Jump to content

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


AdRock

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