Page 1 of 1
[SOLVED] Working with multiple resultsets simultatiouly
Posted: Tue Jan 11, 2005 8:38 am
by Hagar
I'm trying to retreive multiple result and using them. I have tried to pass the results to and array but PHP doesn't like it to much.
Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, array given in C:\PHP\includes\.... on line 21
Posted: Tue Jan 11, 2005 9:07 am
by feyd
post some code please. Specifically, the creation of the mysqli link or object, your query, and the code used for calling mysqli_fetch_array().
please help!
Posted: Wed Jan 12, 2005 1:13 am
by Hagar
Code: Select all
<?php
class result{
var $db;
var $connect;
var $result;
function result(&$connect){
include("globals/Sianda_glb_conn.php");
$this->connect = $connect;
$this->db = $dbName;
}
function pages ($whereValue = "%",$page_requested,&$result,&$fieldName){
$debug = 0;
include("class/Select/scripts.php");
$sql = new scripts();
$debug = 0;
switch($page_requested){
case "MemProd":
$this->result=mysqli_query($this->connect,$sql->Mem_List_script($whereValue)) or die("Invalid Query".mysql_error());
$resultї0] = $this->result;
$this->result=mysqli_query($this->connect,$sql->Mem_Address_script($whereValue)) or die("Invalid Query".mysql_error());
$resultї1] = $this->result;
$nRows=mysqli_num_rows($this->result);
$numFileds = mysqli_num_fields($this->result);
$fieldInfo = mysqli_fetch_fields($this->result);
for($i=1; $i<$numFileds; $i++){
$fieldNameї$i] = $fieldInfoї$i]->name;
}
if ($debug != 0){
echo "result numbers: ".count($result)."<br>";
echo "Connection: {$this->connect}";
echo "<br> Numbers of Fields: {$numFileds}<br>";
echo "Number of Rows: {$nRows}<br>";
}
if ($debug != 0){
echo "MemProd";
echo "{$sql->Mem_List_script($whereValue)}<br>";
}
break;
if(count($result) == 1){
$nRows=mysqli_num_rows($this->result);
$numFileds = mysqli_num_fields($this->result);
$fieldInfo = mysqli_fetch_fields($this->result);
for($i=1; $i<$numFileds; $i++){
$fieldNameї$i] = $fieldInfoї$i]->name;
}
if ($debug != 0){
echo "Connection: {$this->connect}";
echo "<br>Numbers of Fileds: {$numFileds}<br>";
echo "Number of Rows: {$nRows}<br>";
}
}
}
}
?>
getting the recordset from a switch
Code: Select all
<?php
function vertical_display($result_num = 0,$page){
include_once("class/html/html.php");
include_once("class/select/results.php");
$sql_class = new result($connect,$page);
$html = new html();
$whereValue ='%';
$sql_class->pages($whereValue,$page,$resultї$result_num],$fieldName);
for($a=0; $a < count($resultї$result_num]);$a++){
$html->open_table("100%");
$html->open_table_row();
echo $resultї$result_num];
while($row=mysqli_fetch_array($resultї$result_num])){
for ($i=1; $i <= count($fieldName);$i++){
$html->open_table_row();
$html->open_table_data($fieldNameї$i],"","1","tblhead");
$html->close_table_data();
$html->open_table_data($rowї$i],"","1","tbldata");
$html->close_table_data();
$html->close_table_row();
}
$html->open_table_row();
$html->open_table_data("b","0%","");
$html->close_table_data();
$html->close_table_row();
#echo "FieldName: {$fieldNameї$i]}";
}
$html->close_table_row();
$html->close_table();
}
}
?>
The "class/select/results.php" path is where the class is. assume the the class has been instatiated and all the nice things.
All this works well if you are using one recordset only.

Posted: Wed Jan 12, 2005 1:34 am
by feyd
check to see what "count($result[$result_num])" returns.. I'd guess 1, no matter what.
problem solved
Posted: Thu Jan 13, 2005 3:15 am
by Hagar
I fixed it a the place where I call the diferent results Thank you in any case.