Я использую php для генерации неопределенного количества div, и каждый div форматируется одинаково, но имеет различную заполняемую информацию. Моя проблема в том, что я не могу понять, как определить, в каком div находится нажатая кнопка? Я хотел бы иметь возможность узнать $ row ["bar_name"] для нажатой кнопки. то есть, если нажата понедельник, мне также нужно знать, в каком $ row ["bar_name"] находилась кнопка понедельника. Я изменил форматирование того, как генерируется div, потому что его легче читать, когда он находится в формате html, по сравнению с выводом в php. Любая помощь приветствуется, спасибо!
// how the div is being generated (slightly altered for easier readability)
<?php
if (mysqli_num_rows($result) > 0) {
while($row = mysqli_fetch_assoc($result)) {
//this is echoed as one string in my actual code
<div id='" . $row["bar_name"] . "'>
<h3 id='barTitle' class='bar'>" . $row["bar_name"] . "</h3>
<h6 id='subTitle'>". $row["hourStart"] . "-" . $row["hourEnd"] . " | " . $row["area"] . "</h6>
<table>
<tr>
<th class='dowb'> <button id='monday'> Monday </button></th>
<th class='dowb'> <button id='tuesday'> Tuesday </button></th>
<th class='dowb'> <button id='wednesday'> Wednesday </button></th>
<th class='dowb'> <button id='thursday'> Thursday </button></th>
<th class='dowb'> <button id='friday'> Friday </button></th>
<th class='dowb'> <button id='saturday'> Saturday </button></th>
<th class='dowb'> <button id='sunday'> Sunday </button></th>
<br>
</tr>
</table>
<br>
<table>
<tr>
<th class='barInfo'> <strong> Drinks: </strong></th>
<th class='barInfo'> <strong> Food: </strong></th>
</tr>
<tr>
<th class='barInfo' id="dowDrink"> Things to drink</th>
<th class='barInfo' id="dowFood"> Things to eat</th>
</tr>
</table>
<a href='" . $row["profile_page"] . "'> More Info </a>
<hr>
</div>
}
}
?>
//ajax (its the same code with the names switched out for monday-sunday)
$("#monday").click(function() {
var monday = true;
$.ajax({
type: "POST",
dataType: "html",
url: "barMapPhp.php",
data: {monday: monday},
success: function(result){
jQuery("#dowd").html(result);
}
});
});
// php code that ajax is sent to but im unsure how to proceed from here if i cant specify which $row["bar_name"] div that the button was in
if(isset($_POST["monday"])){
???
}