netrunnr Posted January 29, 2008 Share Posted January 29, 2008 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 } ?> Quote Link to comment https://forums.phpfreaks.com/topic/88356-solved-trouble-with-while-loops/ Share on other sites More sharing options...
themistral Posted January 29, 2008 Share Posted January 29, 2008 Please can you be more specific about the problem you are having. Quote Link to comment https://forums.phpfreaks.com/topic/88356-solved-trouble-with-while-loops/#findComment-452171 Share on other sites More sharing options...
netrunnr Posted January 29, 2008 Author Share Posted January 29, 2008 It basically doesn't go past this line: <EDITED> if(!(session_register('login'))) </EDITED> :( Quote Link to comment https://forums.phpfreaks.com/topic/88356-solved-trouble-with-while-loops/#findComment-452176 Share on other sites More sharing options...
netrunnr Posted January 29, 2008 Author Share Posted January 29, 2008 Ok, bit more information, I want this to go through the loop and pick the things out from the SQL database. The session is registered as it is pulling other things from the database. It is just this bit that doesnt work *Help!* (pur-lease) Quote Link to comment https://forums.phpfreaks.com/topic/88356-solved-trouble-with-while-loops/#findComment-452198 Share on other sites More sharing options...
themistral Posted January 29, 2008 Share Posted January 29, 2008 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! Quote Link to comment https://forums.phpfreaks.com/topic/88356-solved-trouble-with-while-loops/#findComment-452208 Share on other sites More sharing options...
netrunnr Posted January 29, 2008 Author Share Posted January 29, 2008 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. :-\ Quote Link to comment https://forums.phpfreaks.com/topic/88356-solved-trouble-with-while-loops/#findComment-452211 Share on other sites More sharing options...
themistral Posted January 29, 2008 Share Posted January 29, 2008 OK try if(isset(session_register('login'))) { I don't use session_register so this may not work in the way I expect - post to let us know if this is still unsuccessful. Quote Link to comment https://forums.phpfreaks.com/topic/88356-solved-trouble-with-while-loops/#findComment-452227 Share on other sites More sharing options...
netrunnr Posted January 29, 2008 Author Share Posted January 29, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/88356-solved-trouble-with-while-loops/#findComment-452232 Share on other sites More sharing options...
netrunnr Posted January 29, 2008 Author Share Posted January 29, 2008 *bump* Quote Link to comment https://forums.phpfreaks.com/topic/88356-solved-trouble-with-while-loops/#findComment-452300 Share on other sites More sharing options...
rajivgonsalves Posted January 29, 2008 Share Posted January 29, 2008 is it that your trying to set the value or get the value it should be if(isset($_SESSION['login'])) { Quote Link to comment https://forums.phpfreaks.com/topic/88356-solved-trouble-with-while-loops/#findComment-452303 Share on other sites More sharing options...
netrunnr Posted January 29, 2008 Author Share Posted January 29, 2008 hmm, well that has stopped the "no items in basket" from coming up, but still no data in the table... it's just empty... It is definitely that line (or my session) as it just skips the entire php section and does the last ELSE statement. ??? Quote Link to comment https://forums.phpfreaks.com/topic/88356-solved-trouble-with-while-loops/#findComment-452310 Share on other sites More sharing options...
netrunnr Posted January 29, 2008 Author Share Posted January 29, 2008 [ [ [ Mega Bump *] ] ] ] Quote Link to comment https://forums.phpfreaks.com/topic/88356-solved-trouble-with-while-loops/#findComment-452329 Share on other sites More sharing options...
adam291086 Posted January 29, 2008 Share Posted January 29, 2008 have you tried echoing $_SESSION['login'] to make sure it has been set Quote Link to comment https://forums.phpfreaks.com/topic/88356-solved-trouble-with-while-loops/#findComment-452330 Share on other sites More sharing options...
netrunnr Posted January 29, 2008 Author Share Posted January 29, 2008 It's ok, I sorted it... My database is formatted into two partitions for data, only one partition was being read. The image below you you lot: <(I'll kill you!) Sorry, but thank you very much for your help (those who took time ) Quote Link to comment https://forums.phpfreaks.com/topic/88356-solved-trouble-with-while-loops/#findComment-452332 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.