mercredi 10 novembre 2021

Display one-column data randomly in MySQL

I have a table with a number of records. By dragging and dropping the text in the input, the user determines which text is for which input or image.

Normally all recessions are displayed in order and it is clear which answer is for which image. I want the column response data to be randomly placed in front of each image.

Note that I do not want every row to be displayed randomly, but I want the data in a column to be displayed randomly.

id answer image
1 test1 test1.jpg
2 test2 test2.jpg

I want Test1 Title to be displayed in front of test2 image and Test2 Title to be displayed in front of test1 image.

I used the following code but it did not change:

$gg1 = "SELECT * FROM groupanswer WHERE id='$nowid' ";
$gg2=mysqli_query($conn,$gg1);
while($gg3=mysqli_fetch_assoc($gg2)){
    $iii=$gg3['answer'];
    $aa = array($iii);
    $key = array_rand($aa);
}

I attached the photo:

enter image description here




Aucun commentaire:

Enregistrer un commentaire