<table width="100%" align="center" border="0" bgcolor="#FFFFFF">
  <tr height="30px" style="color:#000000;" > 
  	  <th>Unique ID</th>
      <th>Username</th> 
      <th>Form Name</th>
      <th>Name</th> 
      <th>Mobile</th>
      <th>DOB</th> 
      <th>&nbsp;</th> 
  </tr>
  
  
  

                
<?
/*$username="username";
$password="password";
$database="your_database";*/

mysql_connect('locahost', 'username', 'password') or die(mysql_error());
mysql_select_db('database') or die(mysql_error());
$query="SELECT * FROM table_name WHERE user_id='username'";
$result=mysql_query($query);

$num=mysql_num_rows($result);

mysql_close();


$i=0;
while ($i < $num) {

$form_id=mysql_result($result,$i,"form_id");
$form_name=mysql_result($result,$i,"form_name");
$username=mysql_result($result,$i,"user_id");
$first=mysql_result($result,$i,"first");
$surname=mysql_result($result,$i,"surname");
$mobile=mysql_result($result,$i,"mobile");
$dob=mysql_result($result,$i,"dob");





?>
	<tr height="30px" style="color:#999999;" > 
      <th><div style="text-transform:capitalize;"><? echo $form_id; ?></div></th>
	  <th><div style="text-transform:capitalize;"><? echo $username; ?></div></th>
      <th><div style="text-transform:capitalize;"><? echo $form_name; ?></div></th> 
      <th><div style="text-transform:capitalize;"><? echo $first." ".$surname; ?></div></th> 
      <th><? echo $mobile; ?></th> 
      <th><? echo $dob; ?></th> 
      <th><a href="view.php">view</a></th> 
     </tr>

<?
$i++;
}

?>

 </table>               
<? } ?>

When I click "view" it must go to next page with the detail linking using "$form_id;" as primary

Recommended Answers

All 4 Replies

Hi

Please check your line number 54

<th><a href="view.php">view</a></th>

Replace it as below

<th><a href="view.php?id=<?php echo $form_id;?>">view</a></th>

There are two ways....either use <form> or you can do it in the way proposed by rpn_sen

<a href="view.php?id=<?php echo $form_id;?>view</a>

Or

<form method="POST" action="view.php">
<tr height="30px" style="color:#999999;" > 
      <th><div style="text-transform:capitalize;"><? echo $form_id; ?></div></th>
	  <th><div style="text-transform:capitalize;"><? echo $username; ?></div></th>
      <th><div style="text-transform:capitalize;"><? echo $form_name; ?></div></th> 
      <th><div style="text-transform:capitalize;"><? echo $first." ".$surname; ?></div></th> 
      <th><? echo $mobile; ?></th> 
      <th><? echo $dob; ?></th> 
<input tppe="hidden" name="form_id" value=<?php echo $form_id?> >
</form>

Although 1st is better for you as sending data in hidden field id hard coded and its not that much secure...

How can I retrieve those data in next page?

Hi

In View.php page you have get the id value by using GET

$id = $_GET['id']

with the help of $id you have to retrieve data from the table

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.