amwd07 Posted December 3, 2007 Share Posted December 3, 2007 I not sure if we are talking nested regions here, or how to change my code? <?php do { $commentid = $row_rs3['rating_id']; //// this coming from another recordset this bit is correct mysql_select_db($database_connDW, $connDW); $query_rs4 = "SELECT * FROM restaurant_ratings WHERE rating_id = '$commentid'"; $rs4 = mysql_query($query_rs4, $connDW) or die(mysql_error()); $row_rs4 = mysql_fetch_assoc($rs4); $totalRows_rs4 = mysql_num_rows($rs4); $name = $row_rs4['name']; $created = $row_rs4['created']; $title = $row_rs4['title']; $comments = $row_rs4['comments']; $commentid = $row_rs4['rating_id']; ?> /// code on page /// <?php do { mysql_select_db($database_connDW, $connDW); $query_rs5 = "SELECT * FROM restaurant_comments WHERE rating_id = '$commentid'"; $rs5 = mysql_query($query_rs5, $connDW) or die(mysql_error()); $row_rs5 = mysql_fetch_assoc($rs5); $totalRows_rs5 = mysql_num_rows($rs5); $cmessage = $row_rs5['message']; $cname = $row_rs5['name']; $ccreated = $row_rs5['created']; ?> <p><strong><?php echo $cname ?></strong> comments <br> <?php echo $ccreated ?><br> <?php echo $cmessage ?></p> <?php } while ($row_rs5 = mysql_fetch_assoc($rs5)); mysql_free_result($rs5); ?> /// code on page /// <?php } while ($row_rs3 = mysql_fetch_assoc($rs3)); mysql_free_result($rs4); ?> Quote Link to comment https://forums.phpfreaks.com/topic/79995-solved-php-do-x2/ Share on other sites More sharing options...
MadTechie Posted December 3, 2007 Share Posted December 3, 2007 Okay.. so what are we talking..? Quote Link to comment https://forums.phpfreaks.com/topic/79995-solved-php-do-x2/#findComment-405273 Share on other sites More sharing options...
amwd07 Posted December 3, 2007 Author Share Posted December 3, 2007 All I need is to have a repeat region for my ratings and each ratings would have a repeat region for the comments on that rating rs3 is to link them by the outlet rs4 is the ratings rs5 is the comments It works until I put the rs5 in then the script times out? <?php do { <?php do { <?php } while ($row_rs5 = mysql_fetch_assoc($rs5)); <?php } while ($row_rs3 = mysql_fetch_assoc($rs3)); Quote Link to comment https://forums.phpfreaks.com/topic/79995-solved-php-do-x2/#findComment-405283 Share on other sites More sharing options...
MadTechie Posted December 3, 2007 Share Posted December 3, 2007 rs5 will neverend, as it starts the search over evertime /// code on page /// <?php /*MOVED out of loop*/ mysql_select_db($database_connDW, $connDW); $query_rs5 = "SELECT * FROM restaurant_comments WHERE rating_id = '$commentid'"; $rs5 = mysql_query($query_rs5, $connDW) or die(mysql_error()); $row_rs5 = mysql_fetch_assoc($rs5); $totalRows_rs5 = mysql_num_rows($rs5); while ($row_rs5 = mysql_fetch_assoc($rs5)) { $cmessage = $row_rs5['message']; $cname = $row_rs5['name']; $ccreated = $row_rs5['created']; ?> <p><strong><?php echo $cname ?></strong> comments <br> <?php echo $ccreated ?><br> <?php echo $cmessage ?></p> <?php } mysql_free_result($rs5); ?> **UPDATED.. try the above Quote Link to comment https://forums.phpfreaks.com/topic/79995-solved-php-do-x2/#findComment-405290 Share on other sites More sharing options...
amwd07 Posted December 3, 2007 Author Share Posted December 3, 2007 Thankyou for helping but what about the do { only one record is now showing does this go before while? Quote Link to comment https://forums.phpfreaks.com/topic/79995-solved-php-do-x2/#findComment-405305 Share on other sites More sharing options...
MadTechie Posted December 3, 2007 Share Posted December 3, 2007 you don't need the do unless you have the condition at the end of the loop.. as you need the condition at the start (to set $row_rs5) do is unneed.. as for the results i have to assume their are connect.. you could try this echo $query_rs5; //<--Add this while ($row_rs5 = mysql_fetch_assoc($rs5)) then copy the statement into PMA and run it.. Quote Link to comment https://forums.phpfreaks.com/topic/79995-solved-php-do-x2/#findComment-405313 Share on other sites More sharing options...
amwd07 Posted December 3, 2007 Author Share Posted December 3, 2007 I have tried what you have said and the query seems to be correct SELECT * FROM restaurant_comments WHERE rating_id = '916' in my db there are 2 entires with 916 in ratings_id Any idea's are you sure I can't pu the do in somewhere? Quote Link to comment https://forums.phpfreaks.com/topic/79995-solved-php-do-x2/#findComment-405321 Share on other sites More sharing options...
amwd07 Posted December 3, 2007 Author Share Posted December 3, 2007 got it working looks like I did need the do in after all ;D <?php mysql_select_db($database_connDW, $connDW); $query_rs5 = "SELECT * FROM restaurant_comments WHERE rating_id = '$commentid'"; $rs5 = mysql_query($query_rs5, $connDW) or die(mysql_error()); $row_rs5 = mysql_fetch_assoc($rs5); $totalRows_rs5 = mysql_num_rows($rs5); do { $cmessage = $row_rs5['message']; $cname = $row_rs5['name']; $ccreated = $row_rs5['created']; ?> <p><strong><?php echo $cname ?></strong> comments <br> <?php echo $ccreated ?><br> <?php echo $cmessage ?></p> <?php } while ($row_rs5 = mysql_fetch_assoc($rs5)); mysql_free_result($rs5); ?> Quote Link to comment https://forums.phpfreaks.com/topic/79995-solved-php-do-x2/#findComment-405471 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.