简体   繁体   中英

Show specific row from table

I have a table table1

id | name | age | emailid
-------------------------------
1  | abc  | 24  | abc@gmail.com
2  | abc  | 35  | abc@gmail.com
3  | abc  | 23  | abc@gmail.com

My php code is:

<?php
require"connection.php";

$email=$_SESSION["email"];

$qry=mysql_query("select * from user_new_history where email='$email' order by id ASC") or die(mysql_error());

while($qry1=mysql_fetch_array($qry))
{
    if($count<1)
    {
        echo $id;
    }
}
?>

It gives last two rows. But I want to show only 2nd row. How can it be possible ?

Please help.

You use email for find user and you have 3 user with same name and email.

You must set unique 'email' and 'name' field.

Then you can find users.

在SQL中执行:

select * from user_new_history where email='$email' order by id ASC LIMIT 1,1

Try this:

<?php
  require"connection.php";

  $email=$_SESSION["email"];

  $qry=mysql_query("select * from user_new_history where email='$email' order by id ASC") or die(mysql_error());
  $count = 1;
   while($qry1=mysql_fetch_array($qry))
   {
     if($count == 2)
     {
       echo $id;
     }
     $count ++;
   }
?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM