Hi everyone
I have a bug in my php code I need help in if someone has time. I have two text boxes that takes in 2 dates. A function then querries the db and returns the rows needed. With this I have a seperate display that will display the actualrows returned and onethat displays the # of rows returned. All this works other than the display of number of rows returned. It will only return this after the 2nd time I press the submit button. I would like it to display on the first submit.
The function is:
<?php
querry_textboxs($datevariable1,$datevariable2){
$query = "Select DISTINCT * From calander WHERE task_date >='$datevariable1' AND task_date <= '$datevariable2'";
echo " ";
$result = mysql_query($query);
if(!$result){
echo "Error in search for results:".mysql_error();
//exit();
}
while ($row = mysql_fetch_array($result)){
echo '<tr>';
//Print Date
echo '<td align="center" width="110">'.$row['task_Date'].'</tr>';
//Print Task Time
echo '<td align="center" width="110">'.$row['task_time'].'</tr>';
//Print Task name
echo '<td align="center" width="110">' .$row['task_Name'].'</td>';
//Print Description
echo '<td align="left" width="200">' .$row['task_Description'] .'</td>';
}
if (!empty($result)){
$records_found = mysql_num_rows($result);}
return $records_found;
}?>
The function call is: Works fine
//querries textboxes and prints out data
<?php
$records = querry_textboxs($val_from,$val_to);
// set to session
$_SESSION['records_set'] = $records; ?>
//the display of rows returned is: // works only after submit is pressed 2nd time
<?PHP
if(!isset($_SESSION['records_set'])){$_SESSION['re
cords_set'] = ' '; }
echo "Records returned are: {$_SESSION['records_set']}"; ?>