How come the second li tag breaks the {} in my code, whilst the first li tag and the a tag are both fine? As soon as I comment out the echo $RESULT['full_name']);
in the second li tag the code works perfectly and I don't get why.
The error that comes up is the following:
Parse error: syntax error, unexpected ')', expecting ',' or ';' in /Applications/XAMPP/xamppfiles/htdocs/ajax.php on line 27
<?php
// add name to variable using post
if (isset($_POST['search'])) {
include "db.php";
$name = $_POST['search'];
$query = "SELECT full_name FROM Users WHERE full_name LIKE '%$name%' LIMIT 5";
if ($result = mysqli_query($db, $query)) {
echo json_encode(array('success'=>1));
} else {
echo json_encode(array('success'=>0));
}
echo '<ul class = "results">';
while ($RESULT = mysqli_fetch_array($result)) {
?>
<li onclick = 'fill("example")'></li>
<li onclick = 'fill("<?php echo $RESULT['full_name']); ?>")'>
<a><?php echo $RESULT['full_name']; ?></a>
</li>
//use name to query similiar names and assign to result variable using mysqli_fetch_array
//based on that reult, loop through all the rows which are simililiar and echo their full name in that list in an li
<?php
}
}
?>
</ul>
(thanks a ton in advance)