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
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> "; 

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.