Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/242.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在php和mysql中为每一行创建唯一的页面?_Php_Mysql_Sql - Fatal编程技术网

如何在php和mysql中为每一行创建唯一的页面?

如何在php和mysql中为每一行创建唯一的页面?,php,mysql,sql,Php,Mysql,Sql,我有一个表,有4列(id、名称、姓氏、url)。我想为每一行创建唯一的子页面。(example.com/id?=444)。所以,如果我访问example.com?id=444,我将看到id为444的行中的数据 现在我有一个表单,您可以将数据添加到数据库中: <form action="motogp.php" method="POST"> <input type="text" name="name" placeholder="Ime"> <input type="

我有一个表,有4列(id、名称、姓氏、url)。我想为每一行创建唯一的子页面。(example.com/id?=444)。所以,如果我访问example.com?id=444,我将看到id为444的行中的数据

现在我有一个表单,您可以将数据添加到数据库中:

 <form action="motogp.php" method="POST"> <input type="text"
 name="name" placeholder="Ime"> <input type="text" name="surname"
 placeholder="Priimek"> <input type="text" name="url" placeholder="URL
 do slike"> <button type="reset" class="ui button">Počisti</button>
 <button type="submit" class="ui positive button">Pošlji</button>
 </form>
Počisti
波什尔吉
motogp.php页面代码:

$sql="INSERT INTO person (name, surname, url)
VALUES
('$_POST[name]','$_POST[sruname]','$_POST[url]')";

if (!mysqli_query($con,$sql))
  {
  die('Error: ' . mysqli_error($con));
  }


$result = mysqli_query($con,"SELECT * FROM person ORDER BY id DESC LIMIT 1");


while($row = mysqli_fetch_array($result))
  {
  echo "<h2>VIDEO: " . $row['name'] . . $row['surname'] . " z drugo zaporedno zmago zmanjšal zaostanek za Marquezom</h2>";
  echo "<img src='images/avoter.png'>";
  echo "<img src='" .  $row['url'] ."'>";

}
$sql=“插入个人(姓名、姓氏、url)
价值观
("$"发帖[名称]","$"发帖[地址]","$"发帖[网址]";;
如果(!mysqli_query($con,$sql))
{
die('Error:'.mysqli_Error($con));
}
$result=mysqli_query($con,“按id描述从个人订单中选择*限制1”);
while($row=mysqli\u fetch\u数组($result))
{
echo“视频:.$row['name'].$row['姓氏].“z drugo zaporedno zmago zmanjšal-zaostanek za Marquezom”;
回声“;
回声“;
}
现在它只给了我example.com/motogp.php而不是example.com/?id=444。

您需要使用$\u GET[''而不是$\u POST[''

GET通过URL发送您的所有数据,格式为

website.com/page.php?v=d&v=d
其中v是一个变量,d是分配给它的某种数据。 如果您想要动态创建页面。你需要把它发过去

所以如果你想要的页面是 website.com/page.php?id=4 为了从id为4的数据库条目中获取数据,您需要这样做

<?php
$id = $_GET['id']; //in the case of the URL above, it will equal four
?>
在page.php的代码中,您可以使用以下代码看到“id”等于什么:

$var = $_GET['id'];
这将从url中获取id的值

So for website.com/page.php?id=1 $var is equal to 1,
for website.com/page.php?id=2 $var is equal to 2,
for website.com/page.php?id=3 $var is equal to 3,

example.com/?id=444
example.com/index.php?id=444
(或者无论默认的目录索引页面是什么,index.html等等)的缩写。你创建了那个页面吗?我想要那个?id=444在motogp.php中,当尝试访问/motogp.php?id=3时,它会给我错误。然后你会想要更改你的链接以包含
motogp.php
。然后您将遇到更多问题,因为该页面看起来像您的“表单处理程序”。用于处理表单数据的页面(表单的
操作所引用的页面
通常应该与用于查看数据库数据的页面不同。因此,我将$id=$\u GET['id'];放在我的motogp.php文件中?我真的不明白这一点。您将$id=$\u GET['id'];在您试图创建动态的文件上。我将其放在motogp.php中,如果type/motogp.php?id=1,则会给出错误(未定义索引)
So for website.com/page.php?id=1 $var is equal to 1,
for website.com/page.php?id=2 $var is equal to 2,
for website.com/page.php?id=3 $var is equal to 3,