Regarding retrieving multiple rows from database through PHP code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi All,
  We have implemented the below code.Actually we are getting 5 results for the below code.But we able to get only 4 values,we are missing the first row out of 5 results.We cant able to predict why we are getting this result.

  Please once go through this code and help us.
<?php
function write_query($sql)
{
 echo "<xmp>";
 echo $sql.';';
 echo "</xmp>";
}
function trim_param($str)
{
 if(trim($str) == '') {
  return 0;
 } elseif(trim($str) == 'N') {
  return 0;
 } else {
  return $str;
 }
}
function GetRating($url)
{
 $res_new1=array();
 $Query1="";
 for ($i=0;$i<count($url);$i++)
 {
 $str=0;
 $mysqli = mysqli_connect("localhost", "root", "123", "db");
 $urls=$url["$i"];
 
 $res = $mysqli->query("call rating('$urls',@abc);");
 if(mysqli_num_rows($res)>0)
 {
 $row = mysqli_fetch_row($res);
 $str=$row[0];
 }
 if($str>0)
 {
 $res_new1[]=$str;
 }
 else
 {
 $res_new1[]="NONE";
 }
 
 $mysqli->close( );
 
 }
 return $res_new1;
}
function Clix_Rated_site($str_searchString,$mysqli)
{
  $str_searchString =  trim($str_searchString);
 $topic = array();
 $topic_one=array();
 $topic_two=array();
 $Query1 = "";
 
 $temp_str_searchString ="";
 if(substr($str_searchString,strlen($str_searchString)-1) == 's') {
  $temp_str_searchString = substr($str_searchString,0,strlen($str_searchString)-1);
  $var="+".mysql_escape_string($temp_str_searchString)."*";
  $Query1="call Clix_Rated_site('$var')";
   } 
   else
   {
  $temp_str_searchString = $str_searchString;
  $var=mysql_escape_string($temp_str_searchString);
  $Query1="call Clix_Rated_site('$var')";
   }
   $mysqli = mysqli_connect("localhost", "root", "123", "db");
   $result = $mysqli->query("$Query1");
   if(mysqli_num_rows($result)==0) 
   {
    $var="+".mysql_escape_string($str_searchString)."*";
    $mysqli->close();
   $mysqli = mysqli_connect("localhost", "root", "123", "db");
    $Query1="call Clix_Rated_site('$var')";
    $result = $mysqli->query("$Query1");
   }
   if(mysqli_fetch_row($result)>0)
   {
    $rows=mysqli_num_rows($result);   
  for($i=0;$i<$rows;$i++) 
  {
   $res_row= mysqli_fetch_row($result); 
   $topic[] = array('id'=>$res_row[0],'name'=>$res_row[1],'url'=>$res_row[2],'rating'=>$res_row[3], 'category'=>$res_row[4] ,'site_main'=> $res_row[5]); 
   
  }
 }
 else
  {
  $topic[] = "None";
  }
 $mysqli->close();
 return $topic;
}
?>

Thankig u all.
       
---------------------------------
 Get the freedom to save as many mails as you wish. Click here to know how.

[Non-text portions of this message have been removed]


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux