Ok so here is what I am trying to accomplish. On a page, I am trying to get it setup so that a box appears for each network site, and then that network site appears in the title portion of my box, and then all the sub sites appear in the body section of that area. Plain Text Example: Network: Title Site Here sub_site 1 [*]credits [*]refs [*]cashout sub_site 2 [*]credits [*]refs [*]cashout sub_site 3 [*]credits [*]refs [*]cashout sub_site 4 [*]credits [*]refs [*]cashout ---------------------------------------- Now I have in fact got the title portion working properly, and the box to display correctly. All is good with that. Now Im driving myself loopy trying to get the 'sub loop' if you will (the loop that pulls the sub sites in) to work properly. For now using the present code below, it is just looping a single sub site over and over. What it SHOULD do is call to the database and loop thru any sub sites for that net_id and display them in the body area of the box, so it produces the example above. Here is my present code. I know it's close - but i think ive just been looking at it too long and can't get it right.... <!-- START MIDDLE BOX --> <table border="0" cellpadding="0" cellspacing="0" width="500" style="margin: 10px;"> <?php while ($row = mysql_fetch_array($result)) { $site_name = ucwords(strtolower($row["site_name"])); $new_id = $row["net_id"]; echo ' <tbody><!-- This creates the layout for header and body of each listing--> <tr> <td width="451" align="left" class="TabText" style="background-image: url(yardlist_files/headerBackground.gif);"><font color="#FFFFFF"><b> Network: ' . $site_name . ' </b></font></td> </tr> <tr> <td> <table class="BoxFrame" border="0" cellpadding="0" cellspacing="1" width="100%">'; $s_sites = mysql_query("SELECT * FROM sub_sites WHERE net_id = {$new_id}", $link); $sub_rows = mysql_num_rows($s_sites); while ($s_row = mysql_fetch_array($s_sites)) { $myArray = array( $s_site = $s_row["site_name"], $credit = $s_row["credit"], $refs = $s_row["refs"], $pay_out = $s_row["pay_out"], $net_id = $s_row["net_id"]); } echo ' <tbody> <tr> <td class="BoxContent" style="padding: 8px;"> <ul style="margin: 0px; padding: 0px 0px 0px 16px;">'; foreach ( array_keys($myArray) as $key ) { $element =& $myArray[$key]; echo ' <li><a href="" class="BoxLink">' . $s_site . '</a></li> <a href="" class="BoxLink">' . $credit . ' Credit(s)</a> <a href="" class="BoxLink">' . $refs . ' Referral(s)</a> <a href="">' . $pay_out . '</a> '; } echo ' </ul></td> </tr> </tbody> </table> </td> </tr> </tbody>'; } ?> </table> <!-- END MIDDLE BOX --> PHP: any help is definitely appreciated and if you pm me your paypal email i may be able to forward you over a couple of bucks for your time. thanks so much and sorry for the inconvenience.
hmm, the code is kinda long so i did not bother to read through all of them, what stands out though is this line $myArray = array( $s_site = $s_row["site_name"], $credit = $s_row["credit"], $refs = $s_row["refs"], $pay_out = $s_row["pay_out"], $net_id = $s_row["net_id"]); } i dont know why you need to put it in an array when you can just use assign the values to the variables and output it directly since i assumed that is what you want to do
darn bbcode <!-- START MIDDLE BOX --> <table border="0" cellpadding="0" cellspacing="0" width="500" style="margin: 10px;"> <?php while ($row = mysql_fetch_array($result)) { $site_name = ucwords(strtolower($row["site_name"])); $new_id = $row["net_id"]; echo ' <tbody><!-- This creates the layout for header and body of each listing--> <tr> <td width="451" align="left" class="TabText" style="background-image: url(yardlist_files/headerBackground.gif);"><font color="#FFFFFF"><b> Network: ' . $site_name . ' </b></font></td> </tr> <tr> <td> <table class="BoxFrame" border="0" cellpadding="0" cellspacing="1" width="100%"> <tbody> <tr> <td class="BoxContent" style="padding: 8px;"> <ul style="margin: 0px; padding: 0px 0px 0px 16px;">'; $s_sites = mysql_query("SELECT * FROM sub_sites WHERE net_id = {$new_id}", $link); $sub_rows = mysql_num_rows($s_sites); while ($s_row = mysql_fetch_array($s_sites)) { $s_site = $s_row["site_name"], $credit = $s_row["credit"], $refs = $s_row["refs"], $pay_out = $s_row["pay_out"], $net_id = $s_row["net_id"]; echo ' <li><a href="" class="BoxLink">' . $s_site . '</a></li> <a href="" class="BoxLink">' . $credit . ' Credit(s)</a> <a href="" class="BoxLink">' . $refs . ' Referral(s)</a> <a href="">' . $pay_out . '</a> '; } echo ' </ul></td> </tr> </tbody> </table> </td> </tr> </tbody>'; } ?> </table> <!-- END MIDDLE BOX --> PHP:
Try these change and see if its work. 1) while ($s_row = mysql_fetch_array($s_sites)) { $myArray = array( $s_site = $s_row["site_name"], $credit = $s_row["credit"], $refs = $s_row["refs"], $pay_out = $s_row["pay_out"], $net_id = $s_row["net_id"]); } PHP: Replace that while loop with this code. $s_row = mysql_fetch_array($s_sites); PHP: 2) foreach ( array_keys($myArray) as $key ) { $element =& $myArray[$key]; echo ' <li><a href="" class="BoxLink">' . $s_site . '</a></li> <a href="" class="BoxLink">' . $credit . ' Credit(s)</a> <a href="" class="BoxLink">' . $refs . ' Referral(s)</a> <a href="">' . $pay_out . '</a> '; } PHP: Replace that code with this code. foreach ( $s_row as $key => $value ) { $element = $key; echo ' <li><a href="" class="BoxLink">' . $s_row['site_name'] . '</a></li> <a href="" class="BoxLink">' . $s_row['credit'] . ' Credit(s)</a> <a href="" class="BoxLink">' . $s_row['refs'] . ' Referral(s)</a> <a href="">' . $s_row['pay_out'] . '</a> '; }//end foreach PHP: