I'm using this query to return all profile info of a player and also all of the times associated with that player from the EVENT_DATA table. However, I'm only being returned one event time per player even though each player has more than one time in the database. The player's name is being used in a search box, and that's why the WHERE clause includes the name entered into the search. Does anyone recommend that I run two separate queries; one for the profile and one for the times? The profile data comes up ok, but it's just the event data only being limited to one row. This is my code, and I appreciate any suggestions.
<form class='form-inline quick-search-form' role='form'>
<div class='form-group'>
<input type='text' id='name' name='name' class='form-control' placeholder='Driver name'>
</div>
<button type='submit' id='quick-search' class='btn btn-custom'><span class='glyphicon glyphicon-search custom-glyph-color'></span></button>
</form>
$sql = "SELECT EVENT_DATA.personaId, EVENT_DATA.ID AS event_id, EVENT_DATA.alternateEventDurationInMilliseconds, EVENT_DATA.EVENTID, EVENT_DATA.rank, EVENT_DATA.carId, PERSONA.iconIndex, PERSONA.cash, PERSONA.level, PERSONA.created, PERSONA.score, PERSONA.motto, PERSONA.repAtCurrentLevel, PERSONA.rep, PERSONA.name AS p_name
FROM EVENT_DATA
INNER JOIN PERSONA ON EVENT_DATA.personaId = PERSONA.ID
WHERE (PERSONA.name = '".@mysqli_real_escape_string($conn, $_GET['name'])."' AND EVENT_DATA.EVENTID = '43' AND EVENT_DATA.alternateEventDurationInMilliseconds > '0')";
if ($result = mysqli_query($conn, $sql)){
if(mysqli_num_rows($result) > 0) {
while ($row = mysqli_fetch_array($result)){
$name = $row['p_name'];
$avatarimg = mysqli_real_escape_string($conn, $row['iconIndex']);
$cash = mysqli_real_escape_string($conn, $row['cash']);
$name = mysqli_real_escape_string($conn, $row['p_name']);
$level = mysqli_real_escape_string($conn, $row['level']);
$createddate = mysqli_real_escape_string($conn, $row['created']);
$driverscore = mysqli_real_escape_string($conn, $row['score']);
$motto = mysqli_real_escape_string($conn, $row['motto']);
$repcurrent = mysqli_real_escape_string($conn, $row['repAtCurrentLevel']);
$reptotal = mysqli_real_escape_string($conn, $row['rep']);
$personaid = $row['personaId'];
$eventid = $row['EVENTID'];
$milliseconds = $row['alternateEventDurationInMilliseconds'];
Then, I used php echo for each of the variables, and outputted them in a table.
Thank you!