billabong0202 Posted February 20, 2008 Share Posted February 20, 2008 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 https://forums.phpfreaks.com/topic/92170-using-variable-within-a-hyperlink/ Share on other sites More sharing options...
revraz Posted February 20, 2008 Share Posted February 20, 2008 echo "<p><li><a href='{$row[foodtype]}.html'>{$row['foodtype']}</a></p>"; Link to comment https://forums.phpfreaks.com/topic/92170-using-variable-within-a-hyperlink/#findComment-472109 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.