我有一个显示数据库数据的小代码。:
<?php
require 'connect.php';
$checkuserlogin='SELECT * FROM users WHERE uname="raj"';
$runcheckuserlogin=mysqli_query($connect,$checkuserlogin);
echo mysqli_fetch_array($runcheckuserlogin)['ts'];
echo mysqli_fetch_array($runcheckuserlogin)['llogin'];
?>
这只能给我带来的价值。柱。如果我重新排序回声线,我会得到一个首先出现的回声线。并且第二个回波线没有返回任何东西。
我一定是做错了...因为我没有让任何人在这里遇到同样的问题......
答案 0 :(得分:2)
不要执行两次mysqli_fetch_array:
//MARK: - UITabBarControllerDelegate
func tabBarController(tabBarController: UITabBarController, didSelectViewController viewController: UIViewController) {
if viewController == tabBarController.moreNavigationController {
tabBarController.moreNavigationController.delegate = self
} else {
setSelectedTabBarOption()
}
}
//MARK: - UINavigationControllerDelegate
func navigationController(navigationController: UINavigationController, willShowViewController viewController: UIViewController, animated: Bool) {
setSelectedTabBarOption()
}
private func setSelectedTabBarOption() {
if let viewControllers = viewControllers {
let selectedController: UIViewController? = viewControllers.count > selectedIndex ? viewControllers[selectedIndex] : nil
if let tag = selectedController?.tabBarItem.tag {
//do whatever with your tag
}
}
}
对于奖励积分,您应该以面向对象的方式处理MySQLi。有关如何......请参阅mysqli::query documentation
答案 1 :(得分:1)
多数民众赞成是因为每个查询只应使用一次mysqli_fetch_array。
Here is a link to mysqli_fetch_array documents
我已经添加了正确的方法。
<?php
require 'connect.php';
$checkuserlogin='SELECT * FROM users WHERE uname="raj"';
$runcheckuserlogin=mysqli_query($connect,$checkuserlogin);
$row=mysqli_fetch_array($runcheckuserlogin);
echo $row["ts"];
echo $row["llogin"];
?>