我在使用带有括号的单引号和双引号时遇到问题
我有任何错误,如果条件请任何一个帮助
$resonjob['Post_type']='Jobs';
$resonjob['reason']='reasonstatus.php?job_id='.$row['job_id'];
$nestedData[] = '<select onchange="reasonstatus(this.value)" style="width:80px;">
<option value="'.$resonjob['reason'].'&type='.$resonjob['Post_type'].'&status=1" '.if($row['status']=='1'){.' selected;'.}.'>Active</option>
<option value="'.$resonjob['reason'].'&type='.$resonjob['Post_type'].'&status=2" '.if($row['status']=='2'){.' selected;'.}.' >Inactive</option>
</select>';
答案 0 :(得分:0)
<?php
$resonjob['Post_type']='Jobs';
$resonjob['reason']='reasonstatus.php?job_id='.$row['job_id'];
$nestedData[] = '<select onchange="reasonstatus(this.value)" style="width:80px;">
<option value="'.$resonjob['reason'].'&type='.$resonjob['Post_type'].'&status=1" '.($row['status']=='1' ? 'selected' : '').'>Active</option>
<option value="'.$resonjob['reason'].'&type='.$resonjob['Post_type'].'&status=2" '.($row['status']=='2' ? ' selected' : '').' >Inactive</option>
</select>';