Hello,
I am trying to add hyperlink to my mysql query result. I have a table called EastLondon which consist of the following:

(restaurant_id INT UNSIGNED PRIMARY KEY, restaurant_name VARCHAR(20), phone_number VARCHAR(20), picture varchar(8), website varchar(40));

I extract all these info into a table using php. What I want to do is add the actual hyperlink to 'website' results. I have the following code but it doesn't work:

foreach ( $restaurants as $row ) {
               echo '<table width="400" border="1" cellspacing="2" cellpadding="2">';
echo '<tr><th width="200">Restaurant Name  </th>';
echo '<td width="200">'.$row['restaurant_name'].'</td></tr>'; 
echo '<tr><th width="200">Telephone Number </th>';
echo '<td width="200">'.$row['phone_number'].'</td></tr>';
echo '<tr><th width="200"><img src="./image/'.$row["picture"].'" width="100" height="131" ></th>';
echo '<a href="'.$row['website'].'">'.$row['website'].'</a>';

echo '</table>';
            }

try this in your last lines of your code

echo '<tr><td><th width="200"><img src="./image/'.$row["picture"].'" width="100" height="131" ></th>';
echo '<a href="'.$row['website'].'">'.$row['website'].'</a></td></tr></table>';

and review your URL addresses in your data base, maybe they aren't right

I actually tried that code before and it still doesn't work. In order to make sure that the URL works, I used http://www.google.com in my database, but it says that the page can't be found when i click on the url. I've been searching for the answer to this for more than 3 days and I can't find it anywhere. I appreciate any kind of help. Thanks

In what way does it "not work". What are the values of the row (what is the exact value of $row['website']

In what way does it "not work". What are the values of the row (what is the exact value of $row['website']

I think that the browser looks for the URL in the server because it says that the page cannot be found. The exact value that is inserted into the database is:

'http://www.google.com'

I can retrieve the address but still I can't reach it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.