943,754 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 1426
  • PHP RSS
You are currently viewing page 1 of this multi-page discussion thread
Apr 16th, 2009
0

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

Expand Post »
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.
Reputation Points: 10
Solved Threads: 0
Light Poster
jameswoodhouse is offline Offline
30 posts
since Nov 2006
Apr 17th, 2009
0

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

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.
Sponsor
Featured Poster
Reputation Points: 410
Solved Threads: 258
Occupation: Genius
cwarn23 is offline Offline
3,004 posts
since Sep 2007
Apr 17th, 2009
0

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

this is wrong syntax

PHP Syntax (Toggle Plain Text)
  1. $row['<a href=&websiteurl">$title</a>']

it could be like

PHP Syntax (Toggle Plain Text)
  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.
Reputation Points: 16
Solved Threads: 48
Posting Whiz
BzzBee is offline Offline
327 posts
since Apr 2009
Apr 17th, 2009
0

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

PHP Syntax (Toggle Plain Text)
  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..


PHP Syntax (Toggle Plain Text)
  1. <a href='$row[websiteurl]l'>$row[title]</a>
?????



Thanks
Last edited by jameswoodhouse; Apr 17th, 2009 at 8:08 am. Reason: update
Reputation Points: 10
Solved Threads: 0
Light Poster
jameswoodhouse is offline Offline
30 posts
since Nov 2006
Apr 17th, 2009
0

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

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
Reputation Points: 10
Solved Threads: 0
Light Poster
jameswoodhouse is offline Offline
30 posts
since Nov 2006
Apr 17th, 2009
0

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

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
Reputation Points: 562
Solved Threads: 368
Posting Maven
almostbob is offline Offline
2,970 posts
since Jan 2009
Apr 17th, 2009
0

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

OMG!! this is driving me mad!!!!!!!!!!

PHP Syntax (Toggle Plain Text)
  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.
Reputation Points: 10
Solved Threads: 0
Light Poster
jameswoodhouse is offline Offline
30 posts
since Nov 2006
Apr 18th, 2009
0

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

Hi,

You are missing double quotes

PHP Syntax (Toggle Plain Text)
  1. $sql = 'SELECT * FROM cartable';
  2. $finalurl = <a href='$row["carwebsiteurl"]'>$row[carname]</a>;
  3. echo $finalurl;
Reputation Points: 28
Solved Threads: 19
Junior Poster
vicky_rawat is offline Offline
137 posts
since Jun 2008
Apr 18th, 2009
0

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

Hi,

You are missing double quotes

PHP Syntax (Toggle Plain Text)
  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:
php Syntax (Toggle Plain Text)
  1. $sql = 'SELECT * FROM cartable';
  2. $finalurl = '<a href=\''.$row['carwebsiteurl'].'\'>'.$row['carname'].'</a>';
  3. echo $finalurl;
Sponsor
Featured Poster
Reputation Points: 410
Solved Threads: 258
Occupation: Genius
cwarn23 is offline Offline
3,004 posts
since Sep 2007
Apr 18th, 2009
0

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

php Syntax (Toggle Plain Text)
  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.
Reputation Points: 10
Solved Threads: 0
Light Poster
jameswoodhouse is offline Offline
30 posts
since Nov 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Supplied argument is not a valid MySQL result resource
Next Thread in PHP Forum Timeline: Validation of age?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC