Jump to content

adding fields to mysql


foozago

Recommended Posts

okay easy enough...but i would like one of those fields to be a hyperlink...when i work in the mysql browser control to add my data it won't let me add a hyperlink as a variable....

 

any idea as to how to do that...

 

i have name

city

street.

and a whole much others

one of them i would like it to see see reviews - i want the words see reviews to be clickable to go to a new page....so how do i add a hyperlink into that field?

Link to comment
Share on other sites

You still need to make it a Link with HTML, right now it's just this

 

<table width="1073" border="0">
    <tr>
      <td>andover</td>
      <td>sparta</td>
      <td>nj</td>
      <td>french</td>
      <td>www.foozago.com/andover</td>
    </tr>
  </table>

Link to comment
Share on other sites

The same way you'd echo any other link, or any other text for that matter, in PHP:

  $url = 'http://www.yahoo.com/';
  echo '<a href="' . $url . '">Click here!</a>';

 

The only difference is you don't have a variable named $url.  You're pulling the URL from the database so it'll be something like:

$sql = "SELECT ...";
$q = mysql_query($sql) or die('Error: ' . mysql_error());
while($row = mysql_fetch_assoc($q)){
  echo '<a href="' . $row['url'] . '">Click here!</a>';
}

Link to comment
Share on other sites

this is what i have and it says i have an error in syntax....

 

SELECT *

FROM restaurants

WHERE name LIKE %colname%

ORDER BY name ASC

 

$q = mysql_query($sql) or die('Error: ' . mysql_error());

while($row = mysql_fetch_assoc($q)){

  echo '<a href="' . $row['url'] . '">Click here!</a>';

}

 

the part that starts with $q is the part that i just put it and made it stop working....the top part that starts with select works...it goes to the database and gets the information....

 

am i typing it wrong?

 

 

 

Link to comment
Share on other sites

okay kind of makes sense....would i put that in the bindings panel......

 

i am using dreamweaver cs3 and using the simple...so i gues i would have to go to advanced and type it exactly as you have posted it???

I have no idea what you're talking about.

 

I have a feeling you may be attempting to run when you haven't even learned how to walk yet.

 

Are you working out of a book or an online tutorial?

 

As for your error, try changing:

SELECT *
FROM restaurants
WHERE name LIKE %colname%
ORDER BY name ASC

to

$sql = "SELECT *
FROM restaurants
WHERE name LIKE '%colname%'
ORDER BY name ASC";

 

Also the '%colname%' is likely meant to be a search string, something like:

'%Friday%'

Link to comment
Share on other sites

whats the filename that this code is in

 

SELECT *
FROM restaurants
WHERE name LIKE %colname%
ORDER BY name ASC

 

(im thinking its using a file to store the query only. thats the only way php would work with this syntax)

 

what EXACTLY does the error say?

 

if you can give us the entire script (or if its really big 100 lines around the error line should do)

Link to comment
Share on other sites

$q = mysql_query($sql) or die('Error: ' . mysql_error());

while($row = mysql_fetch_assoc($q)){

  echo '<a href="' . $row['url'] . '">Click here![/url]';

}

 

 

i had the select part and that worked.  once i add the above...it stops working..

 

question all my fields are just named.....name, street, city....and so forth

 

should they be named $name, $street and so forth?  every tutorial i see online has that dollar sign all over the place...but when i try to add it it just gives me errors all over the place. 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.