Forum Moderators: coopster
f'rinstance:
SELECT from db * WHERE var = ['$var_assigned_earlier'] AND date1 >=Today AND date2<= (today+7)
i know today +7 can be done before this using strtotime(), and i can just pass the variable striaght into it.
plus for this to work, im guessing it;d be easiest to store the dates put in as a timestamp.
After i have that info, id like to be able to count how many records ive gotten...
(i have a habit of... thinking aloud on forum posts :p)
Id appreciate any thoughts
$sql = "SELECT * FROM `db` WHERE `var`='".mysql_real_escape_string($var_assigned_earlier)."' AND `date1`>='".date("Y-m-d")."' AND `date2`<='".date("Y-m-d", strtotime("+7 days"))."';"
If your DATE fields are actually DATETIME fields, then use "Y-m-d H:i:s" for the date() function.
$sql1= "SELECT * FROM guest_data WHERE arr_date >= ".date('y-m-d')"";
In my database arr_date is a DATE field and is in the format y-m-d
::EDIT::
Now worries... for got a full-stop (period in america-talk)
(i hate when that happens)
[edited by: Esqulax at 4:22 pm (utc) on Feb. 18, 2008]
Now im confused as to why this part aint working....
I want it to:
Select records where the room number is = to the room number gotten from the previous sql query AND whos arr_date is today or later. (i think this bit works)
I then want it to display §§ in an new cell, when dep_date, is >= today, today+1, today +2...up to 7
CODE
while($row = mysql_fetch_array($rs))
{
echo("<tr>");
echo("<td align=\"center\"> " .$row["room_number"]);
echo("<td align=\"center\">" .$row["beds"]);$current_room= $row["room_number"];
$sql1= "SELECT * FROM guest_data WHERE room=$current_room AND arr_date >= ".date('y-m-d')."";
$rs2= mysql_query($sql1,$conn);while($row= mysql_fetch_array($rs2))
{
for($k=0;$k<8;$k++)
{
if ($row["dep_date"] >= date('y-m-d',strtotime('{+$k} days')))
{
echo(' <td> §§');
}
}}
}
if ($row["dep_date"] >= date('y-m-d',strtotime("+{$k} days"))) That SHOULD run if the dep_date is today or tomorrow, and up to $k days, if not, it should return nothing.. but i dont think its comparing the values... any ideas?
I put in
else echo(' <td> xx'); after the if staement... theoretically this put xx in cells if theres nothing there... doesnt do this either....
[edited by: Esqulax at 6:11 pm (utc) on Feb. 18, 2008]