hi
i need to link my select to another page (form)

i write :

<?
session_start();
if(!session_is_registered(myusername)){
header("location:main_login.php");
}
?>

<html>
<link href="style.css" rel="stylesheet" type="text/css">
<body>
Login Successful

<?php
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("project", $con);

$result = mysql_query("SELECT * FROM patient");

echo "<table class='table' >
<tr>
<th class='th'>patient id </th>
<th class='th'>date of birth</th>
<th class='th'>family name</th>
<th class='th'>dather name </th>
<th class='th'>given name</th>
<th class='th'>sex </th>
<th class='th'>status </th>


</tr>";

while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td class='td' >" . $row . "</td> ";
echo "<td class='td' >" . $row . "</td>";
echo "<td class='td' >" . $row . "</td>";
echo "<td class='td' >" . $row . "</td>";
echo "<td class='td' >" . $row . "</td>";
echo "<td class='td' >" . $row . "</td>";
echo "<td class='td' >" . $row . "</td>";

echo "</tr>";
}
echo "</table>";

mysql_close($con);
?>

</body>
</html>


so i want to link page with form by patient id
how to make it

before posting, read how to wrap code in [code=language] [/code] tags, makes it easier to read, in this inst code=php
more likely to get assistance if the person with potential to assist is not correcting what is seen as impoliteness, (every new poster wonders why few or nobody helps)
without beating you for using tables in this case they are appropriate for tabular data (there is a bunch of other threads debating tables/css positioning)
Your

echo "<td class='td' >" . $row['pat_id'] . "</td> ";

assuming another page patient.php in which the full details for a single patient are selected from the database by pat_id

echo "<td class='td' ><a href='patient.php?pat_id=".$row['pat_id']."'>".$row['pat_id']."</a></td> ";

creates a link to the patient.php file passing the pat_id
if this is not what you mean, I hope it provides some insight, or postback if Im too far off target

if this code sample is not just a dump for the purpose of the question, you should complete the html; a dtd, closure of all incomplete elements, to ensure it displays as you intend

Seems like almostbob and I got to this at the same time with two different solutions. His is a little simpler to implement while this one may look a little fancier at the expense of a bit more work to code it. The choice is yours.

He already mentioned the code tags so enough said on that.

Your question wasn't totally clear but I have taken a stab at it. If this is an administrator's page where you want to list all of the patients and let the user choose one to see more details, then you can make the output lines part of a form. You could output a <form> statement before the While loop, output a </form> after the end of the loop and then make the first item in each row a radio button:

echo "<td class='td'><input type=radio name=pat$i value=.$row['pat_id']."></td>";

You need a variable $i that is incremented by one on each iteration of the loop to provide a patient number. The module that processes this form will receive a $_POST (or $_GET) variable for each patient, pat$i (e.g. pat1, pat2 etc) that will be used to know which one was selected. If the patient was selected, the value will be the patient ID, otherwise it will be an empty string.

I hope that this is helpful. I had to interpret what you are trying to do so hopefully I got it right. If you understand how HTML forms work, then this should be sufficient info for you to work with. If not, then you may want to go the W3schools or other online sources to understand how forms work. The one thing that here that goes beyond a simple form is that we are creating a series of form variables with unique and predictable names (pat1, pat2, pat3... etc). That allows you to check them in the receiving module to find out which one was selected.

thanx chrishea is work for me to link to another form

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.