0

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';
        }
    }

}
?>
2
  • Did you check if your additems script is running properly at all? Did you manually check the DB if your hobbo category is actually there? Commented Nov 18, 2014 at 14:53
  • I think we should remind stackoverflow users that this site is not a bug fixing forum. You should always ask for global answers that could also benefit another person. Commented Nov 18, 2014 at 15:00

1 Answer 1

2

Here is your issue:

if (isset($_POST['name']) && isset($_POST['game'])) {

All you are posting is name not game.

 $.post('name.php', {name: name}, function(data) {
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.