IndianaGuy Posted January 14, 2017 Share Posted January 14, 2017 (edited) How do I make an entire row into an Array so I can send it back? this page was triggered from an Ajax request. Thank you Thank you $sql = "SELECT * FROM tblMedia WHERE Med_name= '$selected_expo' "; $result = mysqli_query($conn, $sql); if (mysqli_num_rows($result) == 1) { $row = mysqli_fetch_assoc($result); // make the entire row into an array so I can send it back to Ajax request page } else { echo "<h3 class='ui-title'>Multiple records found.</h3>"; } Edited January 14, 2017 by IndianaGuy Link to comment Share on other sites More sharing options...
Ingolme Posted January 14, 2017 Share Posted January 14, 2017 Loop through the rows and store them in an array: $results = array(); while($row = mysqli_fetch_assoc($result)) { $results[] = $row; } Your current code is vulnerable to hacking. You must use prepared statements. Link to comment Share on other sites More sharing options...
IndianaGuy Posted January 14, 2017 Author Share Posted January 14, 2017 Awesome and thank you. Also, thx for the link. I didn't know that and definitely will be neat to learn about it. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now