Php 如何插入/更新/选择数据库,您应该创建另一个问题或学习一点mysql。因此,当您使用列中的uniqid()字符串将照片插入数据库时,然后获取所有照片并显示带有列的url。ohkay现在假设我从mysql数据库获取用户id和照片id,那么我在uniqid()
Php 如何插入/更新/选择数据库,您应该创建另一个问题或学习一点mysql。因此,当您使用列中的uniqid()字符串将照片插入数据库时,然后获取所有照片并显示带有列的url。ohkay现在假设我从mysql数据库获取用户id和照片id,那么我在uniqid(),php,mysql,Php,Mysql,如何插入/更新/选择数据库,您应该创建另一个问题或学习一点mysql。因此,当您使用列中的uniqid()字符串将照片插入数据库时,然后获取所有照片并显示带有列的url。ohkay现在假设我从mysql数据库获取用户id和照片id,那么我在uniqid()中运行它该怎么办?您不需要运行任何东西,uniqid它将返回一个唯一的字符串。检查此示例在您的表“link”上创建一个新列,然后使用link=uniqidUpdate更新数据,并使用uniqid更新表,然后在获取数据时使用它,yourphoto
如何插入/更新/选择数据库,您应该创建另一个问题或学习一点mysql。因此,当您使用列中的uniqid()字符串将照片插入数据库时,然后获取所有照片并显示带有列的url。ohkay现在假设我从mysql数据库获取用户id和照片id,那么我在uniqid()中运行它该怎么办?您不需要运行任何东西,uniqid它将返回一个唯一的字符串。检查此示例在您的表“link”上创建一个新列,然后使用link=uniqidUpdate更新数据,并使用uniqid更新表,然后在获取数据时使用它,yourphoto.php?num=$row['uniqid'];关于如何插入/更新/选择数据库的更多问题,您应该创建另一个问题或学习一点mysql。因此,当您使用列中的uniqid()字符串将照片插入数据库时,然后获取所有照片并显示带有列的url。ohkay现在假设我从mysql数据库获取用户id和照片id,那么我在uniqid()中运行它该怎么办?您不需要运行任何东西,uniqid它将返回一个唯一的字符串。检查此示例在您的表“link”上创建一个新列,然后使用link=uniqidUpdate更新数据,并使用uniqid更新表,然后在获取数据时使用它,yourphoto.php?num=$row['uniqid'];关于如何插入/更新/选择数据库的更多问题,您应该创建另一个问题或学习一点mysql。因此,当您使用列中的uniqid()字符串将照片插入数据库时,然后获取所有照片并显示带有列的url。ohkay现在假设我从mysql数据库获取用户id和照片id,那么我在uniqid()中运行它该怎么办?您不需要运行任何东西,uniqid它将返回一个唯一的字符串。检查此示例在您的表“link”上创建一个新列,然后使用link=uniqidUpdate更新数据,并使用uniqid更新表,然后在获取数据时使用它,yourphoto.php?num=$row['uniqid'];有关如何插入/更新/选择数据库的更多其他问题,您应该创建另一个问题或学习一点mysql。因此,当您使用列中的uniqid()字符串将照片插入数据库时,您将获取所有照片并显示带有该列的url。
yourphoto.php?num=60&idr=3
yourphoto.php?num=654654654648&idr=34546545621
//Insert into DB
$new_photo = array(
array('id' => 1, 'name' => 'newphoto', 'unique' => uniqid()),
array('id' => 2, 'name' => 'newphoto2', 'unique' => uniqid())
);
// select everything from db
$photos = $new_photo;
//display photos
foreach($photos as $photo){
// display Link with $photo['unique'], <a href="link.php?num=$photo['unique']"
var_dump($photo);
}
//GET Num
// select where unique = $_GET['num']
// DB information
$host = "localhost";
$username = "root";
$password = "password";
$dbname = "database";
// Create our photos_temp table
$test_query = "CREATE TABLE IF NOT EXISTS `photos_temp` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`unique` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;";
//Connect to DB
$conn = new mysqli($host, $username, $password, $dbname);
// Create Table
$table = $conn->prepare($test_query);
$table->execute();
// Data to insert into the database ( you can insert trough a form )
$new_photos = array(
array('name' => 'newphoto', 'unique' => uniqid()),
array('name' => 'newphoto2', 'unique' => uniqid())
);
// Insert Query template
$addquery = "INSERT INTO `photos_temp` (`name`, `unique`) VALUES (?, ?)";
// foreach our data ( we will insert the 2 photos )
foreach($new_photos as $photo){
if($query = $conn->prepare($addquery)){
$query->bind_param('ss', $photo['name'], $photo['unique']);
$query->execute();
}
}
echo 'finish inserting';
// DB information
$host = "localhost";
$username = "root";
$password = "password";
$dbname = "database";
$conn = new mysqli($host, $username, $password, $dbname);
$stmt = $conn->stmt_init();
$stmt->prepare('Select * from photos_temp');
$stmt->execute();
$result = $stmt->get_result();
while ($data = $result->fetch_assoc())
{
echo '<a href="?num='.$data['unique'].'">'.$data['name'].'</a><br/>';
}
if(isset($_GET['num'])){
$num = $_GET['num'];
$stmt->prepare("SELECT * FROM `photos_temp` WHERE `unique` = ?");
$stmt->bind_param("s", $num);
$stmt->execute();
$result = $stmt->get_result();
$photo = $result->fetch_assoc();
echo '<pre>';
print_r($photo);
}