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
[Back to original message]
|