Jump to content

how to keep get[] date


m118

Recommended Posts

I am working on one web site.

 

<li><a href="table.php?id=<?php  echo "Brother" ;?>&cd=<?php echo "Inkjet"; ?>">Brother</a></li>

 

<?php

 

include("connection.php");

 

$cd=$_GET["cd"];

$id=$_GET["id"];

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

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

$select="select * from $chun where brand = '$id' and kind ='$cd'  LIMIT $start_from, 12";

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

 

?>

 

 

 

<?php

 

$sql = "select count(*) from $chun where brand = '$_GET[id]' and kind ='$_GET[cd]'";

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

$row = mysql_fetch_row($rs_result);

$total_records = $row[0];

$total_pages = ceil($total_records / 12);

 

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

            echo "<a href='table.php?page=".$i."'>".$i."</a> ";

};

?>

 

 

This problem can only can display one page, the second page can not display. I think the reason is that the get[] function can get data when I trun the page.  Please tell me how to keep data at command line. $select="select * from $chun where brand = '$id' and kind ='$cd'  LIMIT $start_from, 12"; When I try to trun the page, the brand and kind can not get the data. Thank you very much.

Link to comment
https://forums.phpfreaks.com/topic/221913-how-to-keep-get-date/
Share on other sites

Your question is really hard to understand, it's not clear which page is the first and which is the second.

 

Remember that $_GET contains all the parameters that are in the URL. So if your URL is http://www.site.com/page.php?xid=yvalue then $_GET will contain one key "xid" with the value "yvalue".

 

Keeping that in mind, try making this change...

 

echo "<a href='table.php?page=".$i."&id=".$_GET['id']."&cd=".$_GET['cd']."'>".$i."</a> "; 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.