如何编写PHP代码来访问第一个元素,直到列网站的最后一个元素,并将输出传递给另一个PHP函数。
<?php
$mysqli = new mysqli("localhost", "root", "", "wte");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$query = "SELECT Website FROM websites";
if ($result = $mysqli->query($query)) {
// PHP code to access the first element till last element of the column Website and to pass the output to another php function
}
/* free result set */
$result->close();
}
/* close connection */
$mysqli->close();
?>
答案 0 :(得分:1)
阅读php手册:http://php.net//manual/en/mysqli-result.fetch-assoc.php
while ($row = $result->fetch_assoc()) {
your_function($row["Website"]);
}