Re: Multiple <a> Tags, Filled With MySQL DB data with PHP [message #179259 is a reply to message #179247] |
Wed, 26 September 2012 14:25 |
Denis McMahon
Messages: 634 Registered: September 2010
Karma:
|
Senior Member |
|
|
On Tue, 25 Sep 2012 19:48:35 -0400, Jerry Stuckle wrote:
>> <?php $sql = "SELECT id, imagelink, comment, picdate, rel FROM
>> PictureMedia ORDER BY picdate DESC";
>> $visuals_query=mysql_query( $sql );
>> $debug = "sql: " $sql . "\nresult: " . var_dump( $visuals_query ) .
>> "\n"; if ( $visuals_query == false )
>> $debug .= "sql error: " . mysql_error() . "\n";
>> ?>
> Won't show much. The result of a mysql_query call is a result, not an
> array. All it will say is "false" or "resource id 2" (or similar). And
> your following "if" statement will handle the first result.
Point taken, it probably needs to be more like:
<?php
$sql = "SELECT id, imagelink, comment, picdate, rel FROM PictureMedia
ORDER BY picdate DESC";
$visuals_query = mysql_query( $sql );
$debug = "sql: " $sql . "\n";
if ( $visuals_query == false ) {
$debug .= "sql error: " . mysql_error() . "\n";
}
else {
$debug .= "Result set contained " . mysql_num_rows( $visuals_query
) ." rows\n";
if ( mysql_num_rows( $visuals_query ) > 0 ) {
$debug .= "Rows:\n"
while ( $tmp = mysql_fetch_assoc( $visuals_query ) )
$debug .= var_dump( $tmp );
mysql_data_seek( $visuals_query, 0 );
}
}
?>
Rgds
Denis McMahon
|
|
|