Jump to content

[SOLVED] Trouble with "WHILE" loops


netrunnr

Recommended Posts

:(

Hello There People!!

 

I'm hacing a slight issue with While loops, can anyone help?

 

                  <?php

					$Sno = 1;
					$pGTotal = 0;

					if(!(session_register('login')))
					{
						$query = "SELECT * FROM userordersdetail WHERE order_id=".$oid."";									
						$result_orderdetails = mysql_query($query)or die("error".mysql_error());
						$rownum = mysql_num_rows($result_orderdetails);

						if($rownum > 0)
						{
							while($res_order = mysql_fetch_array($result_orderdetails))
							{
								$pPrice = $res_order['product_price'];
								$pTotPrice = $pPrice * $res_order['product_qty'];
								$pTotPrice = number_format($pTotPrice,2,'.','');
								$pGTotal = $pGTotal + $pTotPrice;
								$pGTotal = number_format($pGTotal,2,'.','');
								$pPrice = number_format($pPrice,2,'.','');
				?>
                  <tr class="bodyText">
                    <td height="36" align="center"><strong> <?php echo $Sno; ?>.</strong></td>
                    <td align="center"> <?php echo $res_order['product_name']; ?></td>
                    <td align="center"> <?php echo $res_order['product_size']; ?></td>
                    <td align="center">  <?php echo $pPrice; ?></td>
                    <td align="center"> <?php echo $res_order['product_qty']; ?> </td>
                    <td align="center">  <?php echo $pTotPrice; ?> </td>
                    <td> </td>
                    <td> </td>
                  </tr>
                  <tr>
                    <td colspan="8" ></td>
                  </tr>
                  <?php
								$Sno++;
								}
							}
							else
							{
								echo "<tr>";
								echo "<td height=\"25\" colspan=\"8\"><font size=\"2\" face=\"Geneva, Arial, Helvetica, sans-serif\">Shopping Basket Is Empty!</font></td>";
							    echo "</tr>";
							}
						}
						else
						{
					  ?>
                  <tr>
                    <td height="25" colspan="8"> </td>
                  </tr>
                  <tr>
                    <td height="25" colspan="8"> </td>
                  </tr>
                  <?php
						}
					  ?>

Link to comment
https://forums.phpfreaks.com/topic/88356-solved-trouble-with-while-loops/
Share on other sites

Not sure if you are doing the right thing with this line

 

if(!(session_register('login'))) {

 

Think the correct syntax should probably be

 

if(!isset(session_register('login'))) {

 

Explain what you want this line to check and I will see if I can get the correct code for you!

Hey, cheers for the reply.

 

Basically I want the code to check to see if the session is true (which it is). then go through the databse picking out the UserOrderDetails and showing them (what they ordered, quantities etc).

 

I changed the line you mentioned but to no avail.  :-\

I just get the standard: syntax error, unexpected T_STRING, expecting T_VARIABLE... etc

 

Thank you anyway, i just want to connect to the db, read the contents where the Order ID is $oID and just pull the information out.

 

I've done this loads of times, but this time it has be stumped :(

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.