Problem! Need solution.
Posted: Tue Apr 20, 2004 5:58 am
I’m totally new to programming; trying to learn PHP by editing/creating small scripts. But this one really got me. Here is the template I’m using http://www.dollar5.com/test/datafeed/datafeed.php. All I want to do is display 30 or more records per page. It’s not a big deal for you guys but for me it’s kind of rocket science. Please help me out with this problem.
Code: Select all
<?php
$link = mysql_connect('localhost', 'user', 'pass');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db("dollar5_datafeed", $link)
or die("Couldn't open $db: ".mysql_error());
if(!$rowstart) $rowstart=0;
$query = "SELECT `name`, `keyword`, `desc`, `url`, `imgsm`, `imglr`, `price`, `cat1`, `cat2` FROM test limit $rowstart,1";
$result = mysql_query($query)
or die("SELECT Error: ".mysql_error());
if(!$result) error_message(sql_error());
$query_data = mysql_fetch_array($result);
$name = $query_data["name"];
$keyword = $query_data["keyword"];
$desc = $query_data["desc"];
$url = $query_data["url"];
$imgsm = $query_data["imgsm"];
$imglr = $query_data["imglr"];
$price = $query_data["price"];
$cat1 = $query_data["cat1"];
$cat2 = $query_data["cat2"];
// Display CSS Table
$display = "<table align="center" cellspacing="0" class="table">
<tr class="td-top">
<td colspan="2" class="name">$name</td>
</tr>
<tr class="tr-bottom">
<td align="center" class="td-left"><a href="$imglr" target="_blank"><img src="$imgsm"class="smallimg"></td>
<td class="td-right"><p class="desc">$desc
<p class="price">Special Sale Price: <span class="amount">$ $price</span></p>
<a href="$url" target="_blank"><img src="details_normal.gif" alt="$name" width="100" height="22" border="0" class="details" hsrc="details_over.gif"></a>
</td>
</tr>
</table><br>";
mysql_close($link);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script language="JavaScript" type="text/JavaScript">
function init() {
if (!document.getElementById) return
var imgOriginSrc;
var imgTemp = new Array();
var imgarr = document.getElementsByTagName('img');
for (var i = 0; i < imgarr.length; i++) {
if (imgarr[i].getAttribute('hsrc')) {
imgTemp[i] = new Image();
imgTemp[i].src = imgarr[i].getAttribute('hsrc');
imgarr[i].onmouseover = function() {
imgOriginSrc = this.getAttribute('src');
this.setAttribute('src',this.getAttribute('hsrc'))
}
imgarr[i].onmouseout = function() {
this.setAttribute('src',imgOriginSrc)
}
}
}
}
onload=init;
</script>
<style type="text/css">
<!--
@import url("TEST.css");
-->
</style>
<body>
<table width="600" border="0" align="center" cellpadding="0" cellspacing="0" class="tabletotalresult">
<tr>
<td> Datafeed Test</td>
</tr>
</table><br>
<? echo "$display";?>
<br>
<table width="600" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="right"><table width="220" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<a href="<? $php_self ?>?rowstart=<? echo $rowstart-1;?>"><img src="prev-norm.gif" width="100" height="22" border="0" hsrc="prev-over.gif"></a></td>
<td align="right"><a href="<? $php_self?>?rowstart=<?echo $rowstart+1 ;?>"><img src="next-norm.gif" width="100" height="22" border="0" hsrc="next-over.gif"></a></td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>