Jump to content

[SOLVED] PARSE error please suggest


Guest upirate

Recommended Posts

Guest upirate

$resultsperpage="<form name='form1' method='post' action='something.php'>

  <label>

                          Results per page <select name='rpp' id='rpp' onChange='this.form.submit();'>

[line 855] >-->  <option value='10' ".if (!(strcmp('10', $rpp))) {echo 'SELECTED';} .">10</option>

    <option value='20' '.if (!(strcmp('20', $rpp))) {echo 'SELECTED';} .'  >20 </option>

    <option value='50' '.if (!(strcmp('50', $rpp))) {echo 'SELECTED';} .' >50 </option>

    <option value='100' '.if (!(strcmp('100', $rpp))) {echo 'SELECTED';} .' >100 </option>

  </select>

  </label>

</form>

";

 

 

error:   

Parse error: parse error, unexpected T_IF in /home/pricetak/public_html/results.php on line 855

Link to comment
https://forums.phpfreaks.com/topic/41807-solved-parse-error-please-suggest/
Share on other sites

maybe it's because you're trying to echo something inside of a string definition?  I'm not much for complex mixing of statements but this is how I'd do it...

isSelected = function(num) {
    if (!(strcmp(num, $rpp))) {
        return " SELECTED";
    } else {
        return "";
    }
}
$resultsperpage="<form name='form1' method='post' action='something.php'>
<label>
    Results per page <select name='rpp' id='rpp' onChange='this.form.submit();'>
    <option value='10'" .isSelected('10'). ">10</option>

// etc, etc.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.