我终于设法让我的代码从两个表中的每一个中返回第一列,但是我如何更改代码以从两个表中返回所有各种列数据并按 ID 号排序。这是我的代码
<?php
$mysqli = mysqli_connect("localhost", "name", "pass", "db");
// check connection
if (mysqli_connect_errno()) {
echo "Connect failed: " . mysqli_connect_errno(); exit();
}
$query = "SELECT * FROM custrec;"; "SELECT * FROM contidr;";
$result = array();
/* execute multi query */
if ($mysqli->multi_query($query))
{
do
{
//store first result set
if($result = $mysqli->store_result())
{
while( $rows = $result->fetch_row())
{
printf("<br/>%s<br/>", $rows[0]);
}
$result->free();
}
/* print divider */
if($mysqli->more_results())
{
printf("-----------------<br/>");
}
else
{
echo '<br/>';
}
} while($mysqli->more_results() && $mysqli->next_result());
}
/* close connection */
$mysqli->close();
?>