The answer you entered to the math problem is incorrect.

storing a variable and looping (1 reply)

I am very much a newbie to mysql with php and I am having some difficulty figuring out how to do what I will describe below:

I am trying to do the following:

List the availability of a product in different states around the US by showing the state and then listing below it all the rows from the database that are in that state, then moving down to the next state and repeating the same procedure until everything has been exausted.

I can select a unique list of states by doing the following:


$result = mysql_query("SELECT DISTINCT clients.State FROM clients,stock WHERE clients.StoreNo=stock.StoreNo AND stock.ProductID=2 AND clients.Country <> 'CAN' ORDER BY State")

or die(mysql_error());

$row = mysql_fetch_array( $result );

// Print out the contents of each row into a table

echo "
echo "'>";

echo $row['State'];

echo "

";

?>

This gives me the first state value of a row that has a Product ID of 2.

Then *somehow* I have to list all the cities below and move to the next.

Would this involve an "IF" statement? A "do while"?

Somehow I would have to store the value of the string variable and compare the rows in the database, and then I would have to discard that value and repeat it with the next.

Any help with this procedure would be GREATLY appreciated.

Reply

Please solve the math problem above and type in the result. e.g. for 1+1, type 2.