mesber Posted February 23, 2009 Share Posted February 23, 2009 i have a table called events that has 2 attributes:EventId, Event i need to retrieve this table in a way each row will b linked to a different page..please any help... Link to comment https://forums.phpfreaks.com/topic/146481-dynamic-table-with-hyperlink/ Share on other sites More sharing options...
RichardRotterdam Posted February 23, 2009 Share Posted February 23, 2009 Do you mean every event should have a detail page? It's not really clear what you mean with "linked" Link to comment https://forums.phpfreaks.com/topic/146481-dynamic-table-with-hyperlink/#findComment-768982 Share on other sites More sharing options...
keeps21 Posted February 23, 2009 Share Posted February 23, 2009 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. Link to comment https://forums.phpfreaks.com/topic/146481-dynamic-table-with-hyperlink/#findComment-769183 Share on other sites More sharing options...
mesber Posted February 24, 2009 Author Share Posted February 24, 2009 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... Link to comment https://forums.phpfreaks.com/topic/146481-dynamic-table-with-hyperlink/#findComment-769916 Share on other sites More sharing options...
keeps21 Posted February 24, 2009 Share Posted February 24, 2009 $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>"; Link to comment https://forums.phpfreaks.com/topic/146481-dynamic-table-with-hyperlink/#findComment-769931 Share on other sites More sharing options...
mesber Posted February 24, 2009 Author Share Posted February 24, 2009 thank you..it worked Link to comment https://forums.phpfreaks.com/topic/146481-dynamic-table-with-hyperlink/#findComment-769945 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.