Jump to content

Hyperlinks From Database ..


gabobby

Recommended Posts

Hi,

 

I am new to this site and relatively new to PHP, so I would be grateful of any help.

 

I have the following code:

 

$result = mysql_query("SELECT * FROM resource");
echo "<table border='1'>

<tr>
<th>ID</th>
<th>Name</th>
<th>Description</th>
<th>Click on this link</th>
</tr>";
while ($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['resource_id'] . "</td>";
echo "<td>" . $row['name_of_resource'] . "</td>";
echo "<td>" . $row['description'] . "</td>";
echo "<td>" . $row['resource_name_path'] . "</td>";
//echo "<td>".'<a href="../../8_resources/Mystical Creatures Database.mdb">'.$row['hyperlink_resource_name'].'</a>'."</td>";


echo "<td>".'<a href="'.$row['resource_name_path.'].'">'.$row['hyperlink_resource_name'].'</a>'."</td>";


echo "</tr>";
}
echo "</table>";
mysql_close($con);

 

It outputs resource information from a table. However, the a href hyperlink bit doesn't work - when I click on it, it doesn't throw up an error, just takes me to an index of files page and lists the file names on the site instead of opening the above database, called 'Mystical Creatures Database.mdb.

 

Is there something wrong with the code?

Edited by Zane
Link to comment
Share on other sites

Hi again ..

 

Forgot to add that the $row['resource_name_path.'] is inserting the path to the hyperlink and it is this section that I am having trouble with. The section that is // commented out actually works, but it is not pulling in the 'path' from the database.

 

Any ideas?

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.