Jump to content

Displaying results on multiple pages?


devain

Recommended Posts

Hello Everyone was wondering if I could get some help with the following code? I am querying a database for results of listings that are in a database these listings are displayed on the page in a form. I am wanting each listing to be on a different page. Below is my code.



$lim=1;
if (!isset($s) || $s < 1 || !is_numeric($s)) {
            $s = 1;
        }


    $start = ($s - 1) * $lim;
     $sql = "select id,bussimg,imagewidth,imageheight,email,usridm,company,businesscategory,address1,address2,state,city,zip,website,email,repname,description,phonenumber,country,status from $approvecheckbusinesses where usridm='$user_id'";
    $result=db_query($sql);
      



        $countpages = $sql;
        $sql = $sql . " order by id asc limit $start, $lim";
       $result=db_query($sql);
        $pages = ceil(mysql_num_rows(mysql_query($countpages)) / $lim);
     
    


$result=db_query($sql);
for ($i = 0; $i < mysql_num_rows($result); $i++) {
$Listid= mysql_result($result, $i, "id");

$usridm= mysql_result($result, $i, "usridm");
$CompanyName= mysql_result($result, $i, "company");
$realname= mysql_result($result, $i, "repname");
$email= mysql_result($result, $i, "email");
$BusinessCategory= mysql_result($result, $i, "businesscategory");
$status= mysql_result($result, $i, "status");
    



echo ("FORM IS TO BE DISPLAYED HERE");

}

if ($pages > 1) {
            echo("<p align=left style='font-size: 85% color=white'>");
            for ($i = 1; $i <= $pages; $i++) {
                echo("[");
                if ($i == $s) {echo("<b>");}
                else {echo("<a id=home_offerLink href='index.html?EditMemberListing&user_id=$user_id&s=$i'>");}
                echo("Page $i");
                if ($i == $s) {echo("</b>");}
                else {echo("</a>");}
                echo("]  ");
            }
            echo("</p>")

 

Page Numbers here using the above code.. The problem I seem to be running into is that it only displats the first record. The page numbers show up page 1 page 3

page 2 and three are blank there is no mysql error or anything for some reason I only get that first result out of three

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.