bar2ayunie
Programmer
Hello, I have a php code to display a few things from my sql database. Right now, it's listed in rows:
item 1
item 2
item 3
and so on
But I want to list all of the info in rows AND two columns, like this:
item 1 item 2
item 3 item 4
and so on
I've looked endlessly on google to find codes that will get me to create another column and I did find a few, but I can't seem to get it inserted in the code that I have. I did already manage to have only images be displayed in two columns and as many rows as there are images to display, but I can't seem to add in more information. I keep getting errors.
Is there anybody who knows how to continue? I wil display on the code that works perfectly, which is my starting code and that is the code that needs to be edited in order to display the items in two columns and rows.
This is de code I currently have:
Thank you very much!
item 1
item 2
item 3
and so on
But I want to list all of the info in rows AND two columns, like this:
item 1 item 2
item 3 item 4
and so on
I've looked endlessly on google to find codes that will get me to create another column and I did find a few, but I can't seem to get it inserted in the code that I have. I did already manage to have only images be displayed in two columns and as many rows as there are images to display, but I can't seem to add in more information. I keep getting errors.
Is there anybody who knows how to continue? I wil display on the code that works perfectly, which is my starting code and that is the code that needs to be edited in order to display the items in two columns and rows.
This is de code I currently have:
Code:
(connecting to sql data)
$connection = mysql_connect("$hostname" , "$user" , "$pass") or die ("Can't connect to MySQL");
$db = mysql_select_db($dbase , $connection) or die ("Can't select database.");
$q = "select * from graphics_textures order by id desc ";
$result= mysql_query($q, $connection) or die
("Could not execute query : $q." . mysql_error());
$rows_per_page=10;
$total_records=mysql_num_rows($result);
$pages = ceil($total_records / $rows_per_page);
$screen = $_GET["screen"];
if (!isset($screen))
$screen=0;
$start = $screen * $rows_per_page;
$q .= "LIMIT $start, $rows_per_page";
$result= mysql_query($q, $connection) or die
("Could not execute query : $q." . mysql_error());
while ($row=mysql_fetch_array($result))
{
$id=$row["id"];
$date=$row["date"];
$title=$row["title"];
$artist=$row["artist"];
$thumb=$row["thumb"];
$preview=$row["preview"];
$download=$row["download"];
$pcounter=$row["pcounter"];
$dcounter=$row["dcounter"];
?>
<table cellspacing="0" width="480"><tr><td>
<br><br>
</td></tr><tr><td>
<img src="<?php echo "$thumb"; ?>" align="left">
<b>ID:</b> <?php echo "$id"; ?><br>
<b>Title:</b> <?php echo "$title"; ?><br>
<b>Artist:</b> <?php echo "$artist"; ?><br>
<b>Date:</b> <?php echo "$date"; ?><br>
<a href="../../Downloads/Textures.php?id=<?php echo "$id"; ?>">Download</a>
- [<?php echo "$dcounter"; ?>] <br>
</td></tr></table>
</td></tr></table>
<?php
} #end of while
?>
<p align="center">
<?php
if ($screen > 0)
$j = $screen - 1;
$url = "Textures.php?screen=$j"; // EDIT change 'layout.php' if your page is different
echo "<a href=\"$url\">Prev</a>"; // EDIT change word 'Prev' if desired differently
for ($i = 0; $i < $pages; $i++) {
$url = "Textures.php?screen=" . $i; // EDIT change 'layout.php' if your page is different
$j = $i + 1;
echo " <a href=\"$url\">$j</a> ";
}
if ($screen < $pages-1) {
$j = $screen + 1;
$url = "Textures.php?screen=$j"; // EDIT change 'layout.php' if your page is different
echo "<a href=\"$url\">Next</a>"; // EDIT change word 'Next' if desired differently
}
?>
Thank you very much!