Note that there are some explanatory texts on larger screens.

plurals
  1. POecho not appearing when selecting a certain value
    text
    copied!<p>I have a assessment drop down menu below:</p> <pre><code>&lt;select name="session" id="sessionsDrop"&gt; &lt;option value="All"&gt;All&lt;/option&gt; &lt;option value="2"&gt;EOWOW&lt;/option&gt; &lt;option value="34"&gt;EOWOW&lt;/option&gt; &lt;/select&gt; &lt;select name="student" id="studentsDrop"&gt; &lt;option value="All"&gt;All&lt;/option&gt; &lt;option value="23"&gt;Jay Hart&lt;/option&gt; &lt;option value="32"&gt;Bubba Wright&lt;/option&gt; &lt;/select&gt; </code></pre> <p>Above is a simple drop down menu. I run a query below to get a selected student's details as well as get the selected assessment details. Now the selected assessment outputs the details fine with no problem, But the echo for selected student option does not work as if the user selects the <code>All</code> option, then echo <code>"&lt;p&gt;&lt;strong&gt;Students: &lt;/strong&gt;All Students - Total:(" .$selstudentnum . ")&lt;/p&gt;" . PHP_EOL;</code>. But the problem is that it does not display this echo if the <code>All</code> option is chosen. In fact it does not display an echo at all if the <code>All</code> option is chosen. I tried both <code>===</code> and <code>==</code> bu can't see what I am doing wrong</p> <pre><code>$selectedsessionqry = " SELECT SessionName, SessionDate, SessionTime FROM Session WHERE (SessionId = ?) "; global $mysqli; $selectedsessionstmt=$mysqli-&gt;prepare($selectedsessionqry); // You only need to call bind_param once $selectedsessionstmt-&gt;bind_param("i",$_POST["session"]); // get result and assign variables (prefix with db) $selectedsessionstmt-&gt;execute(); $selectedsessionstmt-&gt;bind_result($selSessionName,$selSessionDate,$selSessionTime); while ($selectedsessionstmt-&gt;fetch()) { echo "&lt;p&gt;&lt;strong&gt;Assessment: &lt;/strong&gt;" . $selSessionName . " - " . date('d-m-Y',strtotime($selSessionDate)) . " - " . date('H:i',strtotime($selSessionTime)) . "&lt;/p&gt;" . PHP_EOL; } $selectedsessionstmt-&gt;close(); $selectedstudentqry = " SELECT StudentAlias, StudentForename, StudentSurname FROM Student WHERE (StudentId = ?) "; global $mysqli; $selectedstudentstmt=$mysqli-&gt;prepare($selectedstudentqry); // You only need to call bind_param once $selectedstudentstmt-&gt;bind_param("i",$_POST["student"]); // get result and assign variables (prefix with db) $selectedstudentstmt-&gt;execute(); $selectedstudentstmt-&gt;bind_result($selStudentAlias,$selStudentForename,$selStudentSurname); $selectedstudentstmt-&gt;store_result(); $selstudentnum = $selectedstudentstmt-&gt;num_rows(); while ($selectedstudentstmt-&gt;fetch()) { if($_POST["student"] === 'All') { echo "&lt;p&gt;&lt;strong&gt;Students: &lt;/strong&gt;All Students - Total:(" .$selstudentnum . ")&lt;/p&gt;" . PHP_EOL; }else{ echo "&lt;p&gt;&lt;strong&gt;Students: &lt;/strong&gt;" . $selStudentAlias . " - " . $selStudentForename . " " . $selStudentSurname . "&lt;/p&gt;" . PHP_EOL; } } </code></pre>
 

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