I have the following code in php
$countryiso = mysql_query("SELECT distinct name as name FROM location_country where code NOT IN('A1','A2','AP','EU') order by name");
echo '<table>';
echo '<th>Country</th><th> Add/Remove </th>';
while ($row = mysql_fetch_assoc($countryiso)) {
echo '<tr>';
echo '<td>'. $row['name'] . '</td>';
echo '<td><form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"><input type="hidden" name="id" value="<?php echo $id; ?>" /><input type="checkbox" name="checkinsat" value="1"<?php if($data['checkinsat'] == '1') echo 'checked'; ?>/><input type="submit" ></form></td>';
echo '</tr>';
}
echo '</table>';
And i get the error
Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in don't know where i am mistaking.
The problem is your echo on line 7. Your doing <?php echo ... ?>
inside of an echo. You should instead concatenate the values into the string.
Instead of:
echo '<td><form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"><input type="hidden" name="id" value="<?php echo $id; ?>" /><input type="checkbox" name="checkinsat" value="1"<?php if($data['checkinsat'] == '1') echo 'checked'; ?>/><input type="submit" ></form></td>';
Try this:
$checked = ($data['checkinsat'] == '1') ? 'checked' : '';
echo '<td><form method="post" action="'.$_SERVER['PHP_SELF'].'"><input type="hidden" name="id" value="'. $id.'" /><input type="checkbox" name="checkinsat" value="1" '.$checked.'/><input type="submit" ></form></td>';
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments