Page 1 of 1

function call

Posted: Wed Jan 19, 2005 5:05 pm
by twb
Hi
I have a bug in my php code I need help in. 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 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.
Here is the following code:

Code: Select all

function querry_textboxs($datevariable1,$datevariable2){
$query = "Select DISTINCT * From calander WHERE task_date>='$datevariable1' AND task_date <= '$datevariable2'"; 
echo "  ";
$result = mysql_query($query); 
if(!$result)&#123;
		echo "Error in search for results:".mysql_error();
		//exit();
		&#125;
	while ($row = mysql_fetch_array($result))&#123; 
		echo '<tr>'; 
		//Print Date
		echo '<td align="center" width="110">'.$row&#1111;'task_Date'].'</tr>';
		//Print Task Time
		echo '<td align="center" width="110">'.$row&#1111;'task_time'].'</tr>';
		//Print Task name
		echo '<td align="center" width="110">' .$row&#1111;'task_Name'].'</td>';
		//Print Description
		echo '<td align="left" width="200">' .$row&#1111;'task_Description'] .'</td>';
		&#125;
		if (!empty($result))&#123;
		$records_found = mysql_num_rows($result);&#125;
		return $records_found;
	&#125;
the php code is:

Code: Select all

<?php 
//querries textboxes
$records = querry_textboxs($val_from,$val_to);
// set to session &#125;
$_SESSION&#1111;'records_set'] = $records;  ?>
Thanks in advance
twb

Posted: Wed Jan 19, 2005 5:22 pm
by feyd
depending on your page layout, and how you are testing it, the problem may be with the session not being a cookie yet. Where's the "seperate display that will display the rows returned?"

function call

Posted: Wed Jan 19, 2005 7:29 pm
by twb
I have the seperate display in another html table at the top of the form.
The code being:

Code: Select all

<?php if(!isset($_SESSION&#1111;'records_set']))&#123;$_SESSION&#1111;'records_set '= ' '; &#125;
echo "Records returned are: &#123;$_SESSION&#1111;'records_set']&#125;" ;  ?>
When I press the submit button it will display the rows needed in the db that was queried, but not till I press it again will it display the number of rows.
Thanks
twb

Posted: Wed Jan 19, 2005 8:05 pm
by feyd
it would seem to me that the error is outside of the code so far posted.. (ignoring the parse error that your newest code would generate)

function call

Posted: Wed Jan 19, 2005 8:34 pm
by twb
Thanks feyd
Ill start looking elsewhere for the prob.
TWB