How do i put this chunk of code into a php variable?
Posted
by
Theron Chong
on Stack Overflow
See other posts from Stack Overflow
or by Theron Chong
Published on 2012-10-12T15:25:02Z
Indexed on
2012/10/12
15:37 UTC
Read the original article
Hit count: 271
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.
© Stack Overflow or respective owner