How do i put this chunk of code into a php variable?
- by Theron Chong
if (isset($_SESSION['name'])){
//select BID and duedates which are between the range of 1-3 days
// before due date from current date
$query = "SELECT DueDate FROM item WHERE DueDate BETWEEN '$warning2' and '$warning' and user='$_SESSION[name]' ORDER BY DueDate DESC";
$find = mysql_query($query);
$alert = mysql_num_rows($find);
if ($alert>=1){
echo "You have got " .$alert. " item(s) due on: </br >";
while ($item = mysql_fetch_array($find)){
echo $item['DueDate'];
echo "<br />";
}
}
echo "Success!";
}
Question: How do i input all this code into a single php variable, say $alert. I am not clear of where to put single quotes or double quotes to make it work. At the end of the day, I will be using the variable for a javascript alert box.