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
https://forums.phpfreaks.com/topic/224319-imbedding-a-href-within-php/
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

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

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.