Reputation: 5
I use this while
loop to display events from facebook. I want to add an href
link in each record that will open a new tab displaying only this event. I have created links for each record but I can't understand how I can make the link to lead to that event.
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "<table class='table table-hover table-responsive table-bordered'>";
echo "<tr>";
echo "<td rowspan='6' style='width:20em;'>";
echo "<img src=". $row["COVER_PHOTO"]." width='200px' />";
echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<td style='width:15em;'>What:</td>";
echo "<td><b>". $row["NAME"]."</b></td>";
echo "</tr>";
//owner
echo "<tr>";
echo "<td>Who:</td>";
echo "<td>". $row["OWNER"]."</td>";
echo "</tr>";
echo "<tr>";
echo "<td>What kind:</td>";
echo "<td>". $row["PAGE_CAT"]."</td>";
echo "</tr>";
echo "<tr>";
echo "<td>When:</td>";
echo "<td>". $row["START_DATE"]." at ". $row["START_TIME"]."</td>";
echo "</tr>";
echo "<tr>";
echo "<td>Where:</td>";
echo "<td>". $row["PLACE"]."</td>";
echo "</tr>";
echo "<tr>";
echo "<td>";
echo "<a href='view.php?more=". $row["EVENT_ID"]."' target='_blank' <?php echo >Λεπτομέρειες</a>";
echo "<tr>";
echo "<td>Description:</td>";
echo "<td>". $row["DESCRIPTION"]."</td>";
echo "</tr>";
Upvotes: 0
Views: 88
Reputation: 661
Your code for this page is just fine. Now to display each individual event in the view.php
file, you will need to access the data (in your case the event ID, stored in more
variable) sent via GET
method in the view.php
page, as thus:
view.php
<?php
if(isset($_GET['more']))
{
$more = $_GET['more'];
}
?>
The value of the more
variable sent via the URL will now be saved in the $more
PHP variable. For example, if the page called is view.php?view=22
, the $more
variable will have the value of 22
.
You can now use this $more
variable - which stores the event ID - to fetch whatever other detail you require.
Upvotes: 1
Reputation: 6521
echo "<a href='view.php?more=". $row["EVENT_ID"]."' target='_blank'> Λεπτομέρειες</a>";
Upvotes: 0