PHP array with mysql and other -
i have table1 phone numbers data 09454151,094949154 , other data client.
my input data in phone number like: 000385926555494 or 0385981961969 convert to: 0926555494 or 0981961969
that works fine code (where $broj00 = '000385926555494 '):
$broj00 = preg_replace('/'.ulazni_poziv.'/', '', $broj); //dodavanje prefixa za ljepsi pregeld broja $prfix = 0; $broj01 = array($prefix,$broj00); $broj02 = implode('',$broj01);
then have problem, work if $broj 1 data can have in $broj = '09846646646,098956565,0989898' 3 number in date.
how can explode 3 number 1 ? , search database number name , return name?
full code working $broj = '0986464646'; -> 1 number.
function realbroj_ul($broj){ global $database; global $session; $result = ""; //uklanjanje odredenog djela iz broja $broj00 = preg_replace('/'.ulazni_poziv.'/', '', $broj); //dodavanje prefixa za ljepsi pregeld broja $prefix = 0; $broj01 = array($prefix,$broj00); $broj02 = implode('',$broj01); if ($broj02 != ''){ $sql = "select * imenik broj='$broj02'"; $query = $database->query($sql); $row = $database->fetch_array($query); if ($row['id'] != ''){ $ime = $row['ime']; $prezime = $row['prezime']; $arry = array($ime,$prezime); $fime = implode(" ", $arry); $result = "<a style='color:green;' href='index.php?stranica=imenik&korisnik=".$broj02."'>".$fime." (".$broj02.")<i class='material-icons' style='margin-top: -2px;position: absolute;color: green;margin-left: 5px;'>search</i></a>"; }else{ $result = "".$broj02." <a href='index.php?stranica=imenik-add&broj=".$broj02."' alt='dodaj u imenik'><i class='material-icons' style='margin-top: -4px;position: absolute;color: blue;margin-left: 5px;'>add_circle</i>"; } } return $result; }
as commented, explode quite simple:
$numbers = explode(",", $phone_numbers);
will return array of phone numbers.
but have create new database schema. advice create table clients , table phone numbers. can have each phone number related client id. searching way have no problem @ all.
client table: id_client | name | surname | etcetera
phone table: id_phone | id_client | phone_number | type(home office, etc)
Comments
Post a Comment