如何添加多个php命令,如:
$email = $_POST['email'];
//get the user.id
$result = mysql_query("SELECT user.id FROM user WHERE user.email LIKE '$email'");
$user_id = mysql_fetch_array($result);
$user_id = $user_id["id"];
//fill the album -> "Profilbilder"
mysql_query("INSERT INTO `album` (`user_id`, `name`) VALUES ('$user_id', 'Profilbilder')") or die(mysql_error());
//get the album.id
$result = mysql_query("SELECT album.id FROM album WHERE album.user_id = '$user_id'");
$album_id = mysql_fetch_array($result);
$album_id = $album_id["id"];
mysql_query("INSERT INTO `foto` (`album_id`, `name`, `zeitstempel`, `link`) VALUES ('$album_id', '$file_name', NOW(), '$file_path')") or die(mysql_error());
..在一个大命令中获取数据库信息?
答案 0 :(得分:1)
您实际上可以将查询结果插入表中,如下所示:
$query="INSERT INTO `album`
(`user_id`, `name`)
SELECT user.id, 'Profilbilder'
FROM `user`
WHERE user.email LIKE '%$email%'";