Hello All,
PHP newbie here ... I have the following code working to retrive the last 50 records from a reservation database:

<?php
/* Databasae Variables */
$username="user"; 
$password="pass";
$database="db"; 

/* Database Connection */
mysql_connect("1.1.1.1",$username,$password); 
mysql_select_db($database) or die ('Unable to select database'); 

/* Select last 50 records */
$query = "SELECT * FROM reservations ORDER BY customerid desc LIMIT 50";
$result = mysql_query($query);
$num=mysql_numrows($result);

/* Output Data in table */

echo "<html>
	<head>
	<style type='text/css'>
	    td {text-align: center}
	    
	</style>
	</head>
	
      <font face='book antiqua'>
      <h2 align='center'>Reservations Log (last 50 reservations)</h2>
      </font>
      <font face='book antiqua' size='1'>
      <table width='1800' align='center' cellspacing='5' cellpadding='3' border='1'>
      	<tr>
      	 <td><strong>ID</strong></td>
      	 <td><strong>Full Name</strong></td>
      	 <td><strong>Email</strong></td>
      	 <td><strong>Address</strong></td>
      	 <td><strong>City</strong></td>
      	 <td><strong>State</strong></td>
      	 <td><strong>Zip</strong></td>
      	 <td<strong>Phone</strong></td>
      	</tr>
";

	
$i=0;
while ($i < $num) {
$customerid=mysql_result($result,$i,"customerid");
$firstname=mysql_result($result,$i,"firstname");
$lastname=mysql_result($result,$i,"lastname");
$email=mysql_result($result,$i,"email");
$address=mysql_result($result,$i,"address");
$city=mysql_result($result,$i,"city");
$state=mysql_result($result,$i,"state");
$zip=mysql_result($result,$i,"zip");
$phone=mysql_result($result,$i,"phone");

echo "<tr>
 	 <td><a href=\"$customerid\">somepage.php</a></td>   
	 <td>$firstname $lastname</td>
	 <td><a href='mailto:$email'>$email</a>	</td>
	 <td>$address</td>
	 <td>$city</td>
	 <td>$state</td>
	 <td>$zip</td>
	 <td>$phone</td>
      </tr>	
	  ";
$i++;
}
echo "
      </table>
      </font>
      </html>";
?>

The database has a lot more info but it doesn't look good to view it all in one page. So I would like to setup dynamic links (line 57) for each record and when the user clicks on it, another window will open listing all info for that particular record ...

I am heavily researching the subject but i'll apprecaite any hint from you guys ...

Thank you all :-)

Welcome waelaltaqi.

You can modify line # 57

<td><a href=\"somepage.php?customerid=$customerid\" target=\"_blank\">somepage.php</a></td>

and write following code in somepage.php

<?php
    $custmerid=$_REQUEST["customerid"];
    $sql="select * from yourtablename where customerid='$customerid'";
    ...
    ...
?>

Worked like a champ ... just to undestand a little better, by setting <a to:

<a href=\"somepage.php?customerid=$customerid\" target=\"_blank\">

is that like passing a $_GET variable?

Yes, you may use $_GET.

i think problem is solved no need to answer.

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.