从get变量中选择语法 [英] Select syntax from a get variable
问题描述
我想从数据库中选择一个我从$ _GET获得的变量值,但它没有显示任何结果。任何人都可以帮我找到我的代码有什么问题吗?
这是我的第一页如何获得GET的价值:
<?php
if($ result-> num_rows> 0){
while($ row = $ result-> ; fetch_assoc()){
?>
< tr>
< td>< a href =file.php ?subject =<?= $ row ['subject']?>><?= $ row ['subject']?>< / a>< / td>
< td><?= $ row ['location']?>< / td>
< td><?= $ row ['geo']?> ;< / td>
< td><?= $ row ['date']?>< / td>
< td>< ;?= $ row ['piority']?>< / td>
< / tr>
<?php
}
}
?>
这是我的第二页,我想从数据库获取数据,主题变量来自第一页页面:
<?php
$ varPage = $ _GET ['subject'];
$ servername =localhost;
$ username =bayansh_;
$ password =u)nHf,Acc);
$ dbname =bayansh_;
$ conn = new mysqli($ servername,$ username,$ password,$ dbname);
//检查连接
if($ conn-> connect_error){
die(连接失败:。 $ conn-> connect_error);
}
$ result = mysqli_query($ conn,SELECT`date` FROM`s editor` WHERE subject ='。$ varPage。 ');
while($ row = mysqli_fetch_array($ result))
?>
现在我想在这里写日期是我的代码:
< p style = font-family:B Zar; direction:rtl; font-size:165%;> <?= $ row ['date']?> < / p>
但它什么也没写。
我的代码有什么问题吗?
我尝试了什么:
I want to select a value from the database with variables I get from $_GET, but it doesn't show any results. Could any one help me find what is wrong with my code?
here is my first page how i get the value to GET:
<?php
if($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
?>
<tr>
<td><a href="file.php?subject=<?= $row['subject'] ?>"><?= $row['subject'] ?></a></td>
<td><?= $row['location'] ?></td>
<td><?= $row['geo'] ?></td>
<td><?= $row['date'] ?></td>
<td><?= $row['piority'] ?></td>
</tr>
<?php
}
}
?>
and here is my second page that i want to get data from database with subject variable from first page:
<?php
$varPage = $_GET['subject'];
$servername = "localhost";
$username = "bayansh_";
$password = "u)nHf,Acc)";
$dbname = "bayansh_";
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$result = mysqli_query($conn,"SELECT `date` FROM `editor` WHERE subject = '.$varPage.'");
while($row = mysqli_fetch_array($result))
?>
and now i want to write the date here is my code:
<p style="font-family:B Zar; direction:rtl; font-size:165%;"> <?= $row['date'] ?> </p>
but it writes nothing.
Is there anything wrong with my code?
What I have tried:
<?php
$varPage = $_GET['subject'];
$servername = "localhost";
$username = "bayansh_user";
$password = "u)nHf,Accmo)";
$dbname = "bayansh_bmc";
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$result = mysqli_query($conn,"SELECT `date` FROM `editor` WHERE subject = '.$varPage.'");
while($row = mysqli_fetch_array($result))
?>
推荐答案
_GET,但它没有显示任何结果。任何人都可以帮我找到我的代码有什么问题吗?
这是我的第一页如何获得GET的价值:
<?php
if(
_GET, but it doesn't show any results. Could any one help me find what is wrong with my code?
here is my first page how i get the value to GET:
<?php
if(
result-> num_rows> 0){
while(
result->num_rows > 0) {
while(
row =
这篇关于从get变量中选择语法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!