Forum Moderators: coopster
im relativly new to php and i have a problem. I have built a searchable database and a page to search it. This all works. At the moment it returns simplified results and i have a link "more info" below each result, i have managed to create a link that will pass the Primary key of the database to a new page in this case called "Ref" e.g.
/mysql/details.php?Ref=115
but i dont have a clue how to display the full results on a new page i have tried alot of ways none seem to work. All i need to do is display the corrosponding row! its so frustrating! any help would be wicked!
cheers phil
[edited by: philhazard at 2:31 pm (utc) on Sep. 5, 2005]
1. fetch the "Ref" from _GET.
$ref = intval( $_GET['Ref'] );
2. execute a database query and retrieve the data however u are doing it, something like
$record = $db->fetch_records( "SELECT * FROM your_table WHERE RefField=$ref" );
3. output
if(! empty( $record ) )
{
echo "$record[Field1] $record[Field2]";
}
else
{
echo "No record was found!";
}
Fatal error: Call to a member function on a non-object
refering to this line:
$record = $db->fetch_records( "SELECT * FROM icepro WHERE RefField=$ref" );
i know its not that complicated but having real problems finding useful info on it!
does anybody know of a good tutorial to do with this, I dont understand it fully and want to!
sorry about the link, changed it now.
cheers,
RefField is the name of the column with the unique variable that you have passed from the previous page.
So if you want to link shoes your db may look like this
hat ¦ shirt ¦ socks ¦ shoes
those are your columns
a row like this
baseball ¦ knitted ¦ ankle ¦ reebok
so your variable would look like this
/mysql/details.php?type=reebok
then on the new page have a query like so
$record = $db->fetch_records( "SELECT * FROM your_table WHERE shoes=$type" );
make sure you connect to the db with the query and you should be set.
hope it helps.
Dylan
cheers phil
if($_GET['Ref'])
{
$query = 'select * from icepro where Ref='.$_GET['Ref'];
$result = mysql_query($query);
$num_results = mysql_num_rows($result);
$row = mysql_fetch_array($result);
echo '<div id="ContentCopy2">';
echo '<br>';
echo '<span class="headerbold16"> '.stripslashes($row['HotelName']).'</span> ';
echo '<br>';
echo '<br>';
echo '<strong> '.stripslashes($row['HotelGroup']).' ';
echo '<br>';
echo 'Town/City:</strong> '.stripslashes($row['TownCity']).' ';
echo '<br>';
echo '<strong>County:</strong> '.stripslashes($row['CountyState']).' ';
echo '<br>';
echo '<strong>Description:</strong> '.stripslashes($row['GeneralDescription']).' ';
echo '<br>';
echo '<strong>Tel:</strong> '.stripslashes($row['Tel']).' ';
echo '<br>';
echo '<strong>Fax:</strong> '.stripslashes($row['Fax']).' ';
echo '<br>';
echo '<a href="mailto:'.stripslashes($row['Email']).'">email</a> ';
echo '<br>';
echo '<strong>Website:</strong> '.stripslashes($row['Website']).' ';
echo '<br>';
echo '<strong>CarPark:</strong> '.stripslashes($row['CarPark']).' ';
echo '<br>';
echo '<strong>Contact:</strong> '.stripslashes($row['Contact']).' ';
echo '<br>';
echo '<strong>Check In:</strong> '.stripslashes($row['CheckIn']).' ';
echo '<br>';
echo '<strong>Check out:</strong> '.stripslashes($row['Checkout']).' ';
echo '<br>';
echo '<strong>Number of rooms:</strong> '.stripslashes($row['Numberofrooms']).' ';
echo '<br>';
echo '<strong>EnSuite:</strong> '.stripslashes($row['EnSuite']).' ';
echo '<br>';
echo '<strong>Single Sex Bookings:</strong> '.stripslashes($row['SingleSexBookings']).' ';
echo '<br>';
echo '<strong>Menu:</strong> '.stripslashes($row['Menu']).' ';
echo '<br>';
echo '<strong>Disabled:</strong> '.stripslashes($row['DisabledFacilities']).' ';
echo '<br>';
echo '<strong>BabySitting/listening:</strong> '.stripslashes($row['BabySitting/listening']).' ';
echo '<br>';
echo '<strong>Leisure Facilities:</strong> '.stripslashes($row['LeisureFacilities']).' ';
echo '<br>';
echo '<strong>Golf Facilities:</strong> '.stripslashes($row['GolfFacilities']).' ';
echo '<br>';
echo '<strong>Child Free Age:</strong> '.stripslashes($row['ChildFreeAge']).' ';
echo '<br>';
echo '<strong>Offer:</strong> '.stripslashes($row['Offer']).' ';