Jump to content

problem with php/mysql search feature


afallingpanda
Go to solution Solved by afallingpanda,

Recommended Posts

Hello guys, so let me give some information, i have a database which is storing some information, and im building a simple search feature which just searches for particular things in the database. however something is not working, here is my code and the results:

 


if (isset($_POST['usernamesearch'], $_POST['gamesearch'], $_POST['modesearch'], $_POST['mapsearch'])){
$usernamesearch = $_POST['usernamesearch'];
$gamesearch = $_POST['gamesearch'];
$modesearch = $_POST['modesearch'];
$mapsearch = $_POST['mapsearch'];


class Leaderboarded{
public function fetch_all(){
global $pdo; global $usernamesearch; global $gamesearch; global $modesearch; global $mapsearch;


$query = $pdo->prepare('SELECT * FROM leaderboards WHERE username="?" AND game_id="?" AND mode_id="?" and map_id="?"');


$query->bindValue(1, $usernamesearch);
$query->bindValue(2, $gamesearch);
$query->bindValue(3, $modesearch);
$query->bindValue(4, $mapsearch);


$query->execute();


return $query->fetchAll();
}
}
$leaderboarded = new Leaderboarded;


$leaderboardeds = $leaderboarded->fetch_all();


<table cellpading=0 cellspacing=0 border=1>
<tr>
<th>playerID</th>
<th>Username</th>
<th>Rank</th>
<th>System</th>
<th>Wins</th>
<th>Losses</th>
<th>Kills</th>
<th>Returns</th>
<th>Verified</th>
<th>Revives</th>
<th>Downs</th>
<th>Taints</th>
<th>Rounds</th>
<th>players</th>
<th>LastRoundTime</th>
<th>TotalTime</th>
<th>mode_id</th>
<th>map_id</th>
<th>game_id</th>
</tr>


<?php 
foreach ($leaderboardeds as $leaderboarded){ ?>
<tr>
<td><?php echo $leaderboarded['player_id']; ?></td>
<td><?php echo $leaderboarded['username']; ?></td>
<td><?php echo $leaderboarded['rank']; ?></td>
<td><?php echo $leaderboarded['system']; ?></td>
<td><?php echo $leaderboarded['wins']; ?></td>
<td><?php echo $leaderboarded['losses']; ?></td>
<td><?php echo $leaderboarded['kills']; ?></td>
<td><?php echo $leaderboarded['returns']; ?></td>
<td><?php echo $leaderboarded['verified']; ?></td>
<td><?php echo $leaderboarded['revives']; ?></td>
<td><?php echo $leaderboarded['downs']; ?></td>
<td><?php echo $leaderboarded['taints']; ?></td>
<td><?php echo $leaderboarded['rounds']; ?></td>
<td><?php echo $leaderboarded['players']; ?></td>
<td><?php echo $leaderboarded['last_round_time']; ?></td>
<td><?php echo $leaderboarded['total_time']; ?></td>
<td><?php echo $leaderboarded['mode_id']; ?></td>
<td><?php echo $leaderboarded['map_id']; ?></td>
<td><?php echo $leaderboarded['game_id']; ?></td>
</tr>
<?php
} ?>
</table> </div><?php
}


} ?>

 

Now.. this is what is outputted on the screen:


 

As you can see i think the problem is that the last part where the data is ment to be outputted, isnt working. but why? any help will be very appretiated, thanks

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.