mangolinux Posted September 11, 2015 Share Posted September 11, 2015 I am trying to get my query results to display each result separtlly on its own line. Here is my code: <?phpinclude("dbinfo.inc.php");$query = "SELECT * FROM boc";$result = mysqli_query($con, $query);/* fetch associative array */while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)){ //Assign variables $post_id = $row['post_id']; $date = $row['date']; $type = $row['type']; $title = $row['title']; $content = $row['content']; }?> <?phpecho "$date - <a href=\"viewnotice.php?id={$post_id}\"'>{$title}</a>";/* free result set */ mysqli_free_result($result);mysqli_close($con);?> This currently displays the results like this 09-04-2015 - Rescheduling Board of Commissioners Meeting 09-04-2015 - September Committee Meetings I would like it to display like this 09-04-2015 - Rescheduling Board of Commissioners Meeting 09-04-2015 - September Committee Meetings Thanks Link to comment https://forums.phpfreaks.com/topic/298126-displaying-mysqli_fetch_array-on-multiple-lines/ Share on other sites More sharing options...
QuickOldCar Posted September 11, 2015 Share Posted September 11, 2015 Do within the while loop. <?php include("dbinfo.inc.php"); $query = "SELECT * FROM boc"; $result = mysqli_query($con, $query); /* fetch associative array */ while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { //Assign variables $post_id = $row['post_id']; $date = $row['date']; $type = $row['type']; $title = $row['title']; $content = $row['content']; echo "$date - <a href='viewnotice.php?id=".$post_id."'>".$title."</a><br />"; } /* free result set */ mysqli_free_result($result); mysqli_close($con); ?> Link to comment https://forums.phpfreaks.com/topic/298126-displaying-mysqli_fetch_array-on-multiple-lines/#findComment-1520646 Share on other sites More sharing options...
mangolinux Posted September 11, 2015 Author Share Posted September 11, 2015 Thanks for the quick reply, Link to comment https://forums.phpfreaks.com/topic/298126-displaying-mysqli_fetch_array-on-multiple-lines/#findComment-1520672 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.