I would like to query the database and select certain users like this.
Code: Select all
$getUsers = mysql_query("SELECT
id,
firstname,
lastname,
location,
level FROM users where level = 'User' AND location = '$location'")or die(mysql_error());
if(mysql_affected_rows() == 0){
//
exit();
};
while ($usersRecieved = mysql_fetch_array($getUsers))
{
extract($usersRecieved);
//
}
Before this second query I have declared a variable called
Code: Select all
$name = $firstname . ' ' . $lastname;Code: Select all
$checkCalendarDay = mysql_query("SELECT
id,
name,
company_name,
appointment_time,
appointment_day,
appointment_month,
appointment_year,
city_town,
location,
postcode_1,
postcode_2 FROM currentappointments WHERE name = '$name' AND appointment_day = '$calday' AND appointment_month = '$calmonth' AND appointment_year = '$calyear' AND location = '$location' ORDER BY name")or die(mysql_error());
if(mysql_affected_rows() == 0){
echo 'There is no apointments listed for '. $_SESSION['user']['location'] . ' ' . $_GET['calday'] . ' ' . $_GET['calmonth'] . ' ' . $_GET['calyear'] . '<br /><br /><a href="add_appointment_set.php?d='.$calday.'&m='.$calmonth.'&y='.$calyear.'">Click here to add a new appointment</a>';
exit();
};
echo '<center><h3>' . $calday . '/' . $calmonth . '/' . $calyear . '</h3></center>';
while ($calendarChecked = mysql_fetch_array($checkCalendarDay))
{
extract($calendarChecked);
echo '
<table width="99%" border="0" cellpadding="3" cellspacing="3" onClick="document.location.href=\'add_appointment.php?rep='.$name.'\';" onMouseOver="this.bgColor=\'#F3F8FC\';" onMouseOut="this.bgColor=\'#FFFFFF\';" class="grey-body">
<tr>
<td>'.$appointment_time.' - '.$city_town.' - '.$location.' - '.$postcode_1.' - '.$company_name.'</td>
</tr>
</table>';
}
I have tried with foreach loop but could not get it right.
Thanks in advance.