My Group messaging system uses an array to control numbers and names
$people = array(
"+14031234567" => "Test Black Berry",
"+14038999999" => "Test Android",
"+14036519999" => "Test iPhone",
);
I have attempted to use php to get this information from a mysql db
<?php
include("config.php");
$connect = new mysqli("$dbhost","$dbuser","$dbpass","$dbname")
or die (mysqli_error());
$people=$connect->query("SELECT phone, name FROM contacts");
while($row=$people->fetch_array(MYSQLI_ASSOC)){
echo
$row ['phone']." => ".$row['name'].",";
}
?>
which gives me the result
+14037777777 => Test Black Berry,
+14038888888 => Test Android,
+14039999999 => Test iPhone,
Close but not quite all the way. What am I missing. Thanks in advance for the help
This the final code that works in my Message App
<?php
include("../../lib/config.php");
$conn=mysqli_connect("$dbhost","$dbuser","$dbpass","$dbname")
or die (mysqli_error());
$query = "SELECT phone, name FROM grouplist";
$result = mysqli_query($conn, $query);
$people = array();
while ($row = mysqli_fetch_assoc($result)) {
$people[$row['phone']] = $row['name'];
}
?>