dod Posted December 17, 2009 Share Posted December 17, 2009 This is my Mysql gen. can anyone tell me why this echos MID(networkset.networkid, 3, 3) AS "MNC" SELECT FROM scan JOIN gps ON scan.gpsid = gps.gpsid JOIN gsmscanset ON scan.scanid = gsmscanset.scanidJOIN gsmcell ON gsmscanset.cellid = gsmcell.cellid WHERE scan.typeid = 4 AND gsmcell.cellid = gsmcell.servingcellid and not SELECT MID(networkset.networkid, 3, 3) AS "MNC" FROM scan JOIN gps ON scan.gpsid = gps.gpsid JOIN gsmscanset ON scan.scanid = gsmscanset.scanidJOIN gsmcell ON gsmscanset.cellid = gsmcell.cellid WHERE scan.typeid = 4 AND gsmcell.cellid = gsmcell.servingcellid heres the code: $arr = array($date,$time,$latandlong,$satdata,$MCC,$MNC,$MCCMNC,$name,$callid,$lac,$bsic,$arfcn,$relvl,$c1,$c2,$rxq,$timing,$numres,$audio,$video,$image); function select($arr){ foreach ($arr as $key => $value) { if (is_null($value)) { unset($arr[$key]); } } $last_item = end($arr); $last_item = each($arr); reset($arr); foreach($arr as $key => $value){ if($value == $last_item['value'] && $key == $last_item['key']){ echo ','; } print $value; } } //echo '<br>'; /* FROM */ $fromdefault1=" scan JOIN gps ON scan.gpsid = gps.gpsid"; $fromdefault2=" JOIN gsmscanset ON scan.scanid = gsmscanset.scanid"; $fromdefault3="JOIN gsmcell ON gsmscanset.cellid = gsmcell.cellid"; /* WHERE */ $wheredefault="scan.typeid = 4 AND gsmcell.cellid = gsmcell.servingcellid"; 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 */ $query = " SELECT ".select($arr)." FROM ".$fromdefault1.$namefrom.$fromdefault2.$fromdefault3.$numresform1.$numresform2.$audiofrom.$videofrom.$imagefrom." WHERE ".$wheredefault.$datesearch.$timesearch.$latandlongsearch . " "; echo $query; } Thank you!!!! Quote Link to comment https://forums.phpfreaks.com/topic/185485-mysql-gen-help/ Share on other sites More sharing options...
sasa Posted December 17, 2009 Share Posted December 17, 2009 in line $query = " SELECT ".select($arr)." FROM ".$fromdefault1.$namefrom.$fromdefault2.$fromdefault3.$numresform1.$numresform2.$audiofrom.$videofrom.$imagefrom." WHERE ".$wheredefault.$datesearch.$timesearch.$latandlongsearch . " "; you call function select it echo some strings and return null after that concat this (null) in string in next line script echo this new string Quote Link to comment https://forums.phpfreaks.com/topic/185485-mysql-gen-help/#findComment-979307 Share on other sites More sharing options...
dod Posted December 21, 2009 Author Share Posted December 21, 2009 in line $query = " SELECT ".select($arr)." FROM ".$fromdefault1.$namefrom.$fromdefault2.$fromdefault3.$numresform1.$numresform2.$audiofrom.$videofrom.$imagefrom." WHERE ".$wheredefault.$datesearch.$timesearch.$latandlongsearch . " "; you call function select it echo some strings and return null after that concat this (null) in string in next line script echo this new string so how do i fix it? Quote Link to comment https://forums.phpfreaks.com/topic/185485-mysql-gen-help/#findComment-981418 Share on other sites More sharing options...
sasa Posted December 22, 2009 Share Posted December 22, 2009 change function to function select($arr){ foreach ($arr as $key => $value) { if (is_null($value)) { unset($arr[$key]); } } $last_item = end($arr); $last_item = each($arr); reset($arr); return implode(', ',$arr); }[/codeg Quote Link to comment https://forums.phpfreaks.com/topic/185485-mysql-gen-help/#findComment-982044 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.