Jump to content

Dynamic table with hyperlink


mesber

Recommended Posts

To link to an event details page for each event you would do this.

 

$query = "SELECT EventId, Event FROM events";
$result = mysql_query($query) or die("Error: mysql_error()");

echo "<table>";
echo "<tr>";

while ( $row = mysql_fetch_array($result) ) {
    echo "<td>{$row['EventId']}</td>";
    echo "<td><a href=\"eventdetails.php?id={$row['EventId']}\">{$row['Event']}</a></td>";
}

echo "</tr>";
echo "</table>";

 

The event details page would then have to take the id from the url and retrieve the data for it from the database.

i meant every row retrieved will be a link to another page..for example:

if i have 2 rows in the table, and i retrieved all the data in the table, the first row has a detailed page let says d1.php, the second row has a detailed page( d2.php) and so on...

 

$query = "SELECT EventId, Event FROM events";
$result = mysql_query($query) or die("Error: mysql_error()");

echo "<table>";
echo "<tr>";

while ( $row = mysql_fetch_array($result) ) {
    echo "<td>{$row['EventId']}</td>";
    echo "<td><a href=\"d{$row['EventId]}.php\">{$row['Event']}</a></td>";
}

echo "</tr>";
echo "</table>";

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.