0

I inserted data into phpmyadmin and have the select function:

$twitterfingers="select * from answers equivalent where tweet like 
'%".$question."%' limit 1";
$state2=$theDatabase->prepare($twitterfingers);
$state2->execute();
$tweets=$state2->fetchAll();
$state2->closeCursor();
?>`

The same tweets keep appearing, I would like a random shuffle of the tweets of appear. Also, it only works when a single word is typed into variable, not a phrase.

Thanks.

chris85
  • 23,846
  • 7
  • 34
  • 51
  • 1
    NOTE: `phpMyAdmin` is an application written in PHP that allows for easy maintenance and manipulation of a **MYSQL** or maybe **MariaDB** database – RiggsFolly Apr 08 '17 at 16:24
  • You are using prepared statements incorrectly. You need to split the phrase and search for each term individually. For random row see http://stackoverflow.com/questions/19412/how-to-request-a-random-row-in-sql. – chris85 Apr 08 '17 at 16:28
  • If you want to search for multiple words in tweets, you probably should use a full-text index. – Barmar Apr 08 '17 at 16:41

1 Answers1

0

you can use this line of code to get the data:

$twitterfingers="select * from answers equivalent where tweet like '%".$question."%' ORDER BY RAND() limit 1";

  • 1
    This is already explained in the duplicate question, there's no need to post it as an answer. – Barmar Apr 08 '17 at 16:40