Page 1 of 1

HELP ! Error passing multiple values to ajax using php

Posted: Sat Oct 24, 2009 7:03 am
by manoj_mohal
There is some error i don't know what but I want to communicate from 1 php file to other using ajax.
But there is a problem I wants to pass multiple values through ajax and wants to get result back.
I am posting the code here.The main file is Search.php which is communicating with SearchDetails through search.js . please try to understand and help me.

Search.php

Code: Select all

 
<?php
        include_once('../classes/Connection.php');
            
        $db='mis_paacce';
        $obj=new Connection;
        $con=$obj->connect();
        mysql_select_db($db,$con) or die(mysql_error());
        
        $query1="select name,city from frenchisie_details";
        $query2="select DISTINCT college from visa_status_details";
        $query3="select DISTINCT course from visa_status_details";
        $query4="select DISTINCT country from visa_status_details";
        
        $result1=mysql_query($query1);
        $result2=mysql_query($query2);
        $result3=mysql_query($query3);
        $result4=mysql_query($query4);
?>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>PAACCE Intranet</title>
<script type="text/JavaScript">
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
//-->
</script>
 
<style type="text/css">
<!--
 
a:link {color: #0000ff;}
a:visited {color: #0000FF;}
a:active {color: #FF0000;}
a:hover {background-color: #ffffff;}
a {text-decoration: none;}
-->
</style>
<LINK REL=StyleSheet HREF="../css/calendar.css" TYPE="text/css">
<SCRIPT type="text/javascript" SRC="../js/weeklycalendar.js">
        </SCRIPT>
        <script type="text/javascript">
                buildWeeklyCalendar(1);
 
        </script>
<script type="text/javascript" src="../js/search.js"></script>
 
 
        
</head>
 
<body>
<form action="" method="post">
<table width="583" height="140" border="0" cellpadding="0" cellspacing="0" align="center">
  <tr>
    <td colspan="4" align="center" bgcolor="#BBBBBB">Search Cases</td>
   
  </tr>
  <div id="setCases">
  <tr>
  <td>Frenchisie</td>
  <td><select name="frenchisie" id="frenchisie">  
  <option value="all" selected="selected">All</option>
  <?php
  while($row=mysql_fetch_row($result1))
  {
  ?>
  <option value="<?php echo $row[1]; ?>"><?php echo $row[0]." (".$row[1].")"; ?></option>
  <?php
  }
  ?>
  </select></td>
  <td width="73">College</td>
  <td width="146"><select name="college" id="college">  
  <option value="all" selected="selected">All</option>
  <?php
  while($rorw1=mysql_fetch_row($result2))
  {
  ?>
  <option value="<?php echo $row1[0];?>"><?php echo $row1[0]; ?></option>
  <?php
  }
  ?>
  </select></td>
  <td><div id="txtCollege"></div></td>
 
  </tr>
  <tr>
 
    <td>Country</td>
  <td><select name="country" id="country">  
  <option value="all" selected="selected">All</option>
  <?php 
  while($row4=mysql_fetch_row($result4))
  {
  ?>
  <option value="<?php echo $row4[0]?>"><?php echo $row4[0]; ?></option>
  <?php
  }
  ?>
  </select></td>
  
  <td>Courses</td>
  <td><select name="course" id="course">  
  <option value="all" selected="selected">All</option>
  <?php
  while($row2=mysql_fetch_row($result3))
  {
  ?>
 <option value="<?php echo $row2[0]; ?>"><?php echo $row2[0]; ?></option>
 <?php
 }
 ?>
  </select></td>
  </tr>
  </div>
  <tr>
  
    <td width="153">From</td>
    <td width="211"><input name="fromDate" type="text" id="fromDate" readonly="readonly" />
    <a href="#" onClick="w_displayDatePicker('fromDate');"><img src="../images/cal.gif" /></a>&nbsp;&nbsp;&nbsp;
    </td>
    <td></td><td></td>
    
  </tr>
  <tr>
 
    <td>To</td>
    <td><input name="toDate" type="text" id="toDate" readonly="readonly" />
    <a href="#" onClick="w_displayDatePicker('toDate');"><img src="../images/cal.gif" /></a></td>
    <td></td><td></td>
  </tr>
  <tr>
 
  <td></td>
  <td><input type="button" value="Find" name="find" onClick="searchStrings(document.getElementById('frenchisie').value,document.getElementById('college').value,document.getElementById('country').value,document.getElementById('course').value,document.getElementById('fromDate').value,document.getElementById('toDate').value);" /></td>
  <td></td><td></td>
  </tr>
</table>
 
</form>
<hr />
<div id="search"> 
<table width="297" height="180" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="239"><a href="#" onclick="MM_openBrWindow('totalEnquiries.php','Enquiries','scrollbars=yes,width=600,height=700')">Total Enquiries</a></td>
    <td width="268">&nbsp;</td>
  </tr>
 
  <tr>
    <td><a href="#" onclick="MM_openBrWindow('registeredEnquiries.php','registred','scrollbars=yes,width=600,height=700')">Registered Enquiries</a></td>
    <td>&nbsp;</td>
  </tr>
  
  <tr>
    <td><a href="#" onclick="MM_openBrWindow('docPending.php','Pending','scrollbars=yes,width=600,height=700')">Documents Pending</a></td>
    <td>&nbsp;</td>
  </tr>
  
  <tr>
    <td><a href="#" onclick="MM_openBrWindow('docRecieved.php','Recieved','scrollbars=yes,width=660,height=700')">Documents Recieved</a></td>
    <td>&nbsp;</td>
  </tr>
      
  <tr>
    <td><a href="#" onclick="MM_openBrWindow('offerLetter.php','letter','scrollbars=yes,width=660,height=700')">Offer Letter Recieved</a></td>
    <td>&nbsp;</td>
  </tr>   
   <!-- <tr><td><input name="offLetter" type="radio" value="rev" checked="checked" />
    Letter Recieved</td><td><input name="offLetter" type="radio" value="notRev" />
    Not Recieved</td></tr>-->
    
  <tr>
    <td><a href="#" onclick="MM_openBrWindow('visaApplied.php','VisaApplied','scrollbars=yes,width=675,height=700')">Visa Applied</a></td>
    <td>&nbsp;</td>
  </tr>
 
  <tr>
    <td><a href="#" onclick="MM_openBrWindow('visaGranted.php','VisaGranted','scrollbars=yes,width=675,height=700')">Visa Granted</a></td>
    <td>&nbsp;</td>
  </tr>
 
</table>
</div>
</body>
</html>
 
 
search.js
 
// JavaScript Document
 
var xmlhttp;
 
function searchStrings(frenchisie,college,country,course,fromDate,toDate)
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  }
var url="SearchDetails.php";
url=url+"?fren="+frenchisie+"&coll"+college+"&count"+country+"&cour"+course+"&from"+fromDate+"&to"+toDate;
url=url+"&sid="+Math.random();
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
 
function stateChanged()
{
if (xmlhttp.readyState==4)
{
document.getElementById("search").innerHTML=xmlhttp.responseText;
}
}
 
function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}
 
SearchDetails.php
 
<?php
        $query='';
        $frenchisie=$_REQUEST['fren'];
        $college=$_REQUEST['coll'];
        $country=$_REQUEST['count'];
        $course=$_REQUEST['cour'];
        $fDate=$_REQUEST['from'];
        $tDate=$_REQUEST['to'];
        $sDate='14-Oct-09';
        $curDate=date('d-M-y');
 
        include_once('../classes/Connection.php');
            
        $db='mis_paacce';
        $obj=new Connection;
        $con=$obj->connect();
        mysql_select_db($db,$con) or die(mysql_error());
        
        
        if($toDate=='' || $toDate==null && $fromDate=='' || $fromDate==null)
        {
            if($frenchisie=='all' && $college=='all' && $country=='all' && $course=='all')
            {
                $query="select DISTINCT vs.regNo,vs.frenchisiCode,vs.applicationDate,vs.country,vs.offLetterDate,pd.fName,pd.lName,pd.passport,pd.inquiryDate,pd.dob,fd.name,fd.state from visa_status_details vs,personal_details pd,frenchisie_details fd";
            }
            else
            {
                if($frenchisie=='all')
                {
                    $query=sprintf("select DISTINCT vs.regNo,vs.frenchisiCode,vs.applicationDate,vs.country,vs.offLetterDate,pd.fName,pd.lName,pd.passport,pd.inquiryDate,pd.dob,fd.name,fd.state from visa_status_details vs,personal_details pd,frenchisie_details fd where vs.regNo=pd.regNo and vs.college='%s' and vs.cousre='%s' and vs.country='%s'",mysql_real_escape_string($college),mysql_real_escape_string($course),mysql_real_escape_string($country));
                }
                else if($college=='all')
                {
                    $query=sprintf("select DISTINCT vs.regNo,vs.frenchisiCode,vs.applicationDate,vs.country,vs.offLetterDate,pd.fName,pd.lName,pd.passport,pd.inquiryDate,pd.dob,fd.name,fd.state from visa_status_details vs,personal_details pd,frenchisie_details fd where frenchisieCode='%s' and cousre='%s' and country='%s'",mysql_real_escape_string($frenchisie),mysql_real_escape_string($course),mysql_real_escape_string($country));
                }
                else if($country=='all')
                {
                    $query=sprintf("select DISTINCT vs.regNo,vs.frenchisiCode,vs.applicationDate,vs.country,vs.offLetterDate,pd.fName,pd.lName,pd.passport,pd.inquiryDate,pd.dob,fd.name,fd.state from visa_status_details vs,personal_details pd,frenchisie_details fd where college='%s' and cousre='%s' and frenchisieCode='%s'",mysql_real_escape_string($college),mysql_real_escape_string($course),mysql_real_escape_string($frechisie));
                }
                else if($course=='all')
                {
                    $query=sprintf("select DISTINCT vs.regNo,vs.frenchisiCode,vs.applicationDate,vs.country,vs.offLetterDate,pd.fName,pd.lName,pd.passport,pd.inquiryDate,pd.dob,fd.name,fd.state from visa_status_details vs,personal_details pd,frenchisie_details fd where college='%s' and frenchisieCode='%s' and country='%s'",mysql_real_escape_string($college),mysql_real_escape_string($frenchisie),mysql_real_escape_string($country));
                }
            }
        }
        else if($toDate=='' || $toDate==null)
        {
            if($frenchisie=='all' && $college=='all' && $country=='all' && $course=='all')
            {
                $query=sprintf("select DISTINCT vs.regNo,vs.frenchisiCode,vs.applicationDate,vs.country,vs.offLetterDate,pd.fName,pd.lName,pd.passport,pd.inquiryDate,pd.dob,fd.name,fd.state from visa_status_details vs,personal_details pd,frenchisie_details fd where pd.inquiryDate IN ('%s','%s')",mysql_real_escape_string($sDate),mysql_real_escape_string($curDate));
            }
            else
            {
                if($frenchisie=='all')
                {
                    $query=sprintf("select DISTINCT vs.regNo,vs.frenchisiCode,vs.applicationDate,vs.country,vs.offLetterDate,pd.fName,pd.lName,pd.passport,pd.inquiryDate,pd.dob,fd.name,fd.state from visa_status_details vs,personal_details pd,frenchisie_details fd where vs.regNo=pd.regNo and vs.college='%s' and vs.cousre='%s' and vs.country='%s' and pd.inquiryDate IN ('%s','%s')",mysql_real_escape_string($college),mysql_real_escape_string($course),mysql_real_escape_string($country),mysql_real_escape_string($sDate),mysql_real_escape_string($curDate));
                }
                else if($college=='all')
                {
                    $query=sprintf("select DISTINCT vs.regNo,vs.frenchisiCode,vs.applicationDate,vs.country,vs.offLetterDate,pd.fName,pd.lName,pd.passport,pd.inquiryDate,pd.dob,fd.name,fd.state from visa_status_details vs,personal_details pd,frenchisie_details fd where frenchisieCode='%s' and cousre='%s' and country='%s' and pd.inquiryDate IN ('%s','%s')",mysql_real_escape_string($frenchisie),mysql_real_escape_string($course),mysql_real_escape_string($country),mysql_real_escape_string($sDate),mysql_real_escape_string($curDate));
                }
                else if($country=='all')
                {
                    $query=sprintf("select DISTINCT vs.regNo,vs.frenchisiCode,vs.applicationDate,vs.country,vs.offLetterDate,pd.fName,pd.lName,pd.passport,pd.inquiryDate,pd.dob,fd.name,fd.state from visa_status_details vs,personal_details pd,frenchisie_details fd where college='%s' and cousre='%s' and frenchisieCode='%s' and pd.inquiryDate IN ('%s','%s')",mysql_real_escape_string($college),mysql_real_escape_string($course),mysql_real_escape_string($frenchisie),mysql_real_escape_string($sDate),mysql_real_escape_string($curDate));
                }
                else if($course=='all')
                {
                    $query=sprintf("select DISTINCT vs.regNo,vs.frenchisiCode,vs.applicationDate,vs.country,vs.offLetterDate,pd.fName,pd.lName,pd.passport,pd.inquiryDate,pd.dob,fd.name,fd.state from visa_status_details vs,personal_details pd,frenchisie_details fd where college='%s' and frenchisieCode='%s' and country='%s' and pd.inquiryDate IN ('%s','%s')",mysql_real_escape_string($college),mysql_real_escape_string($frenchisie),mysql_real_escape_string($country),mysql_real_escape_string($sDate),mysql_real_escape_string($curDate));
                }
            }
        }
        else if($fromDate=='' || $fromDate==null)
        {
            if($frenchisie=='all' && $college=='all' && $country=='all' && $course=='all')
            {
                $query=sprintf("select DISTINCT vs.regNo,vs.frenchisiCode,vs.applicationDate,vs.country,vs.offLetterDate,pd.fName,pd.lName,pd.passport,pd.inquiryDate,pd.dob,fd.name,fd.state from visa_status_details vs,personal_details pd,frenchisie_details fd where pd.inquiryDate IN ('%s','%s')",mysql_real_escape_string($fDate),mysql_real_escape_string($tDate));
            }
            else
            {
                if($frenchisie=='all')
                {
                    $query=sprintf("select DISTINCT vs.regNo,vs.frenchisiCode,vs.applicationDate,vs.country,vs.offLetterDate,pd.fName,pd.lName,pd.passport,pd.inquiryDate,pd.dob,fd.name,fd.state from visa_status_details vs,personal_details pd,frenchisie_details fd where vs.regNo=pd.regNo and vs.college='%s' and vs.cousre='%s' and vs.country='%s' and pd.inquiryDate IN ('%s','%s')",mysql_real_escape_string($college),mysql_real_escape_string($course),mysql_real_escape_string($country),mysql_real_escape_string($fDate),mysql_real_escape_string($tDate));
                }
                else if($college=='all')
                {
                    $query=sprintf("select DISTINCT vs.regNo,vs.frenchisiCode,vs.applicationDate,vs.country,vs.offLetterDate,pd.fName,pd.lName,pd.passport,pd.inquiryDate,pd.dob,fd.name,fd.state from visa_status_details vs,personal_details pd,frenchisie_details fd where frenchisieCode='%s' and cousre='%s' and country='%s' and pd.inquiryDate IN ('%s','%s')",mysql_real_escape_string($frenchisie),mysql_real_escape_string($course),mysql_real_escape_string($country),mysql_real_escape_string($fDate),mysql_real_escape_string($tDate));
                }
                else if($country=='all')
                {
                    $query=sprintf("select DISTINCT vs.regNo,vs.frenchisiCode,vs.applicationDate,vs.country,vs.offLetterDate,pd.fName,pd.lName,pd.passport,pd.inquiryDate,pd.dob,fd.name,fd.state from visa_status_details vs,personal_details pd,frenchisie_details fd where college='%s' and cousre='%s' and frenchisieCode='%s' and pd.inquiryDate IN ('%s','%s')",mysql_real_escape_string($college),mysql_real_escape_string($course),mysql_real_escape_string($frenchisie),mysql_real_escape_string($fDate),mysql_real_escape_string($tDate));
                }
                else if($course=='all')
                {
                    $query=sprintf("select DISTINCT vs.regNo,vs.frenchisiCode,vs.applicationDate,vs.country,vs.offLetterDate,pd.fName,pd.lName,pd.passport,pd.inquiryDate,pd.dob,fd.name,fd.state from visa_status_details vs,personal_details pd,frenchisie_details fd where college='%s' and frenchisieCode='%s' and country='%s' and pd.inquiryDate IN ('%s','%s')",mysql_real_escape_string($college),mysql_real_escape_string($frenchisie),mysql_real_escape_string($country),mysql_real_escape_string($fDate),mysql_real_escape_string($tDate));
                }
            }
        }
        
        else
        {
            if($frenchisie=='all' && $college=='all' && $country=='all' && $course=='all')
            {
                $query=sprintf("select DISTINCT vs.regNo,vs.frenchisiCode,vs.applicationDate,vs.country,vs.offLetterDate,pd.fName,pd.lName,pd.passport,pd.inquiryDate,pd.dob,fd.name,fd.state from visa_status_details vs,personal_details pd,frenchisie_details fd where pd.inquiryDate IN ('%s','%s')",mysql_real_escape_string($fDate),mysql_real_escape_string($tDate));
            }
            else
            {
                if($frenchisie=='all')
                {
                    $query=sprintf("select DISTINCT vs.regNo,vs.frenchisiCode,vs.applicationDate,vs.country,vs.offLetterDate,pd.fName,pd.lName,pd.passport,pd.inquiryDate,pd.dob,fd.name,fd.state from visa_status_details vs,personal_details pd,frenchisie_details fd where vs.regNo=pd.regNo and vs.college='%s' and vs.cousre='%s' and vs.country='%s' and pd.inquiryDate IN ('%s','%s')",mysql_real_escape_string($college),mysql_real_escape_string($course),mysql_real_escape_string($country),mysql_real_escape_string($fDate),mysql_real_escape_string($tDate));
                }
                else if($college=='all')
                {
                    $query=sprintf("select DISTINCT vs.regNo,vs.frenchisiCode,vs.applicationDate,vs.country,vs.offLetterDate,pd.fName,pd.lName,pd.passport,pd.inquiryDate,pd.dob,fd.name,fd.state from visa_status_details vs,personal_details pd,frenchisie_details fd where frenchisieCode='%s' and cousre='%s' and country='%s' and pd.inquiryDate IN ('%s','%s')",mysql_real_escape_string($frenchisie),mysql_real_escape_string($course),mysql_real_escape_string($country),mysql_real_escape_string($fDate),mysql_real_escape_string($tDate));
                }
                else if($country=='all')
                {
                    $query=sprintf("select DISTINCT vs.regNo,vs.frenchisiCode,vs.applicationDate,vs.country,vs.offLetterDate,pd.fName,pd.lName,pd.passport,pd.inquiryDate,pd.dob,fd.name,fd.state from visa_status_details vs,personal_details pd,frenchisie_details fd where college='%s' and cousre='%s' and frenchisieCode='%s' and pd.inquiryDate IN ('%s','%s')",mysql_real_escape_string($college),mysql_real_escape_string($course),mysql_real_escape_string($frenchisie),mysql_real_escape_string($fDate),mysql_real_escape_string($tDate));
                }
                else if($course=='all')
                {
                    $query=sprintf("select DISTINCT vs.regNo,vs.frenchisiCode,vs.applicationDate,vs.country,vs.offLetterDate,pd.fName,pd.lName,pd.passport,pd.inquiryDate,pd.dob,fd.name,fd.state from visa_status_details vs,personal_details pd,frenchisie_details fd where college='%s' and frenchisieCode='%s' and country='%s' and pd.inquiryDate IN ('%s','%s')",mysql_real_escape_string($college),mysql_real_escape_string($frenchisie),mysql_real_escape_string($country),mysql_real_escape_string($fDate),mysql_real_escape_string($tDate));
                }
            }
        }
        
        $result=mysql_query($query);
        
        
        echo "<table width='297' height='180' border='0' align='center' cellpadding='0' cellspacing='0'>
  <tr>
    <td width='239'><a href='#' onclick='MM_openBrWindow(totalEnquiries.php?result=$result,Enquiries,scrollbars=yes,width=600,height=700)'>Total Enquiries</a></td>
    <td width='268'>&nbsp;</td>
  </tr>
 
  <tr>
    <td><a href='#' onclick='MM_openBrWindow(registeredEnquiries.php?result=$result,registred,scrollbars=yes,width=600,height=700)'>Registered Enquiries</a></td>
    <td>&nbsp;</td>
  </tr>
  
  <tr>
    <td><a href='#' onclick='MM_openBrWindow(docPending.php?result=$result,Pending,scrollbars=yes,width=600,height=700)'>Documents Pending</a></td>
    <td>&nbsp;</td>
  </tr>
  
  <tr>
    <td><a href='#' onclick='MM_openBrWindow(docRecieved.php?result=$result,Recieved,scrollbars=yes,width=660,height=700)'>Documents Recieved</a></td>
    <td>&nbsp;</td>
  </tr>
      
  <tr>
    <td><a href='#' onclick='MM_openBrWindow(offerLetter.php?result=$result,letter,scrollbars=yes,width=660,height=700)'>Offer Letter Recieved</a></td>
    <td>&nbsp;</td>
  </tr>   
   <!-- <tr><td><input name='offLetter' type='radio' value='rev' checked='checked' />
    Letter Recieved</td><td><input name='offLetter' type='radio' value='notRev' />
    Not Recieved</td></tr>-->
    
  <tr>
    <td><a href='#' onclick='MM_openBrWindow(visaApplied.php?result=$result,VisaApplied,scrollbars=yes,width=675,height=700)'>Visa Applied</a></td>
    <td>&nbsp;</td>
  </tr>
 
  <tr>
    <td><a href='#' onclick='MM_openBrWindow(visaGranted.php?result=$result,VisaGranted,scrollbars=yes,width=675,height=700)'>Visa Granted</a></td>
    <td>&nbsp;</td>
  </tr>
 
</table>";
        
        
 
?>
 

Re: HELP ! Error passing multiple values to ajax using php

Posted: Sun Oct 25, 2009 8:24 am
by markusn00b
You expect us to trudge through that code and find an error you've not even alluded to? No way.

Give us a better description of the problem. What *does* happen? What *doesn't* happen? What *should* happen? What errors do you receive?

Help us help you.

Mark.

Re: HELP ! Error passing multiple values to ajax using php

Posted: Sun Oct 25, 2009 11:50 pm
by manoj_mohal
Sorry Mark! :oops:

Actually I am pretty new to these things and I want to use some search. I have used 4 dropdowns and two textbox for date.
what i want to do is select one of franchise from first dropdown country from second ,college from third and course from 4th. the select from date and to date. according to this selection i want to search that how many students have been registered with us matching with that criteria.

these are the links below to open new page and total no of students matching that criteria in front of these links .. when i click on them I need show student's details who are in this criteria.


Total Inquiries 40
Registered Inquiries 20
Documents Pending 15
Documents Received 05
Offer Letter Received 04
Visa Applied 04
Visa Granted 03

but I am getting some errors on browser which are of javascript because I am trying to use ajax in this for getting result matching above criteria.

tell me if u need more description.

or if like to help me remotly using TEAMVIEWER just add me on yahoo chat my id is manoj_mohal@yahoo.co.in.

regards,
manoj mohal