Hello
- I've made a gallery, and when a user clicks on a thumbnail
he sees a profile of the product using
$productID
$content .= '<a href="product.php?productID=
'.$row['productid'].' ">
<img src=" '.$row['photo'].' " border=0"></a>';
- in the product.php page user is supposed
to
see the product desciption plus photos.
my intention was to put a few images of the
product there,
so I thought of using iframe:
$content.='<iframe
name="image" src="images.php?productID=
'.$row['productid'].'"
scrolling="auto" frameborder="1"
allowtransparency="true"></iframe>';
- then images.php looks like this:
<?
require("mysql_connect.php");
$productID=$_GET[productid];
//check if it works
print $productlID;
$content='';
//photos next and prev script
// set number of results to display per page
$pagelimit = "1";
// run query (change
yourtable to the name of your table)
$strSQL = "SELECT * FROM photos
WHERE photos.productid=$productID
and small='n'";
$result = mysql_query($strSQL)
or die("Error: " . mysql_error());
//do database connection
//count number of matches
$totalrows = mysql_num_rows($result);
// determine how many pages there will be by using ceil()
//and dividing total rows by pagelimit
$pagenums = ceil ($totalrows/$pagelimit);
// if no value for page, page = 1
if ($page==''){
$page='1';
}
// create a start value
$start = ($page-1) * $pagelimit;
// Showing Results 1 to 1 (or if you're page limit were 5)
// 1 to 5, etc.
$starting_no = $start + 1;
if ($totalrows - $start < $pagelimit) {
$end_count = $totalrows;
} elseif ($totalrows - $start >= $pagelimit) {
$end_count = $start + $pagelimit;
}
// create dynamic next, previous, and page links
/* lets say you're set to show 5 results per page
and your script comes out with 7 results.
this will allow your script to say next2
if you're on the first page and previous5
if you're on the second page. */
if ($totalrows - $end_count > $pagelimit) {
$var2 = $pagelimit;
} elseif ($totalrows - $end_count <= $pagelimit) {
$var2 = $totalrows - $end_count;
}
// previous link
//(make sure to change yourpage.php to the
//name of your page)
if ($page>1) {
$content.='<a href="
'. $PHP_SELF .'?page='.($page-1).'">
Previous '.$pagelimit.'</a>';
}
// dynamic page number links (make sure to
// change yourpage.php to the name of your page)
for ($i=1; $i<=$pagenums; $i++) {
if ($i!=$page) {
$content.=' <a href="'. $PHP_SELF .'?page='.$i.'">'.$i.'</a>';
}
else {
$content.='<b>'.$i.'</b>';
}
}
// next link
// (make sure to change yourpage.php to the name of
your page)
if ($page<$pagenums) {
$content.= ' <a href="
'. $PHP_SELF .'?page='.($page+1).'">Next
' . $var2 . '</a> ';
}
/* output your data wherever you'd like.
BUT
in order for this all to work,
before outputting your data,
you have to run the query over using MySQL's LIMIT.
This will limit how many results are
actually displayed on the page. */
$strSQL = mysql_query("SELECT * FROM photos
WHERE
photos.productid=$productID and small = 'n' LIMIT $start,$pagelimit");
// LIMIT 0,10 will start at 0 and display 10 results
// LIMIT 10,5 will start at 10 and display 5 results
/* now you can do whatever you'd like with this query.
it will only output one page at a time.
change the $pagelimit variable to whatever
to output more than 1 result per page. */
// end 123 next>> table
?>
BUT
it says in my iframe window :
"Error: You have an error in your SQL
syntax near 'and small='n'' at line 2"
Can you, guys, help me. please?