Jump to content


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


displaying hyperlinks in table stored in database [RESOLVED] and fast

Recommended Posts

I am trying to display sponsors hyperlinks that is stored in MySQL in a table column.

I can display them if I'm just echoing the database but if i try and put anchor tags around the hyperlink it displays nothing

This code will work
[code]$q = mysql_query("SELECT * FROM `sponsors` ORDER BY name ASC LIMIT $set_limit, $limit");
  if(!$q) die(mysql_error());
     $err = mysql_num_rows($q);
       if($err == 0) die("No matches met your criteria.");
$numofrows = mysql_num_rows($q);

//Results per page: **EDIT LINK PATH** 

//show data matching query:
echo "<table border=\"0\">\n";
echo "<tr bgcolor=\"lightblue\"><th width=\"200\">Name</th><th width=\"140\">Location</th><th width=\"300\">URL</th></tr>\n";
for($i = 0; $i < $numofrows; $i++) {
    $row = mysql_fetch_array($q); //get a row from our result set
    if($i % 2) { //this means if there is a remainder
        echo "<tr bgcolor=\"yellow\">\n";
    } else { //if there isn't a remainder we will do the else
        echo "<tr bgcolor=\"white\">\n";
    echo "<td>".$row['name']."</td><td>".$row['location']."</td><td>".$row['url']."</td>\n";
    echo "</tr>\n";
//now let's close the table and be done with it
echo "</table>\n";[/code]
Unless i change this
[code]echo "<td>".$row['name']."</td><td>".$row['location']."</td><td>".$row['url']."</td>\n";[/code]
to this
[code]echo "<td>".$row['name']."</td><td>".$row['location']."</td><td><a href='".$row['url']."'</a></td>\n";[/code]
I know there is something dodgey about the anchor link but i can't put my finger on it

Share this post

Link to post
Share on other sites

echo "<td>".$row['name']."</td><td>".$row['location']."</td><td><a href='".$row['url']."'>".$row['name']."</a></td>\n";

Share this post

Link to post
Share on other sites


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.