PHP Classes

AJAX List Box: Retrieve MySQL query results into arrays

Recommend this page to a friend!
  Info   View files Example   View files View files (5)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 628 This week: 1All time: 5,040 This week: 560Up
Version License PHP version Categories
ajax-list-box 1.0Freeware3.0Databases
Description 

Author

This is a simple class that can be used to retrieve MySQL query results into arrays.

It can execute a given MySQL SELECT query and retrieves the results into an array.

Picture of Pravin Sonawane
  Performance   Level  
Name: Pravin Sonawane <contact>
Classes: 4 packages by
Country: India India
Age: 44
All time rank: 50828 in India India
Week rank: 411 Up26 in India India Up

Example

<?php
   
include("functions.php");
   
$db = new PHP_fun();
?>
<!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>Untitled Document</title>
<script language="javascript" type="text/javascript" src="validation.js"></script>
<script language="javascript" type="text/javascript">
    function getCities(id)
    {
        var obj = document.form1;
        if (id != "")
        {
            url = "getCities.php?stateid="+id;
            http.open("GET", url, true);
            http.onreadystatechange = getCitiesResponse;
            http.send(null);
        }
    }
   
    function getCitiesResponse()
    {
        //alert(http.readyState);
        var obj = document.form1;
        if (http.readyState == 4)
        {
            var result = trimString(http.responseText);
            if (result != '' && result != 'undefined')
            {
                clearBox(obj.city);
                obj.city.options[0] = new Option("-City-", "");
                var result_line_arr = result.split("###");
                for (i=0;i<result_line_arr.length;i++)
                {
                    var result_arr = result_line_arr[i].split(":");
                    var code = result_arr[0];
                    var name = result_arr[1];
                    obj.city.options[i+1] = new Option(name, code);
                }
            }
        }
    }
</script>
</head>
<body>
<table width="60%" border="0" cellspacing="0" cellpadding="5">
<form action="" method="post" name="form1">
  <tr>
      <td align="right" class="verdana11">State :</td>
      <td align="left" class="verdana11">
          <select name="state" id="state" onchange="javascript: getCities(this.value);">
            <option value="">-State-</option>
            <?php
                $sql
= "select * from state";
               
$rs = $db->select_row($sql);
                for(
$i=0;$i<count($rs);$i++)
                {
?>
<option value="<?=$rs[$i]['state_id']?>"><?=$rs[$i]['state_name']?></option>
                <?php }
           
?>
</select>
    </td>
  </tr>
    <tr>
      <td align="right" class="verdana11">City : </td>
      <td align="left" class="verdana11">
          <select name="city" id="city" style="width:150px;">
                <option value="">-City-</option>
          </select>
      </td>
    </tr>
</form>
</table>
</body>
</html>


  Files folder image Files  
File Role Description
Accessible without login Plain text file db.sql Data MySql Database File
Plain text file functions.php Class Class
Accessible without login Plain text file getCities.php Example Database Request File
Accessible without login Plain text file index.php Example Main File
Accessible without login Plain text file validation.js Data Javascript File

 Version Control Unique User Downloads Download Rankings  
 0%
Total:628
This week:1
All time:5,040
This week:560Up
User Comments (1)
very amazing script
12 years ago (arunachalam)
70%StarStarStarStar