wchamber22 Posted February 15, 2011 Share Posted February 15, 2011 Hi, I would like to display my master details page links to the details pages in three columns rather than a single column. Below is the do-while code I have thus far, and I am stuck. Could someone please mock up this code quick, because I know it is a simple syntax error somewhere. <?php do { echo "<table border='0'>"; for ($y=1; ; $y++) { echo "<tr>"; for ($x=1; $x<=3; $x++) { echo "<td align='left'><a href="plantdetails.php?recordID=echo $row_rsBotanicalA['PlantID'];">; echo $row_rsBotanicalA['BotanicalName']; </a></td>" } echo "</tr>"; } } while ($row_rsBotanicalA = mysql_fetch_assoc($rsBotanicalA)); echo "</table>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/227780-displaying-master-details-page-links-in-columns/ Share on other sites More sharing options...
Psycho Posted February 15, 2011 Share Posted February 15, 2011 <?php $columns = 3; $recCount = 0; $plantDetailsHTML = ''; while ($row = mysql_fetch_assoc($rsBotanicalA)) { $recCount++; //Open row if needed if($recCount%$columns==1) { $plantDetailsHTML .= "<tr>\n"; } //Display record $plantDetailsHTML .= "<td align=\"left\">"; $plantDetailsHTML .= "<a href=\"plantdetails.php?recordID={$row['PlantID']}\">{$row['BotanicalName']}</a>"; $plantDetailsHTML .= "</td>\n"; //Close row if needed if($recCount%$columns==0) { $plantDetailsHTML .= "</tr>\n"; } } //Close last row if needed if($recCount%$columns!=0) { $plantDetailsHTML .= "</tr>\n"; } ?> <table> <?php echo $plantDetailsHTML; ?> </table> Quote Link to comment https://forums.phpfreaks.com/topic/227780-displaying-master-details-page-links-in-columns/#findComment-1174646 Share on other sites More sharing options...
wchamber22 Posted February 15, 2011 Author Share Posted February 15, 2011 MJ, Almost there! It is displaying the plants names in columns just as I pictured via your code, except that it is not displaying the first result of the query. Every other database result thereafter displays perfectly! MAN, my code was way off earlier! I am a landscaper trying to showcase plant information on our website to become a leader in the area of plant expertise. If you are in or around the Central IL area I will get you some plants for your garden if you would like. Nice work, and I am sure I'll have more questions. Quote Link to comment https://forums.phpfreaks.com/topic/227780-displaying-master-details-page-links-in-columns/#findComment-1174732 Share on other sites More sharing options...
jcbones Posted February 16, 2011 Share Posted February 16, 2011 You must search your script, Dreamweaver is horrible about fetching the results before you actually need them, thereby moving the array_pointer one index (which makes it seem that you are missing a row). So, look for: mysql_fetch_assoc($rsBotanicalA) And delete it, (as long as it is above the code that Mj gave you above. Or, you can post your entire script here, inside the proper [ code ] blocks, and we will strip it out for you. Quote Link to comment https://forums.phpfreaks.com/topic/227780-displaying-master-details-page-links-in-columns/#findComment-1174766 Share on other sites More sharing options...
wchamber22 Posted February 16, 2011 Author Share Posted February 16, 2011 Hi JC, I know exactly which line you are talking about! Deleted it and bingo all results display correctly, thanks for tip. YOU DA MAN. Sincerely, Bill Quote Link to comment https://forums.phpfreaks.com/topic/227780-displaying-master-details-page-links-in-columns/#findComment-1174822 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.