Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Your <code>echo</code> call is not needed in this place. Your statement only concatenates strings and does not print them.</p> <p>Additionaly it's not possible to use an <code>if</code> statement inside a string concatenation. However the if shortcut, the so called <a href="http://php.net/manual/en/language.operators.comparison.php#language.operators.comparison.ternary" rel="nofollow"><em>ternary</em></a> operator is applicable in this situation.</p> <p>And as pointed out in an other answer there is also a space missing before the <em>selected</em> part.</p> <pre><code>for($i=0;$i&lt;count($arrSql);$i++) { $opt .= "&lt;option " .($_GET['pId'] == $arrSql[$i][0]) ? "Selected" : "" ."value=" .$arrSql[$i][0] . "&gt;" .$arrSql[$i][1]. "&lt;/option&gt;"; } </code></pre> <p>An alternative using <code>if</code> that might be more clear is:</p> <pre><code>for($i=0;$i&lt;count($arrSql);$i++){ $opt .="&lt;option "; if ($_GET['pId'] == $arrSql[$i][0]){ $opt .= "Selected"; } $opt .= "value=" .$arrSql[$i][0]. "&gt;" .$arrSql[$i][1]. "&lt;/option&gt;"; } </code></pre> <p>If you want to, you can even inline the array accesses into the string by using curly braces leading to this last line: (more <a href="http://php.net/manual/en/language.variables.variable.php" rel="nofollow">here</a>)</p> <pre><code>$opt .= "value=${$arrSql[$i][0]}&gt;${$arrSql[$i][1]}&lt;/option&gt;"; </code></pre> <p>For the future you might want to enable error output in your scripts. This would have indicated the main error.</p>
    singulars
    1. This table or related slice is empty.
    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.
    1. VO
      singulars
      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