[code=php]
<?php
$db_name = “markbad_markbadsql”;
$table_name = “event”;
$connection = mysql_connect (“localhost”, “markbad_drpl1”, “n4x4q37IhCez”)
or die (‘I cannot connect to the database because: ‘ . mysql_error());
$db = mysql_select_db ($db_name, $connection)
or die (mysql_error());
//sort by date.. only monday thru friday
$sql = “SELECT *, curdate() AS c, dayofweek(curdate()) AS d FROM $table_name WHERE date BETWEEN date_sub(c INTERVAL (d -1) DAYS) AND date_add(c INTERVAL (7-c) DAYS)”;
$result = mysql_query($sql,$connection)
or die (mysql_error());
//While loop will create an array called $row
while ($row = mysql_fetch_array($result)) {
// get individual elements from events
$date = stripslashes($row[‘date’]);
$bar = stripslashes($row[‘bar’]);
$updated = stripslashes($row[‘updated’]);
$details = stripslashes($row[‘details’]);
$map_url = stripslashes($row[‘map_url’]);
$display_block .= ”
t<h4>$bar <span class=”date”> $updated</span></h4>
t<p>
tt&details<br />
tt<span class=”date”>$map_url</span>
t</p>”;
}
?>
//bunch of html
<? echo “$display_block”; ?>
I get a funky error from mysql
[CODE]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘INTERVAL (d -1) DAYS) AND date_add(c INTERVAL (7-c) DAYS)’ at line 1
Please Help. What I want to do with the query is display all of the events within listed from “ONLY” the past seven days. not any before that
Also am I using stripslashes right?
Thanks!