Friends, the situation is as follows:
With AJAX, I make a request to upload data from a database.
var obj; $.ajax({ type: "POST", url: "/functions/dbfunctions.php", data: { type: 7, id: id, } }).done(function(msg){ obj = jQuery.parseJSON(msg); }); Here is php
$result = mysql_query("SELECT * FROM multiplys WHERE sale = '$action'"); $data_multiplys = mysql_fetch_array($result); echo json_encode($data_multiplys); Since not one line is output from the database, but not a certain number, since I don’t know how many records it will find, as a result, I don’t know how to create a cycle on the processing side that could go through all the records that will be in the resulting line. Please help create a loop with which I can parse the json returned to me with arrays
EDITIONS
Here is the complete request code:
$.ajax({ type: "POST", url: "/functions/dbfunctions.php", data: { type: 7, id: id, } }). done (function (msg) {
ЗДЕСЬ НУЖНО ЦИКЛОМ ОБРАБОТАТЬ JSON }
});
PHP itself is in the current state
//load Multiply data if($_POST['type']==7) { $action = $_POST['id']; $result = mysql_query("SELECT * FROM multiplys WHERE sale = '$action'"); // ЗДЕСЬ МОЖЕТ БЫТЬ 10 записей $data_multiplys = mysql_fetch_array($result); echo json_encode($data_multiplys); }