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
https://forums.phpfreaks.com/topic/185873-need-help-urgant/
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
https://forums.phpfreaks.com/topic/185873-need-help-urgant/#findComment-981507
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
https://forums.phpfreaks.com/topic/185873-need-help-urgant/#findComment-981510
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
https://forums.phpfreaks.com/topic/185873-need-help-urgant/#findComment-981515
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.