how to view the selected item on the other webpage.

0 Nathan Moland · July 25, 2015
Sorry it's not displaying code when i use the code when posting a topic.

My code works but its getting 2 result not the only row I click.
i have this code in index.php --------------------------------------------

<form method="POST" action="view.php">
<?php
    $sqlQuery = mysql_query("SELECT fname FROM info");

    while ($rows = mysql_fetch_array($sqlQuery)){
            echo "<input type='text' value='".$rows['fname']."' name='fname'>";
            echo "<input type='submit' value='Show more info' name='submit' class='btn btn-info'><br>"; 
    }
?>
</form>


and this code for view.php ----------------

<table border='1' width='50%'>
<?php
$viewQuery = mysql_query("SELECT * FROM info WHERE fname LIKE '%".$_POST['fname']."%' ");

echo "<tr>";
echo "<td>First Name</td>";
echo "<td>Last Name</td>";
echo "<td>Age</td>";
echo "</tr>";
while ($rows = mysql_fetch_array($viewQuery)){
echo "<tr>";
echo "<td>";
echo $rows['fname'];
echo "</td>";
echo "<td>";
echo $rows['lname'];
echo "</td>";
echo "<td>";
echo $rows['age'];
echo "</td>";
echo "</tr>";
}

?>
</table>



Post a Reply

Replies

Oldest  Newest  Rating
0 Nathan Moland · July 25, 2015
Thanks but my problem now is even i click the first data show in index.php it will output the last data in view.php
  • 1

PHP

106,982 followers
About

Server-side, HTML embedded scripting language used to create dynamic Web pages.

Links
Moderators