By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,501 Members | 2,768 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,501 IT Pros & Developers. It's quick & easy.

Display Multiple Rows From MYSQL Database with PHP

P: n/a
I know this is probably not too hard to do, but how do I display
multiple rows of a mysql query/recordset. Im having trouble doing
this. I don't just want to display them, but I want to make sure ONE
field in each row gets a variable.

The table name is RecentUploads, the field I want to pull is XML

This is probably something simple that is more experienced, but I've
only been doing this for a couple of months. Any help would be
appreicated.

Thank You

http://www.mytuneslive.com

Jan 10 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
ameshkin wrote:
I know this is probably not too hard to do, but how do I display
multiple rows of a mysql query/recordset. Im having trouble doing
this. I don't just want to display them, but I want to make sure ONE
field in each row gets a variable.

The table name is RecentUploads, the field I want to pull is XML

This is probably something simple that is more experienced, but I've
only been doing this for a couple of months. Any help would be
appreicated.

Thank You

http://www.mytuneslive.com


There are some things the mysql database server can do for you ...

if c = space or c is empty or c p xyz then change it to zero otherwise leave it
as it is (or change it to something else....)

select a, b, case when c is null or c = ' ' or c = 'xyz' then '0' else c end, d,
e, f from table where....

Then simply display the results.

or

$link=mysql_connect($HOST,$USR,$PWD,$DB);
if( $link ) {
mysql_select_db( $DB, $link );
if( $sql ) {
$sql = ereg_replace( ";$", "", $sql );
$sql = ereg_replace( "\\\\", "", $sql );
$result = mysql_query( $sql, $link );
if( $result ) {
echo( "<p>Results: for '$sql;'.</p>\n" );
if( $num = mysql_num_rows( $result ) ) {
echo( "<pre>\n" );
while( $array = mysql_fetch_row( $result ) ) {
while( list($key, $val) = each( $array ) ) {
-->>> here check to see if the val for key = whatever and change it...
echo "$val | ";
} # end while
echo "<br />\n";
} # end while
echo( "</pre>" );
} elseif( $af = mysql_affected_rows( $link ) ) {
echo( "<p>$af rows affected.</p>\n" );
} else {
echo( "<p>Command completed.</p>\n" );
} # end if
} else {
echo( "<p>Bad query: '$sql;'.</p>" );
echo( mysql_errno() . ": " .
mysql_error() . "<br />" );
} # end if
} else {
echo( "<p>Connected to '$DB'.</p>" );
} # end if
} else {
echo( "<p>Bad connection.</p>" );
echo( mysql_errno() . ": " .
mysql_error() . "<br />" );
} # end if
?>
--
Michael Austin.
Jan 10 '06 #2

P: n/a
Michael,
That was a little too complicated. If i were to show you my code, do
you think you could fix it?

Jan 10 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.