I'm new to PHP and HTML, I have a function that is on a different class for where I fetch the database value and make the radio button set to selected if it contains the value.
public function getstatusradio () {
$sql = "SELECT ticketstatus FROM ticketpractice WHERE id = 6";
$result = $this->connect()->query($sql);
if ($result-> rowCount() > 0) {
while ($row = $result->fetch()){
echo "<input type='radio' name='status' <?php if($row['ticketstatus']=='new') {echo 'checked';} ?> value='new '>new";
echo "<input type='radio' name='status' <?php if($row['ticketstatus']=='processing') {echo 'checked';} ?> value='processing'>processing";
}
}
}
and here is as I declare the code inside my HTML page
<div>
<?php
$object = new myclass;
$object->getstatusradio();
?>
</div>
this is the result that I want to achieve where the correct radio button is selected according to the database values "new" and "processing." in this example the database value is "processing.
As of now this the result I have
"Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting '-' or identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING)"