How to display data from Mysql table using dynamic links ? [Solved/Closed]

Posts
23
Registration date
Sunday February 17, 2019
Status
Member
Last seen
March 2, 2019
-
Hello,
I search for some tutorials about this subject but I don't find any.
This is my php link on page1.php :

<a href="page2.php?word=car">car</a>

And this is the operation I try to execute on page2.php :

$sql = "SELECT * FROM mytable WHERE word='$word'";

I also tried using word='$_GET['word']' but I only obtain syntax errors.
And this is my code on page2.php :

<?php
$con=mysqli_connect("localhost","root","my password","my database") or die(mysql_error());
$output = ' ';
$word = $_GET['word'];

$sql = "SELECT * FROM mytable WHERE word='$word'";
$query = mysqli_query($con,$sql)

$count = mysqli_num_rows($query);

while($row = mysqli_fetch_array($query)) {
$word = $row['word'];
$definition = $row['definition'];
$id = $row['id'];

$output .= '<div>'.$word.' '.$definition.'</div>';
}
?>

Thank you.
See more 

1 reply

Posts
12780
Registration date
Monday June 3, 2013
Status
Moderator
Last seen
August 8, 2019
1223
0
Thank you
Take a look at Mr Greens code example here.
rab_del
Posts
23
Registration date
Sunday February 17, 2019
Status
Member
Last seen
March 2, 2019
-
Hello,
I finally came to a conclusion, the problem was not the code, the problem was wamp server because the same code works perfectly on 000webhost server so I have a question, is wamp server really reliable to learn and make tests ?

As an alternative I downloaded xamp server for windows but during the insalation I get a warning message about an eventual conflict between xamp and my antivirus, I don't understand this message, therefore I don't dare continue the installation process.

Best regards,