Advertisement

05.09.2008 at 09:04PM PDT, ID: 23391284 | Points: 250
[x]
Attachment Details

PHP - Item list with page links at the bottom (50 items per page, 14 pages), links don't move to next page

Asked by x3o in PHP and Databases, MySQL Server, WebApplications

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">&nbsp;</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.main_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($string1);
                                                      
                                                      $recnum=isset($recnum)? $recnum:0;
                                                      $proddetails=mysql_fetch_array($result1);
                                                      
                                                      $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($recnum)*50;$h++)
                                                            $proddetails=mysql_fetch_array($result1);
                                                      
                                                      $cnt=1;
                                                      for($fg=1,$cu=0;$h<$row && $cu<50;$h++,$cu++,$fg++)
                                                      {
                                                            $proddetails=mysql_fetch_array($result1);
                                                            $i=$h;
                                                      if (mysql_result($result1,$i,'product_status')=="active")
                                                      {
                                                            $str= "<a href='adm_tasks1.php?work=productinactive&id=".mysql_result($result1,$i,'product_id')."' title='Click here to inactivate'><img src='images/No.gif'  height='15' border='0'></a>";
                                                      }
                                                      else
                                                      {
                                                            $str= "<a href='adm_tasks1.php?work=productactive&id=".mysql_result($result1,$i,'product_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_name1')!=""){?>
            <img src="upload/<? echo mysql_result($result1,$i,'image_name1'); ?>" width="75" height="75">
            <?}?>
          </td>
          <td><? echo substr(mysql_result($result1,$i,'product_name'),0,30); ?>
            <br> </td>
          <td align="center">
            <?
              $string2 = "SELECT * FROM en_product_main_category   where main_cat_id='".mysql_result($result1,$i,'product_sub_cat_id')."'";
             // echo $string2;
              $result2 = mysql_query($string2) or die('<br>Error Try Again<br>' . mysql_error());
              $ns=mysql_num_rows($result2);
              if($ns>0){
                    $proddetails=mysql_fetch_array($result2);                                    
                    $i1=$proddetails[1];
                  }
             
             
              echo $i1;
             
            
               ?>
          </td>
          <td align="center"><? echo mysql_result($result1,$i,'product_status'); ?></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.gif" width="20" height="20" border="0"></a></td>
          <td align="center"><a href="javascript:dele_confirm('<? echo  mysql_result($result1,$i,'product_id');?>','product_delete')"><img src="images/icon_delete.gif" 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
[+][-]05.09.2008 at 09:10PM PDT, ID: 21537828

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.09.2008 at 09:34PM PDT, ID: 21537866

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.09.2008 at 09:52PM PDT, ID: 21537895

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.09.2008 at 09:54PM PDT, ID: 21537897

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.09.2008 at 10:04PM PDT, ID: 21537907

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.09.2008 at 10:30PM PDT, ID: 21537956

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.09.2008 at 10:49PM PDT, ID: 21537980

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.09.2008 at 10:53PM PDT, ID: 21537987

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.10.2008 at 05:34PM PDT, ID: 21541057

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.10.2008 at 05:36PM PDT, ID: 21541070

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.10.2008 at 05:49PM PDT, ID: 21541124

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20081112-EE-VQP-42 / EE_QW_2_20070628