Since I am now working from two different databases (1 local, 1 on my live server) I would like to modularize the the connection info. That way the db information is in its own file on each server and the pages with the queries link to the connection file to get the appropriate info..
dbconnect.php
PHP Code:
<?php
// db properties
$dbhost = 'localhost';
$dbname = 'test';
$dbuser = 'root';
$dbpass = 'password';
?>
I put in //notes to explain what I tried so far and the outcome.
PHP Code:
<?php
include("/includes/dbconnect.php"); // I have tried having the include here and it did not seem to work, through errors
print('<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>');
//Connect to the server and select database; you may need it
// I have also tried the $dbc line in the include instead, and replacing the line with the include, but that did not work either through a 500 page error. $dbc = mysqli_connect('localhost', 'dbuser', 'dbpass', 'dbname')
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><center>' . $row['date'] . '</center></td><td><center>' . $row['city'] . ', ' .$row['state'] . '</center></td><td><center>' . $row['description'] . '</center></td><td><center>' . $row['contact'] . '</center></td></tr>';}
mysqli_close($dbc);
print('</table>');
?>