Hello! Please help. There is the following in scripts.js:
$.ajax({ type: "POST", url: "Makers_details.php", data:{ username: $("#username").val(), }, success: function (data) { $("#but3").html(data); } }); in the php file, the actual request in the database and the formation of the response in html. Here is the code:
<?php $link = mysql_connect('localhost', 'root', '') or die('Не удалось соединиться: ' . mysql_error()); mysql_select_db('stepbystep') or die('Не удалось выбрать базу данных'); // Выполняем SQL-запрос $query = "SELECT * FROM firm where Name like '%".$_REQUEST['username']."%'"; $result = mysql_query($query) or die('Запрос не удался: ' . mysql_error()); // Выводим результаты в html echo "<table id='mytable'>\n"; while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "\t<tr>\n"; foreach ($line as $col_value) { echo "\t\t<td>$col_value</td>\n"; } echo "\t</tr>\n"; $lat=$row['lat']; $lng=$row['lng']; $rows[] = $line; } echo "</table>\n"; return $result; ?> Actually everything works - in # but3 the result of the query is displayed from the database. But I just can't figure out how to continue working in ajax (right after the $ ("# but3") line. Html (data);) with the result of the query ... That is, I shoved the result into # but3, but I want to continue in the loop work with the result of the query ... Ie the result is roughly a table, so I need to run through this table and get data from each cell and say the same write them again in # but4 for example
data, for example,eachapi.jquery.com/jquery.each - Aleksey Shimansky