从index.php到detail.php

从index.php到detail.php,php,mysql,get,detail,Php,Mysql,Get,Detail,我的代码有问题 我在index.php(php,mysql)中有html表…这是: 因此,我已链接出零件号,没有问题。当我想看到某些产品的细节时,问题就会显现出来。My detail.php现在看起来像这样: <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cs" lang="cs"> <head> <?php require ('../../inc/config.inc.php'); require

我的代码有问题

我在index.php(php,mysql)中有html表…这是:


因此,我已链接出零件号,没有问题。当我想看到某些产品的细节时,问题就会显现出来。My detail.php现在看起来像这样:

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cs" lang="cs">

<head>
<?php
require ('../../inc/config.inc.php');
require ('../../inc/ini.php');
mysql_set_charset('utf8');
$part_id=$_GET['part_id'];
$data = mysql_query("SELECT * FROM {$cfg['tbl_dily']} WHERE part_id='$part_id'") or die(mysql_error());
while ($detail = mysql_fetch_array($data)){
$id =$detail['part_id'];
}
?>
<title><?php $id; ?></title>
</head>
<body>
<div class="detail">
    <span id="detail_id">Výpis nabídky id <?php $id; ?></span>
    <div class="detail_foto">
    </div>
    <div class="detail_info">
    </div>
</div>
</body>
</html>


你的解释不太好。你也许应该编辑问题并解释问题所在。但现在,让我解释一下“$\u GET”

“$\u GET”是一种将数据从一个PHP脚本传递到另一个PHP脚本的方法。你几乎可以在每一个公式中找到它们。正如您在下面的代码中所看到的,有一种简单的方法可以将数据发送到“action.php”——属性“method”用于告诉公式您想要做什么。您可能应该查看这两个选项,因为GET会在链接中显示您想要传递的数据。您的用户可能会开始处理在您的情况下非常不安全的事情,因为您使用的是mysql数据库。另外,您还应该看看Mysql字符串转义

回到主题:下面的HTML将$\u GET['name']和$\u GET['age']重定向到action.php,您可以在那里使用它们

<form action="action.php" method="get">
<p>Your ame: <input type="text" name="name" /></p>
<p>Your age: <input type="text" name="age" /></p>
<p><input type="submit" /></p>
</form>

您的姓名:

您的年龄:


您的
$\u GET
键必须与您的url键匹配-尝试更改
$part\u id=$\u GET['part\u id']
$part\u id=$\u GET['id']如您所拥有的
?id=“.$part\u id.”
。注意,您使用的是
$\u GET['id']
直接在查询中,而不转义,因此容易受到SQL注入的攻击在编写更多数据库接口代码之前,您必须花一些时间熟悉以避免。你在这里做的事非常危险。请不要以这种方式使用
mysql\u query
,如果可以避免的话,请不要使用。
<form action="action.php" method="get">
<p>Your ame: <input type="text" name="name" /></p>
<p>Your age: <input type="text" name="age" /></p>
<p><input type="submit" /></p>
</form>