Hello Experts,
I am stuck in database query. Well i am making a page which fetch all my database value. For which below is my code:
[code=php]
<?php
$con=mysqli_connect(“localhost”,”root”,””,”test”);
// Check connection
if (mysqli_connect_errno())
{
echo “Failed to connect to MySQL: ” . mysqli_connect_error();
}
$result = mysqli_query($con,”SELECT * FROM testimonials”);
echo “<table border=’1′>
<tr>
<th>ID</th>
<th>Name</th>
<th>Email_id</th>
<th>Review_Title</th>
<th>Review</th>
<th>Date</th>
<th>Post</th>
</tr>”;
while($row = mysqli_fetch_array($result))
{
echo “<tr>”;
echo “<td>” . $row[‘id’] . “</td>”;
echo “<td>” . $row[‘name’] . “</td>”;
echo “<td>” . $row[’email_id’] . “</td>”;
echo “<td>” . $row[‘review_title’] . “</td>”;
echo “<td>” . $row[‘review’] . “</td>”;
echo “<td>” . $row[‘date’] . “</td>”;
echo “<td>” . “<a href=’row_test.php’>Post</a>”. “</td>”;
echo “</tr>”;
}
echo “</table>”;
mysqli_close($con);
?>
This is done properly but in my last column “POST” der are links.What i want is wen click on one particular row link on the next page it must display my selected row contents. I tried the below code so far:
[code=php]
<?php
$con=mysqli_connect(“localhost”,”root”,””,”test”);
if (mysqli_connect_errno())
{
echo “Failed to connect to MySQL: ” . mysqli_connect_error();
}
$txt= $_POST[id];
$result = mysqli_query($con,”SELECT * FROM testimonials where id=3″);
while($row = mysqli_fetch_array($result))
{
echo “<tr>”;
echo “<td>” . $row[‘name’] . “</td>” .”<br>”;
echo “<td>” . $row[‘review_title’] . “</td>”;
echo “<td>” . $row[‘review’] . “</td>”;
echo “</tr>”;
}
echo “</table>”;
mysqli_close($con);
?>
But this only output after mentioning the “id” ie: id=3, but i want it automatically after clicking on the link for the selected row.
Please some one can help me out with the code…. ?
Any help is appreciated.