suttercain Posted May 17, 2007 Share Posted May 17, 2007 Hi Guys, I know this has been asked before but I am having a lot of trouble, even when looking at older posts, on this same request. I currently have this code: <div class="leftcontainer">RECENT COMICS:</div> <div class="curlycontainer1"> <div class="innerdiv"> <table width="468" border="0" cellspacing="0" cellpadding="2"> <?php //COMIC Genrator $sql1 = mysql_query ("SELECT title, comic_id, issue_number, cover_art, cover_artists, writers, pencillers, cover_date FROM comics WHERE type ='Comic Book' ORDER BY comic_id DESC LIMIT 0, 4"); while ($row1 = mysql_fetch_assoc($sql1)){ $cover_date = date('F, Y', strtotime($row1['cover_date'])); echo "<tr>"; echo "<td width='70'><a href='/comics/view_comics.php?id={$row1['comic_id']}'><img src='images/4ndvddb/" . $row1['cover_art'] . "' height='75px' width='50px'/></a><br></td>"; echo "<td><b><a href='/comics/view_comics.php?id={$row1['comic_id']}'>" . $row1['title'] . " #" . $row1['issue_number'] . "</a></b><br>Cover Date: " . $cover_date . "<br>Written By: " . $row1['writers'] . "<br>Cover Artists: " . $row1['cover_artists'] . "<br>Artists: " . $row1['pencillers'] . "</td>"; echo "</tr>"; } ?> </table> It echos the information as such: IMAGE1 text info IMAGE2 text info IMAGE3 text info IMAGE4 text info I would like to echo the information in two columns as such: IMAGE 1 IMAGE 2 text info text info IMAGE 3 IMAGE 4 text info text info How would I achieve this? Does it involve the modules %? Thanks for the help in advance guys! SC Quote Link to comment Share on other sites More sharing options...
boo_lolly Posted May 17, 2007 Share Posted May 17, 2007 yeah modulus will work. <div class="leftcontainer">RECENT COMICS:</div> <div class="curlycontainer1"> <div class="innerdiv"> <table width="468" border="0" cellspacing="0" cellpadding="2"> <?php //COMIC Genrator $sql1 = mysql_query ("SELECT title, comic_id, issue_number, cover_art, cover_artists, writers, pencillers, cover_date FROM comics WHERE type ='Comic Book' ORDER BY comic_id DESC LIMIT 0, 4"); $i = 0; echo "<tr>\n"; while ($row1 = mysql_fetch_assoc($sql1)){ $cover_date = date('F, Y', strtotime($row1['cover_date'])); echo "<td width='70'><a href='/comics/view_comics.php?id={$row1['comic_id']}'><img src='images/4ndvddb/" . $row1['cover_art'] . "' height='75px' width='50px'/></a><br></td>"; echo "<td><b><a href='/comics/view_comics.php?id={$row1['comic_id']}'>" . $row1['title'] . " #" . $row1['issue_number'] . "</a></b><br>Cover Date: " . $cover_date . "<br>Written By: " . $row1['writers'] . "<br>Cover Artists: " . $row1['cover_artists'] . "<br>Artists: " . $row1['pencillers'] . "</td>"; echo (($i % 2 == 0) ? ("</tr><tr>") : ("")); $i++; } ?> </tr> </table> i think that will work. Quote Link to comment Share on other sites More sharing options...
marf Posted May 17, 2007 Share Posted May 17, 2007 echo (($i % 2 == 0) ? ("</tr><tr>") : ("")); That will print the </tr><tr> on the first iteration. add this perhaps? echo ((($i % 2 == 0) && ($i > 0)) ? ("</tr><tr>") : ("")); Quote Link to comment Share on other sites More sharing options...
suttercain Posted May 17, 2007 Author Share Posted May 17, 2007 Hi guys, I tried both of those and here were the results: Boo_Lolly's echoed the results like this: IMAGE1 Text Description IMAGE2 Text Description IMAGE3 Text Description IMAGE4 Text Description And Marf's slightly altered line of code echoed the results like this: IMAGE1 Text Description IMAGE2 Text Description IMAGE3 Text Description IMAGE4 Text Description Any other suggestions? Thanks again for the time. Quote Link to comment Share on other sites More sharing options...
suttercain Posted May 17, 2007 Author Share Posted May 17, 2007 Alright I altered the code a little bit by takeing out a <td></td> tag and now have this: <table width="468" border="0" cellspacing="0" cellpadding="2"> <?php //COMIC Genrator $sql1 = mysql_query ("SELECT title, comic_id, issue_number, cover_art, cover_artists, writers, pencillers, cover_date FROM comics WHERE type ='Comic Book' ORDER BY comic_id DESC LIMIT 0, 4"); $i = 0; echo "<tr>\n"; while ($row1 = mysql_fetch_assoc($sql1)){ $cover_date = date('F, Y', strtotime($row1['cover_date'])); echo "<td width='231'><a href='/comics/view_comics.php?id={$row1['comic_id']}'><img src='images/4ndvddb/" . $row1['cover_art'] . "' height='75px' width='50px'/></a><br>"; echo "<b><a href='/comics/view_comics.php?id={$row1['comic_id']}'>" . $row1['title'] . " #" . $row1['issue_number'] . "</a></b><br>Cover Date: " . $cover_date . "<br>Written By: " . $row1['writers'] . "<br>Cover Artists: " . $row1['cover_artists'] . "<br>Artists: " . $row1['pencillers'] . "</td>"; echo ((($i % 2 == 0) && ($i > 0)) ? ("</tr><tr>") : ("")); $i++; } ?> </tr> </table> So now the result look like this, IMAGE 1 IMAGE 2 IMAGE 3 Text Desc Text Desc Text Desc IMAGE 4 Text Desc I am almost there I just need to get IMAGE 3 and the Text description below IMAGE 1. Any ideas? Quote Link to comment Share on other sites More sharing options...
Garath531 Posted May 17, 2007 Share Posted May 17, 2007 <div class="leftcontainer">RECENT COMICS:</div> <div class="curlycontainer1"> <div class="innerdiv"> <table width="468" border="0" cellspacing="0" cellpadding="2"> <?php //COMIC Genrator $sql1 = mysql_query ("SELECT title, comic_id, issue_number, cover_art, cover_artists, writers, pencillers, cover_date FROM comics WHERE type ='Comic Book' ORDER BY comic_id DESC LIMIT 0, 4"); $i = 0; echo "<tr>\n"; while ($row1 = mysql_fetch_assoc($sql1)){ $i++; $cover_date = date('F, Y', strtotime($row1['cover_date'])); echo "<td width='70'><a href='/comics/view_comics.php?id={$row1['comic_id']}'><img src='images/4ndvddb/" . $row1['cover_art'] . "' height='75px' width='50px'/></a><br></td>"; echo "<td><b><a href='/comics/view_comics.php?id={$row1['comic_id']}'>" . $row1['title'] . " #" . $row1['issue_number'] . "</a></b><br>Cover Date: " . $cover_date . "<br>Written By: " . $row1['writers'] . "<br>Cover Artists: " . $row1['cover_artists'] . "<br>Artists: " . $row1['pencillers'] . "</td>"; echo (($i % 2 == 0) ? ("</tr><tr>") : ("")); } ?> </tr> </table> Does that work? Quote Link to comment Share on other sites More sharing options...
suttercain Posted May 17, 2007 Author Share Posted May 17, 2007 Hi Garath, That Worked!!! Thank you so much. Thank all three of you! Peace! Quote Link to comment 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.