Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- header("content-type: application/javascript");
- require_once 'config.php';
- function number_of_images(){
- $stmt = $mysqli->prepare("select COUNT(*) from images");
- $stmt->execute();
- $stmt->bind_result($num_rows);
- $stmt->fetch():
- return $num_rows;
- }
- function image_uri($id){
- $stmt = $mysqli->prepare("select uri from images where id=?");
- $stmt->bind_param("i", $id);
- $stmt->execute();
- $stmt->bind_result($uri);
- return uri;
- }
- $image_id = rand(0, number_of_images());
- printf("{\"image_id\":%s, \"image_uri\":\"%s\"}", $image_id, image_uri($image_id));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement