我想在产品的网址中传递一个唯一的变量,即数据库中的产品代码或产品ID,每个产品都会在php中动态拥有自己的链接
答案 0 :(得分:0)
您可以使用获取变量
喜欢:
sitename.com/index.php?id=1234
在index.php中就像:
<?php
$DBuser = "XXX";
$DBpassword = "XXX";
$DBhost = "localhost";
$DBname = "XXX";
$mysqli = new mysqli($DBhost, $DBuser, $DBpassword, $DBname);
if ($mysqli->connect_errno) {
printf("Connect failed: %s\n", $mysqli->connect_error);
exit();
}
if ($result=$mysqli->multi_query("SELECT * FROM productos WHERE id='".$_GET['id']."' LIMIT 1")) {
$data = mysqli_fetch_assoc($result)
print_r($data);
} else
echo "Error, id not found";
?>