Page 1 of 1

more newbie help

Posted: Wed Sep 07, 2005 5:53 am
by tom.cull
ok - last one for a while I promise - my brain is tired and I just cant seem to think!

this is some code:

Code: Select all

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Car Test - Add Entry</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>

<form enctype="multipart/form-data" method="post"  action="<?php echo $PHP_SELF ?>">
Contact Name<br>
<input type="Text" name="contact_name" size="25">
<br><br>
<input type="submit" name="submit" value="Search">
</form> 

<?php

if ($submit) {

$username="xxxx";
$password="xxxx";
$database="xxxx";

$contact_name=$_POST['contact_name'];

mysql_connect('localhost',$username,$password);
@mysql_select_db($database) or die( "Unable to select database");


$result = mysql_query("SELECT * FROM newsstuf_usedcars
WHERE contact_name='$contact_name'") or die(mysql_error());

$row = mysql_fetch_array( $result ); 


echo $row['uid']." - ".$row['contact_name']." - ".$row['car_make'];




}

mysql_close();
?>

</body>
</html>
the aim is for me to be able to search for a record using the form, and searching by "contact_name" and dispaly the record. I can get that bit. What I then want it to be able to have the result linking to an editdetails.php passing on the uid

i have tried to play around with things such as

Code: Select all

echo( "<a href='details.php?id='uid'>'contact_name', 'car_make'<br></a>" );
but i just cant figure it out!

thanks in advnace for the help - I know i really should go away and learn some more ir read the book! but times precious at the moment!

Posted: Wed Sep 07, 2005 6:41 am
by CoderGoblin
You probably have to use variables e.g

Code: Select all

echo( "<a href=\"details.php?id={$row['uid']}\">{$row['contact_name']}, {$row['car_make']}</a><br />" );
or

Code: Select all

echo( "<a href=\"details.php?id=".$row['uid']."\">".$row['contact_name'].",".$row['car_make']."</a><br />" );
Hope that helps

Posted: Wed Sep 07, 2005 7:39 am
by tom.cull
perfect - thanks