slack Posted March 10, 2006 Share Posted March 10, 2006 [!--sizeo:2--][span style=\"font-size:10pt;line-height:100%\"][!--/sizeo--][!--fonto:Arial--][span style=\"font-family:Arial\"][!--/fonto--]Hello all,I have a page which can list all records from a table in my local database.For each record that is displayed there is link next to it. When the link is pressed another page opens up and the ID (automated primary key in my table) of the record selected is passed to the URL.So now the URL looks something like this:[a href=\"http://localhost/Webpages/newpage.php?recordID=3\" target=\"_blank\"]http://localhost/Webpages/newpage.php?recordID=3[/a]How do I display the details of the record that has been selected on this new page?Any help much appreciated!ThanksSlack[!--fontc--][/span][!--/fontc--][!--sizec--][/span][!--/sizec--] Quote Link to comment Share on other sites More sharing options...
AV1611 Posted March 10, 2006 Share Posted March 10, 2006 [a href=\"http://localhost/Webpages/newpage.php?recordID=3\" target=\"_blank\"]http://localhost/Webpages/newpage.php?recordID=3[/a]$RID=$_GET['recordID'];then do this query:select * from table where recordID = '$RID'Sorry, if you need a better answer let me know, I just got called to a meeting... Quote Link to comment Share on other sites More sharing options...
slack Posted March 10, 2006 Author Share Posted March 10, 2006 Thanks for the quick reply.It sounds easy from what you have stated but I still can't seem to get it to work.I think it may be something to do with my select statement. Here is a sample of the code.[code]$RID = $_GET['recordID'];$query = "SELECT * FROM dvd WHERE id = '$RID'";$result = mysql_query($query);print ("$result[title]");[/code]Just to let you know that the table is called 'dvd' and 'id' and 'title' are column names in my table.I am just trying to display the 'title' of the selected record.ThanksSlack Quote Link to comment Share on other sites More sharing options...
slack Posted March 10, 2006 Author Share Posted March 10, 2006 No need for a reply as I have worked out the problem.To solve I did something like this:[code]$RID = $_GET['recordID'];$query = "SELECT * FROM `dvd` WHERE `id`='$RID'";$result = mysql_query($query);$row = mysql_fetch_array($result);echo $row[title];[/code]This will now display the selected title Quote Link to comment Share on other sites More sharing options...
tjmaxwell Posted March 21, 2006 Share Posted March 21, 2006 Hello.Sorry to resurrect an old topic, but this is the same kind of thing I'm trying to do. I've searched this forum and have found a couple of code samples, but I can't get them to work. Here's what I have so far:[code]<html><body><?php// listing script// connect to the servermysql_connect( 'localhost', 'user', 'pass' )or die( "Error - Could not connect to database: " . mysql_error() );// select the databasemysql_select_db( 'dbname')or die( "Error! Could not select the database: " . mysql_error() );$RID = $_GET['ID'];$query = "SELECT * FROM `model_numbers` WHERE `ID`='$RID'";$result = mysql_query($query);$row = mysql_fetch_array($result);echo $row[title];?><table border="1" cellpadding="3" cellspacing="3"><tr><th align="left">Manufacturer</th><td align="left"><?php echo($Manufacturer) ?></td></tr><tr><th align="left">Warranty</th><td align="left"><?php echo($Warranty) ?></td></tr><tr><th align="left">Weight</th><td align="left"><?php echo($Weight) ?></td></tr></table></body></html>[/code]I have a product database that contains about 40 fields, and about 15 columns per product. I was trying this code without success. I'm very new to PHP and was wondering if when you select all records, you need to display them all at once? In other words, are my scripts not working because I'm only displaying three of the columns? Any help to get this working would be much appreciated. I want to create one PHP page that is dynamically populated based on the ID field. I want users to be able to go to www.domain.com/products.php?id=(number). Thanks a lot! Quote Link to comment Share on other sites More sharing options...
tjmaxwell Posted March 22, 2006 Share Posted March 22, 2006 Anybody? Quote Link to comment Share on other sites More sharing options...
abe_sapien1 Posted March 22, 2006 Share Posted March 22, 2006 Hi there,It appears you arent defining those values correctly. try this [code]$row = mysql_fetch_array($result);echo $row['title']; <-- notice the quotes?><?php # I am assuming below your column titles are 'Manufacturer' and 'Warranty' etc ... ?><table border="1" cellpadding="3" cellspacing="3"><tr><th align="left">Manufacturer</th><td align="left"><?php echo($row['Manufacturer']) ?></td></tr><tr><th align="left">Warranty</th><td align="left"><?php echo($row['Warranty']) ?></td></tr><tr><th align="left">Weight</th><td align="left"><?php echo($row['Weight']) ?></td></tr></table>[/code]best of luck to ya hope that helped Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.