phpBeginner06 Posted December 3, 2006 Share Posted December 3, 2006 I have; what I am sure is a pretty common question, but I am going to ask any way. Because I have tried different variations of creating this code from other examples I have seen on the internet, but have not got any script I made to work yet.I want to be able to create a hyperlink like this: [nobbc]"<a href=somepage.php?id=3">Ford</a>[/nobbc] and have it link to database that I have created; then send information from the database back to another php page.[u]Here is some basic information concerning the way I have database set up:[/u]The database is named "vehicleList".The data table is named "details".There are 7 table columns; the names of each are as follows: "id", "year", "link", "make", "model", "series", "price".There are also 7 rows in the data table; at this time.I want to be about to click on a link and pull data out of a row and post it to a php web page. I also am not sure how to post the data to the php web page; I have been reading about $_Get['id'], but I tried to create a script with it; and it would not work. I would post the script I had, but I got frusturated at it and deleted it from existance.Any help with this would be great - Thanks Quote Link to comment Share on other sites More sharing options...
chiprivers Posted December 3, 2006 Share Posted December 3, 2006 So am I right thinking that you want a list of links that are vehilce manufacturers (ie Ford, Vauxhall, Skoda etc) and when click on one of these it will take you to a page where it will pull all records from details to provde a list of vehilces made by that manufacturer.Is that right? Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted December 3, 2006 Share Posted December 3, 2006 Please post any code that you've written that hasn't worked. We will then be able to help you.Ken Quote Link to comment Share on other sites More sharing options...
phpBeginner06 Posted December 3, 2006 Author Share Posted December 3, 2006 I want to be able to click a link; that will send any information in my database's data table row to another page (echo or print it). This way I do not have to go and create a new webpage for every vehicle. I can just add information to database and give link a id; then when end user clicks the link (ie <a href="somepage.php?id3">Ford</a>); data will be transfered from database to a php page, where it will be echoed or printed.I do not have the specific code I made; I borrowed it from another example online, but never could get it to work for me. I will see if I can find the example and post it back on here. Quote Link to comment Share on other sites More sharing options...
phpBeginner06 Posted December 3, 2006 Author Share Posted December 3, 2006 Here is an example of the PHP code (aka "somepage.php") I pieced together:[code]<?//connect to mysql//change user and password to your mySQL name and passwordmysql_connect("mysql","username","password"); //select databasemysql_select_db("vehicleList"); $id = $_GET['id'];$search = "SELECT * FROM details WHERE id = '$id'";$result = mysql_query($search);while ($row = mysql_fetch_array($result)) {echo $row["year make model series price"];}?>[/code]Then here would be the HTML hyperlink:[code]<a href="somepage.php?id=3">Ford</a>[/code]I have been placing the above link in a web page with a HTML extention. Is that OK or do I have to have a link like this in a web page with a PHP extention, in order for it to function? Quote Link to comment Share on other sites More sharing options...
phpBeginner06 Posted December 3, 2006 Author Share Posted December 3, 2006 Can anyone help me with this PHP script? Quote Link to comment Share on other sites More sharing options...
chiprivers Posted December 3, 2006 Share Posted December 3, 2006 just try this for me a minute, change[code]echo $row["year make model series price"];[/code]to[code]echo $row["year"];[/code] Quote Link to comment Share on other sites More sharing options...
phpBeginner06 Posted December 3, 2006 Author Share Posted December 3, 2006 Ok - I will try that right now - be right back Quote Link to comment Share on other sites More sharing options...
phpBeginner06 Posted December 3, 2006 Author Share Posted December 3, 2006 I got that to work; so why is the rest of the columns not displaying too?[color=red]ooooooooooooooooooooh - I figured it out - I have to echo each database data table column in a different echo.[/color][color=blue]That is awesome - Thank You So Much For Your Help !!![/color] 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.