0

I have an html dropdown list which gets the data from mysql table. I have a second table where I can see which equipment has already been selected for another user for the day.

My question is:

  • How do I not display that equipment (BowCode and its Information) and instead go to the next entry.

  • It's possible that multiple equipment have been already selected for the day for other users.

My code:

$BowDropDown = mysqli_query($mysqli, "SELECT * FROM equipment order by BowCode ASC");

while ($row = $BowDropDown->fetch_assoc()){

    if($row['BowCode'] != $BowDropDownDayCheck){}

    if($row['Recurve'] =='1'){
        $value = 'Recurve';
    } else if ($row['Compound'] == '1'){
        $value = 'Compound';
    } else if ($row['Longbow'] == '1'){
        $value ='Longbow';
    }
echo "<option value= " . $row['BowCode'] . ">" . $value . " - " . $row['BowCode'] . " - " . $row['Info'] . " - " . $row['Poundage'] . "</option>";
}

I don't know if it is possible or not but maybe the values that are displayed in the dropdown can be visualised like a table view.

table from where the Equipment is stored

tabele where the users are stored with the Equipment the use for the day

Mark
  • 7
  • 5

1 Answers1

0

This one does the job

SELECT 
   b.id, b.BowCode, b.Info
FROM Equipment AS b
LEFT JOIN 
  (SELECT a.BowID
   FROM comeandtrydaysparticipant AS a
   WHERE a.`date`="2018-01-26"
   GROUP BY a.BowID
  ) AS c
ON c.BowID = b.BowCode
WHERE c.BowID IS NULL
;

It selects all items not in comeandtrydaysparticipant for a particular day.

And the proof is in the pudding

Michel
  • 4,076
  • 4
  • 34
  • 52
  • cool and now when i want to echo the values out in php do i do b.BowCode ? – Mark Jan 19 '18 at 16:20
  • Just `BowCode`. The `b.` is an alias for the table Equipment (as `a.` is for that other, very fance tablename ;), it just saves typing. – Michel Jan 19 '18 at 16:25