我的桌子(媒体)有20个记录,有5列(身份证,姓名,电话,电子邮件,地址) 我需要在我的php文件中显示这20条记录怎么做?
答案 0 :(得分:0)
Learn how to query a database using PHP,然后使用如下查询从数据库中获取数据:
SELECT * FROM media;
扩展解决方案:
$db = new mysqli('localhost', 'user', 'pass', 'demo');
if($db->connect_errno > 0){
die('Unable to connect to database [' . $db->connect_error . ']');
}
$sql = "SELECT * FROM media;";
if(!$result = $db->query($sql)){
die('There was an error running the query [' . $db->error . ']');
}
while($row = $result->fetch_assoc()){
echo $row['id'] . ', ' . $row['name'] . ', ' . $row['phone'] . ', ' . $row['email'] . ', ' . $row['address'] . '<br />';
}
每个字段都可以在$row
数组中找到,用于earch结果行。
答案 1 :(得分:0)
学习如何做到这一点的最佳地点是阅读手册或查看PHP website,但这应该会给你一个开端。
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error) {
for (PFObject *object in objects) {
[SVProgressHUD show];
PFFile *thumbnail = [object objectForKey:@"photo"];
[thumbnail getDataInBackgroundWithBlock:^(NSData *data, NSError *error) {
if (!error) {
NSData *imageData = data;
UIImage *image = [UIImage imageWithData:imageData];
[photosArray addObject:image];
[self.collectionView reloadData];
} else {
NSLog(@"Error: %@ %@", error, [error userInfo]);
}
[SVProgressHUD dismiss];
}];
}
}
答案 2 :(得分:0)
<?php
$mysqli = new mysqli("localhost", "my_user", "my_password", "database_name");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$query = "SELECT * FROM media";
if ($result = $mysqli->query($query)) {
/* fetch associative array */
while ($row = $result->fetch_assoc()) {
echo $row['id'] . ', ' . $row['name'] . ', ' . $row['phone'] . ', ' . $row['email'] . ', ' . $row['address'] . '<br />';
}
/* free result set */
$result->close();
}
/* close connection */
$mysqli->close();
?>
试试这个