I have a table which has names of club members against certain duties.Each member has a membership no identifiying them.
So table might look like :
id, event, date, ood,safety,ood_id,s_id.
I want to be able to pick out all duties for a given membership no.
query might look like.
$query = "SELECT *,DATE_FORMAT(date, '%a-%d-%m-%Y') AS dr from table where ood_id='$id' or s_id='$id'" ;
$result = @mysql_query ($query); // Run the query.
if (!$result) {
die("Query error! query text: $query<br />Error: " . mysql_error());
}
Now I have tried two different if conditionals
$name = '';
$duty = '';
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
if ($row['ood_id']==$id) {
$name= $row['ood'];
$duty='Race Officer';
}
if ($row['s_id']==$id) {
$name= $row['safety'];
$duty='Safety';
}
//table here with $name $duty
}//end of while loop
and other try
while($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
if ($row['ood_id']==$id) {
$name= $row['ood'];
$duty='Race Officer';
}elseif
($row['s_id']==$id) {
$name= $row['safety'];
$duty='Safety';
}else{
$name=FALSE;
$duty=FALSE;
}
//etc
Now the first conditional returns the last entry in the row and the second conditional returns the first record in the row.
How do I get all results per row?
I have been worrying away at this for some time and cannot see how to resolve.
Hope you can help