在PHP中组合$ _GET和$ _POST? [英] Combine $_GET and $_POST in PHP?
问题描述
对于一些朋友和家人(不同的网站),我创建了一个脚本,允许他们输入数据到数据库。
for some friends and family (different sites), I created a script that allows them to input data into the database. With
echo ("<a href=\"./pagina.php?ID=" . $row['ID'] . "\">" . $row['ID'] . "<br>");
,我将要求的表格的ID传送到网址。
, I 'send' the ID of the requested table to the URL.
在pagina.php中,我有以下代码:
In pagina.php, I have this code:
ID: <?php echo $_GET["ID"]; ?>
这当然有效,但现在我想使用该ID来显示数据库,所以不能从URL。这些值是。$ row ['onderwerp']。
和。$ row ['tekst']。
(可能有更多的值,但我只是一个初学者,试图得到一些工作)。
That works, of course, but now I want to use that ID to also display the data from the database, so not from the URL. These values are " . $row['onderwerp'] . "
and " . $row['tekst'] . "
(There may be more values to come, but I'm just a beginner, trying to get something to work).
我知道这是可能的,但我只是不能得到任何工作,因为我刚刚开始学习PHP。
I know this is possible, but I just can't get anything to work, as I have just started learning PHP.
我希望你能帮助我。
推荐答案
$id = (int)$_GET['id'];
$sql = "SELECT onderwerp, tekst FROM yourtable WHERE id=$id";
$result = mysql_query($sql) or die(mysql_error());
while($row = mysql_fetch_assoc($result)) {
echo "{$row['onderwerp']} - {$row['tekst']}<br />";
}
这篇关于在PHP中组合$ _GET和$ _POST?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!