ok I made it so that in my index page it would list 10 items from my gallery database
but the items are on top of each other e.g.:
item1
item 2
item3
etc…
I want to be able to orgnise it so it would be like:
item 1 item 2 item 3 item 4
item 5 item 6 item 7 etc…
this is my index page where all my data will show(index.php)
[code]<?php
error_reporting(E_ALL);
ini_set(‘display_errors’, ‘0’);
?>
<?php
// Run a select query to get my letest 6 items
// Connect to the MySQL database
include "script/connect_to_mysql.php";
$dynamicList = "";
$sql = mysql_query("SELECT * FROM gallery ORDER BY id DESC LIMIT 10");
$imageCount = mysql_num_rows($sql); // count the output amount
if ($imageCount > 0) {
while($row = mysql_fetch_array($sql)){
$id = $row["id"];
$dynamicList .= '
';
}
} else {
$dynamicList = "We have no images listed in our store yet";
}
mysql_close();
?>
Store Home Page
<?php include_once("template_header.php");?>
<p><?php echo $dynamicList; ?>
<?php include_once("template_footer.php");?>
[/code]
and this is the page where my data is viewwed i think (gallery.php):
[code]<?php
// This file is www.developphp.com curriculum material
// Written by Adam Khoury January 01, 2011
// http://www.youtube.com/view_play_list?p=442E340A42191003
// Script Error Reporting
error_reporting(E_ALL);
ini_set(‘display_errors’, ‘1’);
?>
<?php
// Check to see the URL variable is set and that it exists in the database
if (isset($_GET['id'])) {
// Connect to the MySQL database
include "script/connect_to_mysql.php";
$id = preg_replace('#[^0-9]#i', '', $_GET['id']);
// Use this var to check to see if this ID exists, if yes then get the product
// details, if no then exit this script and give message why
$sql = mysql_query("SELECT * FROM gallery WHERE id='$id' LIMIT 1");
$imageCount = mysql_num_rows($sql); // count the output amount
if ($imageCount > 0) {
// get all the product details
while($row = mysql_fetch_array($sql)){
$image_name = $row["image_name"];
$date_added = strftime("%b %d, %Y", strtotime($row["date_added"]));
}
} else {
echo "That item does not exist.";
exit();
}
} else {
echo "Data to render this page is missing.";
exit();
}
mysql_close();
?>
<?php echo $image_name; ?>
<?php include_once("template_header.php");?>
<?php echo $image_name; ?>
|
|
</tr>
<?php include_once("template_footer.php");?>
[/code]