$link = mysqli_connect("localhost", "root", "1124", "mini_dialer");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$rand=array();
$query = " select * from leads";
if ($result = mysqli_query($link, $query)) {
/* fetch associative array */
while ($row = mysqli_fetch_assoc($result)) {
$rand[]=$row[lead_id];
}
/* free result set */
mysqli_free_result($result);
$key=array_rand ($rand);
echo "Selecting random element $rand[$key]"; // this will print rand value
}
else {mysqli_close($link);
?>
printf("Error: %s\n", mysqli_error($link));
}
/* close connection */
No hay comentarios:
Publicar un comentario