mercredi 31 mai 2017

how can i select one row from table in MySQL database alone in anthor page with php?

i create questions and answers system with php and i created page have all questions that recorded in table named questions and make beside every question reply link which directed to answer page, so i need to select this question that i want to comment on it from table and show it single in the answer page to make comments on it , how can i make this with php?

this is my questions page code

<?php  session_start();  $connection = new mysqli('localhost','root','','questionssystem') or die ("Database connection failed"); /*start questions*/$sql = "SELECT question_text FROM question"; $result = $connection->query($sql); echo'<h2>Questions page</h2>'; if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
    echo '<form action="answers.php" method="post">';
    echo '<div class ="container">';
    echo "<p>question: " . $row["question_text"];
    echo '<span class="psw">If You want to reply this Question , please <a href="http://localhost:8080/questionssystem/answers.php" target="_self">Reply</a></span>';
    echo '</div>';
    echo '</form>'; } }else { echo "0 results";} /*end questions*/ $connection->close(); ?>

<html>
<head>
<link rel="stylesheet" type="text/css" href="css_file.css">
</head>
<body></body></html>




Aucun commentaire:

Enregistrer un commentaire