Looping through the Database

the mail() function

Moderators: macek, egami, gesf

Post Reply
User avatar
freshnet
php-forum Active User
php-forum Active User
Posts: 359
Joined: Tue Feb 22, 2011 8:19 am
Location: Canada

Re: Looping through the Database

Post by freshnet » Thu Mar 22, 2012 2:48 pm

You'll want to fetch your query results into a variable and then use a foreach on that variable, e.g.

Code: Select all

$sql = mysqli_query($mysqli,"SELECT x FROM y");
$sql_result = mysqli_fetch_array($sql);

foreach ($sql_result as $value)
{
if ($value == $something_else)
{some code}
else
{some more code}
}

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests