New to PHP and MySQL, any help would be appreciated.

Using PHP, I'm pulling fields from my MySQL database into a table and I would like to link one of the fields (club_id) to another web page.

How would I do that?

Recommended Answers

All 8 Replies

by linking, I'm referring to when you click on the "club_id" you are sent to another page.

Is this what you want? <a href="http://www.google.com/"><?php echo "$club_id" ?></a> Maybe I will understand your question better if you elaborate on what you are trying to do.

Thank you, that is pretty much what I'm trying to do...but...this is what I have so far: (see result in the attached image)...

<?php
$result = mysql_query("SELECT * FROM venues ORDER BY club_id");
echo "<table border='1'>
<tr>
<th>ID</th><th>Club Name</th><th>Description</th><th>City</th><th>Alcohol</th>
<th>Food</th><th>Dining</th><th>Smoking</th><th>Dancing</th><th>All Ages</th>
</tr>"; while($row = mysql_fetch_array($result))
  {
  echo "<td>" . $row['club_id'] . "</td>";
  echo "<td>" . $row['club_name'] . "</td>";
  echo "<td>" . $row['club_description'] . "</td>";
  echo "<td>" . $row['club_city'] . "</td>";
  echo "<td>" . $row['alcohol'] . "</td>";
  echo "<td>" . $row['food'] . "</td>";
  echo "<td>" . $row['dining'] . "</td>";
  echo "<td>" . $row['smoking'] . "</td>";
  echo "<td>" . $row['dancing'] . "</td>";
  echo "<td>" . $row['all_ages'] . "</td>";
  echo "</tr>";
  }
echo "</table>";mysql_close($con);
?>

I would like to take each club's ID and have it linked to go to that club's page!

not OK yet...

I used fetch_array in a row, but that doesn't let me assign a URL link to each individual Club_ID????

I am assuming that you have the urls saved in the database. echo "<td><a href=\"$row[url]\"> $row['club_id'] </a></td>";

No I don't have the URLs stored in the database! I guess that is another investigation on how to do that!
Thank you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.