I have an array of values queried from a database, $roundsarray
.
Another query returns a set of values which are some of the same in the array. However, rather than displaying the values, I want to display them as a key. My code is as follows:
$datarounds=mysql_query("SELECT DISTINCT eventID FROM results WHERE (eventID BETWEEN '$firstevent' AND '$lastevent') AND compId='$compId' AND teamId='$teamid' AND (eventSession='R' OR eventSession='R1' OR eventSession='R2' OR eventSession='R3') AND driverId='$driversource' ORDER BY eventID", $CONNECTW);
while($row=mysql_fetch_row($datarounds))
{
$roundid=$row[0];
foreach ($roundsarray as $k => $value)
{
if ($roundid==$value) { $rounddisplay=$k+1; }
$roundpack .= "$rounddisplay,";
}
The $datarounds
query provides the event ids, and what i am trying to do is to display that a specific event is the 3rd, 4th, 12th or whatever in the array (the $k+1
is to account for the first value of the array being key 0).
However, $rounddisplay
is always returned empty and I can't figure out what I am doing wrong. Thank you for any help!