0

hello guys
i hav db as to store firstname,lastname,email,addr,city.
if i select any id i want that particular row and also at that same page i click next button next row want to preview.
please help for this by send code as possible soon

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by Dragonbaki
0

Hi gdsm.., Here i post you a sample code.. Just replace your table name and place you displaying format in specified area here, you will get it as your wish.. It will works better., If any probs, pls let me know...

<?php
$id=$_POST['id']               
@$option=$_POST['submit1'];    // This is for your select option.. Previous or Next...
if(isset($option))
{
$i=0;
$sql1=mysql_query("select * from table_name");
while($ret=mysql_fetch_array($sql1))
{
if($i==0)
{
$startid=$ret['id'];    // This will get the starting id in your database....
$i++;
}
else
{
$endid=$ret['id'];    // This will get all id's but it will overwrites upto the last... So, we can get last id of your database by this...
}
}
if($option=='Previous')
{
if($id==$startid)   // if starting id number...
{
echo "Sorry.. No previous records...";
exit;
}
else
{
$id=$id-1;
}
}

if($option=='Next')
{
if($id==$endid)
{
echo "Sorry.. No Next records found..";
exit;
}
else
{
$id=$id+1;
}
}
}

echo "<form action='' name='myform' method='post'>";

$sql=mysql_query("select * from table_name where id='$id'");
if(!sql)
{
echo "Sorry... Records not found.. This may be deleted...";
exit;
}

while($ret=mysql_fetch_array($sql))
{
// Your records displaying code.... It is better to display in a table format...
}
echo "<input type='submit' value='Previous' name='submit1'> &nbsp;&nbsp;&nbsp; <input type='submit' value='Next' name='submit1'>";
?>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.