While loop problem

Links for php scripts

Moderators: macek, egami, gesf

Post Reply
MeroD
New php-forum User
New php-forum User
Posts: 53
Joined: Wed Oct 10, 2012 12:14 am

Re: While loop problem

Post by MeroD » Tue Oct 16, 2012 4:51 am

<?php
$i=0;
$j=5;

do {
echo $i . ",";
$i= round($i,1) + 0.2;
if( $i==2 ){break;}
} while ( $j==5 )

?>

seandisanti
php-forum Fan User
php-forum Fan User
Posts: 973
Joined: Mon Oct 01, 2012 12:32 pm

Re: While loop problem

Post by seandisanti » Tue Oct 16, 2012 12:22 pm

This was a double post when it was created, and the issue was discussed on the other post. it was a combination of a rounding issue and poor coding practice.

jinijames
New php-forum User
New php-forum User
Posts: 20
Joined: Fri Oct 19, 2012 4:32 am
Location: India
Contact:

Re: While loop problem

Post by jinijames » Wed Nov 07, 2012 4:14 am

<?php
include 'db.php';
$i=0;
$result15=mysql_query("select c.dishes from c");
while($row=mysql_fetch_array($result15))
{
if($row['dishes']!=NULL)
{
$dish[$i]=$row['dishes'];
$i++;
}

}

//$j=0;
//while($j<$i)
$j=0;
while($j<$i)
{

$result16=mysql_query("select * from dish_box where dish_name='$dish[$j]'");
while($row=mysql_fetch_array($result16))
{
$v_id=$row['dish_id'];
echo $v_id.'<br />';
}
$j++;

}

mysql_close();
?>

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest