Friday, 15 March 2013

php - multiple mysql queries with different result names -


I have two questions from the same table and select the same information, but the results send on two names. There are two variables to store the result, but how do I store other information from the query?

  need_once ('connectvars.php'); $ Dbc = mysqli_connect (DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) or die ('Error connecting to server, line 20.'); $ Query = "SELECT COUNT (Art) from Artwork"; $ Number of ID = mysqli_query ($ dbc, $ query) Total number of / or die ("query error, line 22"); $ Line = mysqli_fetch_array ($ result, MYSQL_NUM); Find_pic (); // Get two ID numbers ($ count1 = $ count2 or name = "") {// check the problem line if calculation = a second or any name = nothing;); // if true, run the function again} while ($ count1 = 37 or $ count2 = 37) {// if any calculation = 37 find_pic (); // if true, run the function again} show_pic (); Function find_pic () {$ count1 = rand (0, $ line [0]); $ Count2 = rand (0, line [[0]); $ Query1 = "SELECT * FROM artwork WHERE id = $ count1"; $ Query2 = "SELECT * FROM artwork WHERE id = $ count2"; $ Result1 = mysqli_query ($ dbc, $ query1) or die ("query error, line 38"); $ Result2 = mysqli_query ($ dbc, $ query2) or die ("query error, line 39"); }    

If the whole point is to get two random images, why not do it? SELECT is the artwork from WHERE ID! = 37 and name! = '' ORDER BY RAND () LIMIT 2

No comments:

Post a Comment