I'm basing my logic off of the assumption that a SELECT query will return a value of Zero, that is '0' for use in this array:
$check_day_id = "select day_id from days_table";
$check_day_id_res = mysql_query($check_day_id) or die(mysql_error());
// LOGIC= IF RESULTS <= 0 THEN DAY IS MONDAY ETC
$weekarray = array('Monday' => 0,'Tuesday' => 1,'Wednesday' => 2,'Thursday' => 3,'Friday' => 4,'Saturday' => 5,'Sunday' => 6);
foreach ($weekarray as $key => $val) {
if ($check_day_id_res == $val) {
$day_of_week = $key;
break;
}
}
day_id value in my db table is:
INT not null primary key auto_increment
if i have rows in the days_table, the above array will work, allowing me to use $day_of_week, as in:
echo "<h1>Add an entry for".$day_of_week.":</h1>";
which will print: Add an entry for Thursday if there are three rows in the table at time of query
but, if i clear all rows from the table, my $day_of_week variable keeps "defaulting" to THursday!
i don't get it. why does it show thursday instead of Monday? what is this Array actually getting returned from the MySQL SELECT query above which would make it show THursday when there are no rows in my table?