Jump to content

Need help urgant


dod

Recommended Posts

why down my code ony return one item instead of all the items selected.

$arr = array($date,$time,$latandlong,$satdata,$MCC,$MNC,$MCCMNC,$name,$callid,$lac,$bsic,$arfcn,$relvl,$c1,$c2,$rxq,$timing,$numres,$audio,$video,$image);

foreach ($arr as $key => $value) {
  if (is_null($value)) {
    unset($arr[$key]);
  }
} 

function select($array){
$last_item = end($array);
$last_item = each($array);
reset($array);
foreach($array as $key => $value){
if($value == $last_item['value'] && $key == $last_item['key']){
	echo ',';
}
return $value;
}
}

if (isset($datebetween, $dateand)){$datesearch=' AND DATE(gps.date) BETWEEN '.$datebetween.' AND '.$dateand.'';}
if (isset($timebetween, $timeand)){$timesearch=' AND DATE(gps.time) BETWEEN '.$timebetween.' AND '.$timeand.'';}
if (isset($timebetween, $timeand)){$timesearch=' AND DATE(gps.time) BETWEEN '.$timebetween.' AND '.$timeand.'';}
if (isset($lat, $long)){$latandlongsearch=' AND DATE(gps.time) BETWEEN '.$lat.' AND '.$long.'';}

$query =   'SELECT '.select($arr).'
			FROM '.$fromdefault1.$namefrom.$fromdefault2.$fromdefault3.$numresform1.$numresform2.$audiofrom.$videofrom.$imagefrom.'
			WHERE '.$wheredefault.$datesearch.$timesearch.$latandlongsearch . ' ';	

/* Query */
echo $query;

}

thank you!!!!!

Link to comment
Share on other sites

If the code is parsing without problems, then either your SQL query is structured incorrectly, or your data is incorrect, which is building the SQL query incorrectly.

 

Check that your echo $query output is what you need it to be. If it is correct, then your table probably doesn't have the data you expect it to.

 

I don't know what "item" you are asking about.

Link to comment
Share on other sites

If the code is parsing without problems, then either your SQL query is structured incorrectly, or your data is incorrect, which is building the SQL query incorrectly.

 

Check that your echo $query output is what you need it to be. If it is correct, then your table probably doesn't have the data you expect it to.

 

I don't know what "item" you are asking about.

 

i was talking about the var $value. it only outputs 1 value :S

Link to comment
Share on other sites

do a print_r($arr); and ensure $arr has the data you expect in it.

 

do the print_r() before and after the foreach loop that does the is_null() checks.

 

oh wait... look at the select() function.

 

you are foreaching through $array parameter, but only returning $value which wil be the value of the last index in the array. I guess you want to build a string of field names with , between them like field1,field2,field3?

 

You need to: $returnValue .= $value.','; and then return($returnValue);

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.