Jump to content

Imbedding a href within php


rick88

Recommended Posts

Hey there. Firstly may I apologise if this is the wrong forum for this question. I wasn't overly sure. I'm currently developing an aplication within php which allows a user to upload a file which is saved to a directory and information on the file which is saved to a databse (including the file name). This information is then displayed in a table along with the directory location concatinated with the file name to provide a file location. My only issue is that being new to PHP I am unsure how to change this address to a workable link using a href. Any help in adapting the below script would be much apreciated. Thanks, Rick.

 

echo "<table border='1'><tr>";

for($fieldIterator = 1; $fieldIterator < $numFields; $fieldIterator++)

{  echo "<th>".mysql_field_name($result, $fieldIterator)."</th>";

}

echo "</tr>";

 

while($row = mysql_fetch_array($result))

  {    echo "<tr>";

  echo "<td>" . $row[1] . "</td>";

  echo "<td>" . $row[2] . "</td>";

  echo "<td>" . $row['Price'] . "</td>";

  echo "<td>" . $row['Genre'] . "</td>";

  echo "<td>" . $row['Category'] . "</td>";

  echo "<td>$ref= C:\wamp\www/.$row[imageAddress] </td>";

 

 

  echo "</tr>";

  }

echo "</table>";

Link to comment
Share on other sites

To be able to display a link to the file in question, all you need to do is this:

echo '<a href:"' . $row[imageAddress] . '"> Link to File</a>';

 

Depending on what is stored in $row[imageAddress] will depend what directory information you need to place before it, so like this:

 

echo '<a href:"C:\wamp\www\files\' . $row[imageAddress] . '"> Link to File</a>';

 

Hopefully that can get you on the right track

 

Denno

Link to comment
Share on other sites

This area in your code is assigning and echoing back a file system location.

 

  echo "<td>$ref= C:\wamp\www/.$row[imageAddress] </td>";

 

This needs to be transformed into a web URL for a browser to understand where to locate something via and HTTP request.  eg.

 

$image_address = $row['ImageAddress'];
$image_name = $row['ImageName']; // assuming you have this
echo "<td><a href=\"$image_address\">$image_name</a></td>";

 

Let me know if I'm missing something

 

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.