MySQL PHP
From KOP KB
This is really just one example but its one way you can display data. This one just happens to be one where it took a post from a form for like a zip code and then checked related zip codes in a a database.
Simple Connect and Display troubleshoot
<?
//connection information
$host = 'hostname';
$user = 'username';
$pass = 'pass';
$db = 'dbname';
$conn = mysql_connect($host, $user, $pass);
//connection needs db name below
mysql_select_db("dbname", $conn);
//This is just if your using information from a search form
$search = $_POST["tZip"];
// after the from is whatever table you are attempting to pull data from
$connstring = "SELECT * FROM tablename WHERE columnname LIKE '$search' " ;
$result = mysql_query($connstring);
?>
<?
echo "<h1>Stores Near You:</h1>";
// Checks to make sure it actually brings a result, so to whether show them or to say out of luck or similar issue
if(mysql_num_rows($result) == 0) {
echo "Sorry there appears to be no stores in your immediate area.";
}
else{
while($nt=mysql_fetch_array($result)){
// this was done due to some kind of formatting with the page after the fact so this may change depending on what your doing
echo "<br />";
echo "<br />";
// for each $nt has a correlated column name to display
// something else to display the content
// this displays the content how you want it depending on the theme of what their doing will depend on what you do here for html
echo "<h4>$nt[cnam1]</h4>$nt[cnam2]<br />$nt[cnam3]<br />$nt[cnam4], $nt[cnam5]<br />$nt[cnam6]";
}
echo "<br />";
echo "<br />";
}
echo mysql_error();
mysql_close();
?>
Selecting the current week based off Monday
It really depends what you are doing but this is where you could modify this to get current week, previous week and so on.
select * from mmdata where week(FROM_UNIXTIME(`timestamp`), 1) like (week(CURDATE(), 1)-1) ORDER BY timestamp DESC