Jump to content

using variable within a hyperlink


billabong0202

Recommended Posts

First is this possible. I want to use a variable that i pulled from an array within my hyperlink. \

 

Ex. I pulled the foodtype variable from my database using:

 

$qry= "SELECT DISTINCT (restaurant_info.food_type) as foodtype

FROM restaurant_info

INNER JOIN restaurants

ON restaurants.rest_id= restaurant_info.rest_id

WHERE restaurants.delivery = 'yes'

ORDER BY food_type ASC";

 

Then i wanted to use that data to echo hyperlink created by that variable (foodtype)

 

$result = mysql_query($qry); //result of the query

 

if (!$result) {die(mysql_error()); //if result is empty then show error and stop process

}else{

echo '<ul>'; //start unordered list for links

while($row = mysql_fetch_array($result)) {

 

// CREATE link using $row['foodype'].html

this is where i am confused

echo '<p><li><a href=" ' $row[foodtype] ' . '.html' " >' . $row['foodtype'] . '</a></p>';

}

echo '</ul>';

}

 

And second, what is the syntax for doing something like that, i have tried to search for it but have been unsuccessful.

 

 

 

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.