Return Car Make from MySQL database & have the make hyperlinked.

Reply

Join Date: Nov 2006
Posts: 30
Reputation: jameswoodhouse is an unknown quantity at this point 
Solved Threads: 0
jameswoodhouse jameswoodhouse is offline Offline
Light Poster

Return Car Make from MySQL database & have the make hyperlinked.

 
0
  #1
Apr 16th, 2009
Hi there what i'm trying to do is:

return a car manufacturer from a MySQL database and have the text returned a hyperlink to the car manufacturer website.

The below just returns the manufacturer without a hyperlink:

$row['manufacturer']

Would i make a row in the database called 'carmakeurl', store the URL in that, then somehow echo it out.

$row['<a href=&websiteurl">$title</a>']


????


Thanks
Last edited by jameswoodhouse; Apr 16th, 2009 at 7:20 pm.
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 1,516
Reputation: cwarn23 has a spectacular aura about cwarn23 has a spectacular aura about cwarn23 has a spectacular aura about 
Solved Threads: 136
cwarn23's Avatar
cwarn23 cwarn23 is offline Offline
Posting Virtuoso

Re: Return Car Make from MySQL database & have the make hyperlinked.

 
0
  #2
Apr 17th, 2009
If you are trying to retrieve 1 row of a mysql table via link then it is probably best to just have a unique number/hash column and link to the php page with that row id in it. Then when retrieving the row, you can just use SELECT * FROM `table` WHERE `id`='".mysql_real_escape_string($value)."' As for how to get the unique hash, just hash the date and time the the field was entered. Alternatively you could just make the id field the manufacturer field.
Try not to bump 10 year old threads as it can be really annoying.
http://syntax.cwarn23.net/
Smilies: ^_* +_+ v_v -_- *~*`
My favourite PC. - MacGyver Fan
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 257
Reputation: BzzBee is an unknown quantity at this point 
Solved Threads: 37
BzzBee BzzBee is offline Offline
Posting Whiz in Training

Re: Return Car Make from MySQL database & have the make hyperlinked.

 
0
  #3
Apr 17th, 2009
this is wrong syntax

  1. $row['<a href=&websiteurl">$title</a>']

it could be like

  1. <a href='&websiteurl'>$row[title]</a>
if you are fetching data from db and using it as a link
Last edited by BzzBee; Apr 17th, 2009 at 7:25 am.
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 30
Reputation: jameswoodhouse is an unknown quantity at this point 
Solved Threads: 0
jameswoodhouse jameswoodhouse is offline Offline
Light Poster

Re: Return Car Make from MySQL database & have the make hyperlinked.

 
0
  #4
Apr 17th, 2009
  1. <a href='&websiteurl'>$row[title]</a>

i think this is what i'm looking for, but what if i want to retrieve the websiteurl from a row in the table as well. would it be like..


  1. <a href='$row[websiteurl]l'>$row[title]</a>
?????



Thanks
Last edited by jameswoodhouse; Apr 17th, 2009 at 8:08 am. Reason: update
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 30
Reputation: jameswoodhouse is an unknown quantity at this point 
Solved Threads: 0
jameswoodhouse jameswoodhouse is offline Offline
Light Poster

Re: Return Car Make from MySQL database & have the make hyperlinked.

 
0
  #5
Apr 17th, 2009
Thanks BzzBee that works, but what if i want to retrieve the url from a row as well. rather than entering the URL in php.

<a href='$row[linkurlrow]'>$row[title]</a>

??

Thanks
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 1,382
Reputation: almostbob has a spectacular aura about almostbob has a spectacular aura about almostbob has a spectacular aura about 
Solved Threads: 167
almostbob's Avatar
almostbob almostbob is offline Offline
Nearly a Posting Virtuoso

Re: Return Car Make from MySQL database & have the make hyperlinked.

 
0
  #6
Apr 17th, 2009
Originally Posted by jameswoodhouse View Post
Thanks BzzBee that works, but what if i want to retrieve the url from a row as well. rather than entering the URL in php.

<a href='$row[linkurlrow]'>$row[title]</a>

??

Thanks
thats going to work, as long as you update the table to include a column of urls, called linkrulrow
Failure is not an option It's included free, you don't have to do anything to get it
If at first you dont succeed, join the club
Of course its always in the last place you look, you dont keep looking after you find it

Please mark solved problems, solved
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 30
Reputation: jameswoodhouse is an unknown quantity at this point 
Solved Threads: 0
jameswoodhouse jameswoodhouse is offline Offline
Light Poster

Re: Return Car Make from MySQL database & have the make hyperlinked.

 
0
  #7
Apr 17th, 2009
OMG!! this is driving me mad!!!!!!!!!!

  1. $sql = 'SELECT * FROM cartable';
  2. $finalurl = <a href='$row[carwebsiteurl]'>$row[carname]</a>;
  3. echo $finalurl;


I have 1 table with 2 rows in my SQL database. The rows are named:

carwebsiteurl - this contains a URL which is http://www.ford.co.uk

&

carname - this contains the text ford.


It still shows errors!!!!
Last edited by Ezzaral; Apr 17th, 2009 at 12:23 pm. Reason: Added [code] [/code] tags. Please use them to format any code that you post.
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 133
Reputation: vicky_rawat is an unknown quantity at this point 
Solved Threads: 17
vicky_rawat's Avatar
vicky_rawat vicky_rawat is offline Offline
Junior Poster

Re: Return Car Make from MySQL database & have the make hyperlinked.

 
0
  #8
Apr 18th, 2009
Hi,

You are missing double quotes

  1. $sql = 'SELECT * FROM cartable';
  2. $finalurl = <a href='$row["carwebsiteurl"]'>$row[carname]</a>;
  3. echo $finalurl;
Vivek Rawat
Keep solving complexities.
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 1,516
Reputation: cwarn23 has a spectacular aura about cwarn23 has a spectacular aura about cwarn23 has a spectacular aura about 
Solved Threads: 136
cwarn23's Avatar
cwarn23 cwarn23 is offline Offline
Posting Virtuoso

Re: Return Car Make from MySQL database & have the make hyperlinked.

 
0
  #9
Apr 18th, 2009
Originally Posted by vicky_rawat View Post
Hi,

You are missing double quotes

  1. $sql = 'SELECT * FROM cartable';
  2. $finalurl = <a href='$row["carwebsiteurl"]'>$row[carname]</a>;
  3. echo $finalurl;
You are also missing the quotes around the html code. Try the following:
  1. $sql = 'SELECT * FROM cartable';
  2. $finalurl = '<a href=\''.$row['carwebsiteurl'].'\'>'.$row['carname'].'</a>';
  3. echo $finalurl;
Try not to bump 10 year old threads as it can be really annoying.
http://syntax.cwarn23.net/
Smilies: ^_* +_+ v_v -_- *~*`
My favourite PC. - MacGyver Fan
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 30
Reputation: jameswoodhouse is an unknown quantity at this point 
Solved Threads: 0
jameswoodhouse jameswoodhouse is offline Offline
Light Poster

Re: Return Car Make from MySQL database & have the make hyperlinked.

 
0
  #10
Apr 18th, 2009
  1. $sql = 'SELECT * FROM cartable';$finalurl = '<a href=\''.$row['carwebsiteurl'].'\'>'.$row['carname'].'</a>';echo $finalurl;


Now it just shows a blank page, no errors though!!!!
Last edited by peter_budo; Apr 19th, 2009 at 5:11 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the PHP Forum
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC