Jump to content

[SOLVED] 2 Columns echoed from the MySQL Database


suttercain

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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?

 

Link to comment
Share on other sites

<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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.