我有来自同一个表的两个查询并选择相同的信息,但将结果发送给两个名称。有两个变量来存储结果,但是如何存储来自查询的其他信息?
require_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(id) FROM artwork"; //find total number of id's
$result = mysqli_query ($dbc, $query) or die("query error, line 22");
$row = mysqli_fetch_array ($result, MYSQL_NUM);
find_pic(); //get the two id numbers
while ($count1 = $count2 or name = ""){ //problem line. check if counts = each other or either name = nothing
find_pic(); //if true, run function again
}
while ($count1=37 or $count2=37){ //if either count = 37
find_pic(); //if true, run function again
}
show_pic();
function find_pic(){
$count1 = rand(0,$row[0]);
$count2 = rand(0,$row[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");
}