I'm workings hours to find a solution to fix a problem
I'm using 2 pages: on the first page additem.php I want to add some items to right section.
I've a database where i've ordered all items, If i search for 'boots' the page won't refresh and I will get all items related to 'boots', but the problem is I do not get anything. For example Im on the page additem.php?i=Hobbo&g=CATEGORY I want to add some items to 'Hobbo' Which is in category 'CATEGORY' and I search for 'boots' I want to select everything that sounds like 'boots'
Search form:
<?php
if (isset($_GET['i']) && isset($_GET['g']))
{
$i = $db->real_escape_string(trim($_GET['i']));
$g = $db->real_escape_string(trim($_GET['g']));
$gi = $db->query("SELECT * FROM log_items INNER JOIN log_mobs ON log_items.game = log_mobs.game WHERE log_items.game = '" .$g. "' AND log_mobs.game = '" .$g. "' AND log_mobs.name = '" .$i. "'") or die($db->error);
$gk = $db->query("SELECT * FROM log_items WHERE game = '" .$g. "'") or die($db->error);
if($gi->num_rows==0){
echo '<p>This mob is not created yet on this game!</p>';
} else {
?> <p>
Item: <input type="text" class="edit" name="name" method="post" id="name"><br><br>
<input type="hidden" name="game" id="game" value="<?php echo $g ?>"/>
<br>
<input type="submit" id="name-submit" value="Grab item">
<div id="name-data"></div>
<script src="http://code.jquery.com/jquery-1.8.0.min.js"></script>
<script src="js/global.js"></script>
</p>
<?php
}
}
?>
This is my Jquery:
$('input#name-submit').on('click', function() {
var name = $('input#name').val();
if ($.trim(name) != '') {
$.post('name.php', {name: name}, function(data) {
$('div#name-data').text(data);
});
}
});
This is the page where I actually need results from but I don't get anything
<?php
require '../config.php';
require_once '../core/init.php';
?>
<?php
if (isset($_POST['name']) && isset($_POST['game'])) {
$naame = $db->real_escape_string(trim($_POST['name']));
$gaame = $db->real_escape_string(trim($_POST['game']));
$query_90 = "SELECT * FROM log_items
INNER JOIN log_mobs ON log_mobs.game = log_items.game
WHERE log_items.name like '%$naame%'
AND log_items.game = '" .$gaame. "'";
$result_90 = $db->query($query_90) or die ($db->error());
$n_90 = $result_90->num_rows;
if($n_90 == 0) {
echo 'no results';
} else {
while ($row_90 = $result_90->fetch_object()) {
echo htmlspecialchars($row_90->name);
echo 'ok';
}
}
}
?>