Hi,
I’ve got a problem. I have a form which asks the user to login if successful it will go to my filteringview.php. In this page the filterOnload is included. My filterOnload contains a 2 listbox. The first listbox displays No Record if there’s no record found in the database. The 2nd listbox displays the records found in the database for a certain month.
[code=php]
function VwRc_onchange() {
var tempVwRcValue = document.ViewForm.VwRc.value;
document.ViewForm.passActId.value = extract_val(tempVwRcValue,1);
document.ViewForm.passActDate.value = extract_val(tempVwRcValue,2);
document.ViewForm.passPIN.value = extract_val(tempVwRcValue,3);
document.ViewForm.passPrjCode.value = extract_val(tempVwRcValue,4);
}
function extract_val(str,item)
{
var src,strval,xstr;
xstr = str+”,xxx,”;
for(a=1;a<=item;a++)
{
iPos = xstr.search(“,”);
strval = xstr.substr(0,iPos);
xstr = xstr.substr(iPos+1);
}
return strval;
}
<?//connect to database code here
$QueryString=”SELECT * FROM StatusTable INNER JOIN StaffTable ON StatusTable.PIN = StaffTable.PIN WHERE StaffTable.PinProfile = ‘”.$_SESSION[‘username’].”‘ and StatusTable.ActDate >= ‘”.$DateFirst.”‘ and StatusTable.ActDate <= ‘”.$DateEnd.”‘ ORDER BY StatusTable.ActDate DESC”;
$rs=mysql_query($QueryString);
$rsTable=mysql_num_rows($rs);
if (($rsTable==0))
{
?>
<p><select class=select size=”10″ name=”VwRc” style=”width: 780; height: 50; FONT-FAMILY: Lucida Console, Courier New; FONT-SIZE: x-small;” LANGUAGE=javascript onchange=”return VwRc_onchange()”>
<option value = “No Record”>No Record(s) Found</option>
</select>
<p><font size=4 color=navy><? print “Filtered Records from: “;?><? print $DateFirst;?><? print ” to “;?><? print $DateEnd;?></font></p>
<? }
else
{
function AppendSpace($sString,$iMaxChar)
{
extract($GLOBALS);
$sSpace=””;
for ($i=1; $i<=($iMaxChar-strlen($sString)); $i=$i+1)
{
$sSpace=$sSpace.” ”;
}
$AppendSpace=$sString.$sSpace;
return $function_ret;
} ?>
<p><select class=select size=”120″ name=”VwRc” style=”width: 780; height: 250; FONT-FAMILY: Lucida Console, Courier New; FONT-SIZE: x-small;” LANGUAGE=javascript onchange=”return VwRc_onchange()”>
<? while(!($rsTable==0))
{ $rsTable=mysql_fetch_array($rs);
<option value=”<? echo $rsTable[‘ActId’]; ?>,<? echo $rsFilter[“ActDate”]; ?>,=”<? echo $rsTable[‘PrjCode’]; ?> “>
<? echo AppendSpace($rsFilter[“ActId”],14); ?> <? echo AppendSpace($rsFilter[“ActDate”],18); ?>?> <? echo AppendSpace($rsFilter[“PrjCode”],18); ?>
</option>
}
?>
</select>
<p><font size=4 color=navy><? print “Filtered Records from: “;?><? print $DateFirst;?><? print ” to “;?><? print $DateEnd;?></font></p>
<? } ?>
If there’s no record it displays the 1st listbox or No Record in a listbox but I tried to put data in my database but it did not display the data. I really am having problem here. Hope someone could help me with my code. ?