linking from list[SOLVED]
Posted: Fri Sep 09, 2005 8:24 am
Hi,
i have a page where I can list the contents of a db:
This works fine. But i want to make it so that each item of the list is linked to a edititem.php page, passing on the id.
I have tried with putting in the below but it didnt work:
could one of you great experts help me out - im learning, just not quick enough!
i have a page where I can list the contents of a db:
Code: Select all
<html>
<body>
<?php
// listing script
$username="xxxx_xxxx";
$password="xxxx";
$database="xxxx_xxxx";
$table="xxxx_xxxx";
// connect to the server
mysql_connect( 'localhost',$username,$password)
or die( "Error! Could not connect to database: " . mysql_error() );
// select the database
mysql_select_db( $database)
or die( "Error! Could not select the database: " . mysql_error() );
// retrieve all the rows from the database
$query = "SELECT * FROM $table ORDER BY `contact_nlast`, `contact_nfirst`";
$results = mysql_query( $query );
// print out the results
if( $results )
{
while( $contact = mysql_fetch_object( $results ) )
{
// print out the info
$id = $contact -> id;
$contact_nlast = $contact -> contact_nlast;
$contact_nfirst = $contact -> contact_nfirst;
echo( "$id, $contact_nlast, $contact_nfirst<br>" );
}
}
else
{
die( "Trouble getting contacts from database: " . mysql_error() );
}
?>
</body>
</html>I have tried with putting in the below but it didnt work:
Code: Select all
$row = mysql_fetch_array( $result );
echo( "<a href=\"editdetails.php?id=".$row['id']."\">".$row['id']." . ".$row['contact_nfirst']." ".$row['contact_nlast']." - ".$row['car_make']."</a><br />" );