Note that there are some explanatory texts on larger screens.

plurals
  1. PODisplaying multiple results from nested query?
    primarykey
    data
    text
    <p>I am writing an appointment book type thing, and i have a table for just possible times, so my first query is to list all of the times, then my 2nd table is scheduled appointments, which lists inside the table the appointment if its time and date match the time and date pulled from the first query.</p> <p>What i cannot figure out is if 2 entries on the 2nd query match the criteria to display both results at the same time.</p> <p>Heres my setup:</p> <pre><code>$query = mysql_query("SELECT * FROM times", $db); while ($row = mysql_fetch_array($query)){ $time = $row[time]; $query2 = mysql_query("SELECT * FROM appts WHERE time = '$time' AND date = '$date' ", $db); $apt = mysql_fetch_array($query2); $aptid = $apt[id]; echo "&lt;tr&gt;&lt;td&gt;"; echo date('h:i A', strtotime($row[time])); echo "&lt;/td&gt;&lt;td&gt;$apt[name]&lt;/td&gt;&lt;/td&gt;&lt;td&gt;$apt[phone]&lt;/td&gt;&lt;td&gt;$apt[phone2]&lt;/td&gt;&lt;td&gt;$apt[src]&lt;/td&gt;&lt;td&gt;$apt[coach]&lt;/td&gt;&lt;td&gt;$apt[comments]&lt;/td&gt;&lt;td&gt;"; if($aptid != ''){ echo "&lt;a href='index.php?date=$date&amp;apptid=$aptid&amp;action=delete'&gt;Delete&lt;/a&gt; &amp;nbsp; &lt;a href='index.php?date=$date&amp;apptid=$aptid&amp;action=x'&gt;X&lt;/a&gt; &amp;nbsp; &lt;a href='index.php?date=$date&amp;apptid=$aptid&amp;action=ns'&gt;NS&lt;/a&gt;"; } echo "&lt;/td&gt;&lt;/tr&gt;"; } </code></pre> <p>E.G.: 2 appointments set for 9am, its only displaying the first one. <a href="https://i.stack.imgur.com/orpq7.png" rel="nofollow noreferrer">See screenshot</a></p> <p><img src="https://i.stack.imgur.com/orpq7.png" alt="enter image description here"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload