Reply to Re: Display Multiple Rows From MYSQL Database with PHP

Your name:

Reply:


Posted by Michael Austin on 01/10/06 03:12

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.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация