You are here: Re: [PHP] Little Problem with my Guestbook « PHP « IT news, forums, messages
Re: [PHP] Little Problem with my Guestbook

Posted by John Nichel on 09/14/05 16:45

Florian P. wrote:
> <?php
>
> include("sql.inc.php");
> include("config.inc.php");
>
> $connection = mysql_connect($sql['host'],$sql['uid'],$sql['pwd']);
> $select_db = mysql_select_db($sql['db']);
>
> $select = mysql_query('SELECT * FROM comments');
> $data = mysql_fetch_array($select);
>
> $result = mysql_query('SELECT * FROM comments');
> $rows = mysql_num_rows($result);
<snip>

No reason to run this twice....

$data = array();
if ( $result = mysql_query ( 'SELECT * FROM comments' ) ) {
while ( $temp = mysql_fetch_array ( $result, MYSQL_ASSOC ) ) {
$data[] = $temp;
}
$rows = mysql_num_rows ( $result );
mysql_free_result ( $result );
} else {
echo ( mysql_error() );
exit;
}

The returned rows will be in the $data array.

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
john@kegworks.com

 

Navigation:

[Reply to this 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

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