<?php
$query = mysql_query("select * from `tbl_student`");
while($data = mysql_fetch_array($query))
{
        $output[] = array ($data[0],$data[1],$data[2],$data[3],
            '<select class="form-control select1" id="'.$data[0].'">
            <option 'if(----){'selected'}'>asd</option>
            <option >dasd</option>
            <option>asd</option>
            </select>');
}
echo json_encode($output);
?>

<!--here code of if() throw error-->

Help Me guys....

Invalid syntax. What do you want to happen?

<option ' . ($a == $b ? 'selected' : '') . '>asd</option>

select option which is set in database

Thxs Bro

Thxs Bro

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.