Jump to content

I need to fix session code


Recommended Posts

In order to keep data on the browser , so I use session to keep post data. I  try to turn the page. I does not work , I do not know how to fix it. Please tell me . Thank you very much.












if (isset($_GET["page"])) { $page  = $_GET["page"]; } else { $page=1; };

$start_from = ($page-1) * 18;





$select="select * from $chun where  brand = '$_SESSION[brand]'  or sort='$_SESSION[sort]' or type ='$_SESSION[type]'  LIMIT $start_from, 18";


$result2=mysql_query($select, $connection) or die (mysql_error());







  while ($row=mysql_fetch_array($result2)) {








        <td><?php  echo $row['item'];?></td>

        <td><?php  echo $row['oempart'];?></td>

        <td><?php echo $row['compatibility'];?></td>

        <td><?php echo $row['colorful'];?></td>



        <td><?php echo $row['comprice']; ?></td>

        <td><?php  echo $row['oemprice']; ?></td>











    $sql = "select count(*) from $chun  where    brand = '$_SESSION[brand]' or  type ='$_SESSION[type]' or sort='$_SESSION[sort]'  ";



$rs_result = mysql_query($sql,$connection);

$row = mysql_fetch_row($rs_result);

$total_records = $row[0];

$total_pages = ceil($total_records / 18);


for ($i=1; $i<=$total_pages; $i++) {









      <div class="trunpage"><a href='table2.php?page=<?php echo  "$i" ; ?>&id=<?php echo $_SESSION['brand'];?>&cd=<?php echo $_SESSION['type'];?>&td=<?php echo $_SESSION['sort'];?>'  ><?php echo  "$i" ; ?></a>















Link to comment
Share on other sites



The code can work on one page. when I try to turn the page to the next page, I get error message.


Notice: Undefined index: brand in C:\wamp\www\php1000\table2.php on line 179


Notice: Undefined index: type in C:\wamp\www\php1000\table2.php on line 180


Notice: Undefined index: sort in C:\wamp\www\php1000\table2.php on line 181


Link to comment
Share on other sites

This thread is more than a year old.

Join the conversation

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

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.