One of my websites I have built a database the contains support group information. It does work in its rudamentary form but I would like to improve things to better sort by date. The way the database is currently setup I am manually entering the date (i.e. 01/31/13), but I haven't figured out a way to sequentially display only the information based on the current month so that information added to the database for events next year don't affect the list. Before the new year, what I had added to the database showed up like:
01/31/13
08/12/12
Code:
<table cellpadding="5" cellspacing="0" width="100%" align="center" border="1"><tr><th bgcolor="#c2c2c2" text-align="center">Date</th><th bgcolor="#c2c2c2" text-align="center">Location</th><th bgcolor="#c2c2c2" text-align="center">Description</th><th bgcolor="#c2c2c2" text-align="center">Contact Info</th></tr>
<?php
//Connect to the server and select database; you may need it
$dbc = mysqli_connect('localhost', 'db_user, 'db_password, 'db_databasename')
or die("Could not connect to the database.");
$query = "SELECT * FROM `sgroups` ORDER BY `date` ASC, `city` ASC LIMIT 0, 30 ";
$data = mysqli_query($dbc, $query);
while ($row = mysqli_fetch_array($data)) {
//Show results table
echo '<tr><td>' . $row['date'] . '</td><td>' . $row['city'] . ',' .$row['state'] . '</td><td>' . $row['description'] . '</td><td>' . $row['contact'] . '</td></tr>';}
mysqli_close($dbc);
?>
</table>
Also how would I setup the die function to display the "could not connect" message in the table versus ontop of it (ie.
Code:
<table>
<tr><td>' . $row['date'] . '</td><td>' . $row['city'] . ',' .$row['state'] . '</td><td>' . $row['description'] . '</td><td>' . $row['contact'] . '</td></tr>
<tr><td colspan="4">Could not connect to the datase</td></tr>
</table>
versus it spitting out the error message just above the table, then cutting off the rest of the page like:
Code:
Fatal error: Call to undefined function mysqli_connect() in C:\Program Files (x86)\Apache Group\Apache2\htdocs\hydrocephalustalk\index.php on line 65
<br/>
<tr><td>Date</td><td>City, State</td><td>Descrition</td><td>Conact Information</td></tr>
Thanks