m118 Posted January 5, 2011 Share Posted January 5, 2011 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. session_start(); $_SESSION['brand']=$_POST['brand']; $_SESSION['type']=$_POST['type']; $_SESSION['sort']=$_POST['sort']; include("connection.php"); 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()); <?php while ($row=mysql_fetch_array($result2)) { ?> <tr> <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> </tr> <?php }; ?> </table> <?php $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> </div> <?php } ?> Quote Link to comment https://forums.phpfreaks.com/topic/223514-i-need-to-fix-session-code/ Share on other sites More sharing options...
Maq Posted January 5, 2011 Share Posted January 5, 2011 Use code tags. What doesn't work? What happens? Are there any errors? Please, we need more information. Quote Link to comment https://forums.phpfreaks.com/topic/223514-i-need-to-fix-session-code/#findComment-1155355 Share on other sites More sharing options...
m118 Posted January 5, 2011 Author Share Posted January 5, 2011 hello 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 Quote Link to comment https://forums.phpfreaks.com/topic/223514-i-need-to-fix-session-code/#findComment-1155356 Share on other sites More sharing options...
m118 Posted January 5, 2011 Author Share Posted January 5, 2011 The code can work on the first page. Quote Link to comment https://forums.phpfreaks.com/topic/223514-i-need-to-fix-session-code/#findComment-1155358 Share on other sites More sharing options...
m118 Posted January 5, 2011 Author Share Posted January 5, 2011 hello I think the session code is working, because I can see this link on the browser. http://localhost/php1000/table2.php?page=2&id=HP&cd=Copier&td=MICR Toner Quote Link to comment https://forums.phpfreaks.com/topic/223514-i-need-to-fix-session-code/#findComment-1155364 Share on other sites More sharing options...
m118 Posted January 6, 2011 Author Share Posted January 6, 2011 Who can give any idea ? Thank you very much. Quote Link to comment https://forums.phpfreaks.com/topic/223514-i-need-to-fix-session-code/#findComment-1155779 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.