Code: Select all
<?php
$result=mysql_query("SELECT * FROM table WHERE thisfield = '$thatvariable'");
while ( $a_row = mysql_fetch_object( $result ) )
{
//do whatever
}
?>Moderator: General Moderators
Code: Select all
<?php
$result=mysql_query("SELECT * FROM table WHERE thisfield = '$thatvariable'");
while ( $a_row = mysql_fetch_object( $result ) )
{
//do whatever
}
?>Code: Select all
list($a, $b, $c) = mysql_fetch_row(mysql_query($query));Code: Select all
$res=mysql_query($query) or handle_error();
list($a, $b, $c) = mysql_fetch_row($res);Code: Select all
$res = $db->query($query);
switch($res->numrows()) {
case 0 : handle_not_found(); break;
case 1: handle_normal(); break;
default: handle_multiple_found_error(); break;
}
//or
$res = $db->query($query);
if ($res->numrows()!=1) handle_error();
else {
// normal processing
}