Click here to Skip to main content
15,906,341 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:

C#
&lt;?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-&gt;connect_error) {
    			         die("Connection failed: " . $conn-&gt;connect_error);
    			    } 
    			    $result = mysqli_query($conn,"SELECT `date` FROM `editor` WHERE subject = '.$varPage.'");
    
    while($row = mysqli_fetch_array($result))
    
    ?&gt;
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900