$(document).ready(function() {
$(document).ready(function () {
var request = $.ajax({
url: 'inc/everything.php',
type: "POST",
dataType: "html",
success: function (data) {
if ("row:has('tacobell');") {
$('#oriental').html(name);
}
}
});
});
.encasing {
width: 193px;
height: 400px;
float: left;
}
.result-ingredient {
z-index: 13;
width: 150px;
margin: 10px;
float: left;
}
<div class=" encasing">
<img class="result-ingredient" src="img/chicken.png">
<div id ="chicken"> </div>
</div>
<div class=" encasing">
<img class="result-ingredient" src="img/beef.png">
<div id ="beef"> </div>
</div>
<div class=" encasing">
<img class="result-ingredient" src="img/pork.png">
<div id ="pork"> </div>
</div>
<div class=" encasing">
<img class="result-ingredient" src="img/oriental.png">
<div id ="oriental"> </div>
</div>
<?php
include 'database.php';
$sql = "SELECT * FROM `answers` WHERE 1 ORDER BY `choices` ASC ";
$result = mysql_query($sql, $conn);
if (!$result) {
var_dump($result);
$message .= 'DB Error occured';
die($message);
}
while ($row = mysql_fetch_assoc($result)) {
echo "Name:" . ($row['name']) . " " . "choices:" . $row['choices'];
echo "<br>";
}
?>
There has to be a better way to display all of those queries in html. I want the persons name to appear under the item they chose earlier, which corresponds to a value in the database. Its not exactly working and i was wondering if i'm just going about this the wrong way?
- Is there a way to display and sort multiple queries with less code than i'm using?
- whats the best way to pick up the resulting code in ajax to be sent to html?
edit:
i don't know how to get ajax to pick up the right data i want. My idea was to check if any of the rows has a certain value then just post the names from that but its not working.
this is what the database prints out now
Name: trisha choices: chicken,tacobell
Name: sarah choices: chicken,mcrab,sriracha,tacobell
Name: rachel choices: chicken,peas,corn,lettuce,mcrab,sriracha,tacobell