Reputation:
When I click the go to the form I want to see all other information about that id number. Here is the code behind the go to the form option:
<td width="174" class="centertext"><a href="form.php?formid=<?php echo $row["formid"]; ?>"> Go to the form</a></td>
This is the code that I used to retrieve a specific row from my database. the code does not show any errors but it also does not show the result. All I see is empty page. What is the problem here? I have been trying to solve for 1 week and can't find anything. I am beginner at PHP. Thanks in advance.
<?php
$conn = mysqli_connect("localhost","root","","son_fbe");
if (mysqli_connect_error()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
exit();
}
$formid = isset($_GET['formid ']) ? $_GET['formid '] : '';
if($sql= "SELECT formid,gonderilen,gonderen FROM derssaydirma WHERE formid = ?")
{
$stmt = $conn->prepare($sql);
$stmt->bind_param("i", $formid);
$stmt->execute();
$result = $stmt->get_result();
while ($row = $result->fetch_assoc()) {
echo $row[ 'formid'];
echo $row['gonderilen'];
echo $row['gonderen']; }
$stmt->close();
}
// show an error if the query has an error
else
{
echo "Error: could not prepare SQL statement";
}
?>
Upvotes: 1
Views: 95
Reputation: 8517
I think I found the mistake.. you having a blank inside your name when accessing the get array. $formid
will be "" and that's why your query is not working.
Change this line..
$formid = isset($_GET['formid ']) ? $_GET['formid '] : '';
to
$formid = isset($_GET['formid']) ? $_GET['formid'] : '';
Upvotes: 1