Issue when displaying results from randomization with Mysql row

So first off, I know this isn’t the best method to try and randomize Mysql Rows, but it works for now.

My only issue is that it displays like this:
{“0”:“random1”,“quote”:“random1”} when I want it to display like this
random1 (and I honestly don’t know why it displays two times :confused: )

My Code: (Moved to pastebin because it kept messing up)
https://pastebin.com/i9s2WHVW

No that is not my only PHP code, but that’s the only section for this issue. Also, if I did something wrong, please correct me as I’m still learning.

Arrays can be referenced by both their numeric index and, when they have them, their string (associative) index.

In this case fetch is getting both. If you need only one or the other the best thing to do is get only the one you need.

Using mysqli ?

http://php.net/manual/en/class.mysqli-result.php

*note

mixed fetch_array ([ int $resulttype = MYSQLI_BOTH ] )

“both” is the default

If all you want to do is display the value of the quote column, don’t json encode the entire array, just display $result(‘quote’)

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.