I have a function that builds an array from a query:
Code: Select all
<?php
//******************************************//
//This is the search function for project//
//******************************************//
function search() { //start of the search function
//begin variables
//we will add some security checks sometime
$section = $_GET['section'];
$term = $_GET['term'];
$sendback = ''; //this variable is what we will use to return values
//end variables
switch($section) { //begin section switch
case "sex":
switch($term) { //begin sex switch
case "male":
$result = mysql_query("SELECT global_id FROM mini_info WHERE sex='male'") or die(mysql_error());
$num_rows = mysql_num_rows( $result ); //total rows
$row = mysql_fetch_array( $result );
$i = 0; //initialize count variable
while($i <= $num_rows) { //begin the loop to build array
$sendback[$i] = $row['global_id'];
$i++; //increment counter
} //end loop
break;
case "female":
break;
}
break;
} //end section switch
} //end search function
?>