I have a listing of products, which is pulled from a database. In order to make the lists more manageable, they are separated into groups of 50 per page, with links to the follow pages auto-generated on the bottom of the page. The links show up correctly and when clicked, show the correct URL in the address bar, but it always shows the same list of items 1-50, as opposed to moving to 51-101, 102-152, etc.
The code was working correctly on another server, but I am moving the site to a new hosting platform and will not work correctly on the new server. Code is listed below:
<tr>
<td height="27" class="link2">View Products</td>
</tr>
<tr>
<td height="300" align="center" valign="top"><div align="left" class="heading1"><br>
</div>
<table width="95%" border="0" cellspacing="0">
<tr class="heading1">
<td width="5%" rowspan="2" align="center">Sl.No</td>
<td width="11%" rowspan="2"> </td>
<td width="24%" rowspan="2">Product Name</td>
<td width="24%" rowspan="2" align="center">Category Name</td>
<td width="14%" rowspan="2" align="center">Display Status</td>
<td colspan="4"> <div align="center">Action</div
></td>
</tr>
<tr align="center" class="heading1">
<td width="9%">Edit</td>
<td width="9%">Delete</td>
<td width="9%">View</td>
<td width="13%">Display Status</td>
</tr>
<?
$dbconn = mysql_connect($hostname, $db_login, $db_pass) or die("Could not connect"); // connects to host
mysql_select_db($database)
or die("Could not select database"); // selecting databes
$string1 = "SELECT e*,c.category_name FROM en_product_master e,en_product_main_category
c where e.product_sub_cat_id=c.mai
n_cat_id order by product_id desc";
$string1 = "SELECT e.* FROM en_product_master e";
//echo $string1;
$result1 = mysql_query($string1) or die('<br>Error Try Again<br>' . mysql_error());
//$result1=getSqlRS($strin
g1);
$recnum=isset($recnum)? $recnum:0;
$proddetails=mysql_fetch_a
rray($resu
lt1);
$row= mysql_num_rows($result1);
if ($row=="0")
{
echo "<tr><td colspan='6' class=heading1 align=center>No Products Existed</td></tr>";
}
for($h=0;$h<preBar1($recnu
m)*50;$h++
)
$proddetails=mysql_fetch_a
rray($resu
lt1);
$cnt=1;
for($fg=1,$cu=0;$h<$row && $cu<50;$h++,$cu++,$fg++)
{
$proddetails=mysql_fetch_a
rray($resu
lt1);
$i=$h;
if (mysql_result($result1,$i,
'product_s
tatus')=="
active")
{
$str= "<a href='adm_tasks1.php?work=
productina
ctive&id="
.mysql_res
ult($resul
t1,$i,'pro
duct_id').
"' title='Click here to inactivate'><img src='images/No.gif' height='15' border='0'></a>";
}
else
{
$str= "<a href='adm_tasks1.php?work=
productact
ive&id=".m
ysql_resul
t($result1
,$i,'produ
ct_id')."'
title='Click here to Activate'><img src='images/Yes.gif' border='0'></a>";
}
?>
<tr valign="middle" class="bodytext">
<td height="43" align="center">
<? echo $cnt; ?>
</td>
<td align="center">
<? if (mysql_result($result1,$i,
'image_nam
e1')!=""){
?>
<img src="upload/<? echo mysql_result($result1,$i,'
image_name
1'); ?>" width="75" height="75">
<?}?>
</td>
<td><? echo substr(mysql_result($resul
t1,$i,'pro
duct_name'
),0,30); ?>
<br> </td>
<td align="center">
<?
$string2 = "SELECT * FROM en_product_main_category where main_cat_id='".mysql_resul
t($result1
,$i,'produ
ct_sub_cat
_id')."'";
// echo $string2;
$result2 = mysql_query($string2) or die('<br>Error Try Again<br>' . mysql_error());
$ns=mysql_num_rows($result
2);
if($ns>0){
$proddetails=mysql_fetch_a
rray($resu
lt2);
$i1=$proddetails[1];
}
echo $i1;
?>
</td>
<td align="center"><? echo mysql_result($result1,$i,'
product_st
atus'); ?></td>
<td align="center"><a href="edit_product.php?id=
<? echo mysql_result($result1,$i,'
product_id
'); ?>&recnum=<? echo $recnum;?>"><img src="images/edit_record.gi
f" width="20" height="20" border="0"></a></td>
<td align="center"><a href="javascript:dele_conf
irm('<? echo mysql_result($result1,$i,'
product_id
');?>','pr
oduct_dele
te')"><img
src="images/icon_delete.gi
f" alt="Click Here to Delete" width="15" height="16" border="0"></a></td>
<td align="center"><a href="../product_detailed.
php?p_id=<
? echo mysql_result($result1,$i,'
product_id
'); ?>" target="_blank"><img src="images/tocdoc.gif" width="24" height="22" border="0"></a></td>
<td align="center"><? echo $str;?></td>
</tr>
<?
$cnt = $cnt + 1;
$i=$i+1;
}
?>
<tr>
<td colspan="9">
<? createNavBar1 ($row,preBar1($recnum),50,
'work='. $work); ?>
</td>
</tr>
Start Free Trial