So I have to call 25 articles from a mysql database and have the article title open a modal window containing the relevant article body. Is there a way to add a link in foreach that would dynamically reference the appropriate article?
for instance, when I click the title "Fish Sticks Taste Horrible" I should get the article talking about the awful tasting fish sticks in side the modal window.
I'm just starting with php and javascript so this is all really over my head. Any help would be very appreciated. this is what I have so far:
$results = $conn->query('SELECT title, byline, body, timestamp FROM PublishedDocs ORDER BY timestamp DESC LIMIT 25;');
<div class="list">
<?php
foreach ($results as $key) {
echo '<a href="#" class="lightbox"><b>';print_r($key[title]); echo '</b></a>';
echo '<p>';print_r($key[byline]); echo '</p>';
echo '<p>';print_r($key[timestamp]); echo '</p>';
echo '<p>';print_r($key[body]); echo '</p><br>';
}
?>
</div>
<div class="backdrop"></div>
<div class="box"><div class="close">x close</div><b><?php print_r($key[title]);?></b><?php print_r($key[body]);?></div>