Jump to content

[SOLVED] PHP loop


PHPNS

Recommended Posts

Hi,  I seem to struggle with loops in PHP.  Can someone please look at the following code and help me... PLEASE. 

 

$query = "SELECT sh_us_overnight FROM tbl_shipping_us";

 

$result = mysql_query($query);

 

for ($i = 0; $i < $result; $i++) {

 

while ($row = mysql_fetch_array($result)) {

 

$rate = $row[$i];

 

}

}

 

 

echo "$rate[0]";

echo "$rate[1]";

 

Hopefully you geniuses can tell what I'm trying to do here.  If not, I'm simply trying to loop through multiple rows returned so that I can assign each row a to a rate variable.  As in, rate1 equals something (row1), rate2 equals something (row2), etc.

I'm getting a weird result here, where each rate array is giving me the next digit in the final row selected.  Obviously, not what I want.

Link to comment
https://forums.phpfreaks.com/topic/55154-solved-php-loop/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.