HDFilmMaker2112 Posted July 10, 2011 Share Posted July 10, 2011 I'm having a bit of an issue with the below: for($i=1; $i <= 3; $i++){ $credits_query="SELECT * FROM $tbl_name4 WHERE film_number='$i'"; $credits_result=mysql_query($credits_query); $content.=' <div class="credit_header">'; if($i==1){$content.='First';}elseif($i==2){$content.='Second';}elseif($i==3){$content.='Third';} $content.=' Film Crew/Producer Credits </div> <table class="producer_table"> <tr class="producer_background"> <td class="border sixty"> Crew or Producer Position </td> <td class="border twenty"> Amount </td> <td class="border"> Buy </td> </tr> </table> <div class="producer_scroll"> <table class="producer_table">'; while($credits_row=mysql_fetch_row($credits_result)){ extract($credits_row); $content.=' <tr align="center"> <td class="border sixty">' .$position. '</td> <td class="border twenty">$' .$cost. '</td> <td class="border"> <form action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_s-xclick"> <input type="hidden" name="hosted_button_id" value="'.$product_code.'">QMNXL6WXL4YL6 <input type="image" src="https://www.paypal.com/en_US/i/btn/btn_buynow_SM.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"> <img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1"> </form> </td> </tr>'; } $content.=' </table> </div>'; } I'm trying to make it loop three times, once for each film. Under each generated table it will be filled in with the credits available for purchase for that specific film, with that data being pulled from the database. Currently, it's not generating the tables with the database data: It just does this: <div class="producer_scroll"> <table class="producer_table"> </table> </div> <div class="credit_header">First Film Crew/Producer Credits </div> <table class="producer_table"> <tr class="producer_background"> <td class="border sixty"> Crew or Producer Position </td> <td class="border twenty"> Amount </td> <td class="border"> Buy </td> </tr> </table> <div class="producer_scroll"> <table class="producer_table"> </table> </div> <div class="credit_header">Second Film Crew/Producer Credits </div> <table class="producer_table"> <tr class="producer_background"> <td class="border sixty"> Crew or Producer Position </td> <td class="border twenty"> Amount </td> <td class="border"> Buy </td> </tr> </table> <div class="producer_scroll"> <table class="producer_table"> </table> </div> <div class="credit_header">Third Film Crew/Producer Credits </div> <table class="producer_table"> <tr class="producer_background"> <td class="border sixty"> Crew or Producer Position </td> <td class="border twenty"> Amount </td> <td class="border"> Buy </td> </tr> </table> <div class="producer_scroll"> <table class="producer_table"> </table> </div> Quote Link to comment https://forums.phpfreaks.com/topic/241541-issue-looping-through-database-items-using-for-and-while/ Share on other sites More sharing options...
HDFilmMaker2112 Posted July 10, 2011 Author Share Posted July 10, 2011 Forgot to mention it also gives this error: Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/zyquo/public_html/makethemoviehappen.com/main.php on line 347 Line 347 -> while($credits_row=mysql_fetch_array($credits_result)){ EDIT: I didn't set the $tbl_name4 variable. All my problems are so simple... Quote Link to comment https://forums.phpfreaks.com/topic/241541-issue-looping-through-database-items-using-for-and-while/#findComment-1240694 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.