<?php include "/path/to/dblogin/details.php"; $db = new mysqli('localhost', $username, $password, $database); if($db->connect_errno > 0){ die('Unable to connect to database [' . $db->connect_error . ']'); } $sql = <<<SQL SELECT * FROM `database_16` WHERE `col_11` = 'Include' ORDER BY submission_id DESC LIMIT 10 SQL; if(!$result = $db->query($sql)){ die('There was an error running the query [' . $db->error . ']'); } while($row = mysqli_fetch_array($result)) { echo "<a href=\"/news-template/full.php?id=". $row['submission_id'] . "\">" . $row['col_5'] . "</a><br /><br />"; } $db->close();
This question has been answered by BobRay. See the first response.
while($row = mysqli_fetch_array($result)) { $output = "<a href=\"/news-template/full.php?id=". $row['submission_id'] . "\">" . $row['col_5'] . "</a><br /><br />"; } $db->close(); return $output;
Just return $output in the snippet. The value returned will replace the snippet tag on the page.
while($row = mysqli_fetch_array($result)) { $output = "<a href="\"/news-template/full.php?id="." $row['submission_id']="" .="" "\"="">" . $row['col_5'] . "</a> "; } $db->close(); return $output;