Reputation:
Trying to call function Sel_item
and pass it the fieldname1
variable as well as the id
. The passing of the id
works fine, but as soon as I try to pass the fieldname1
, it dies. Basically trying to pass the id
and the name of the person
in mysql database to another function.
$id = $row["id"];
$fieldname1 = $row["person_name"];
$fieldname2 = $row["check_in_butt"];
$fieldname3 = $row["date_time"];
$str = "";
if($fieldname2 == true) $str = "checked";
echo '<tr>
<td>'.$fieldname1.'</td>
<td><input type="checkbox"'.$str. 'onclick="Sel_item('.$id.,.$fieldname1.')" </td>
Upvotes: 0
Views: 69
Reputation: 33
I usually make it like this. Work for me
<?php
$id = $row["id"];
$fieldname1 = $row["person_name"];
$fieldname2 = $row["check_in_butt"];
$fieldname3 = $row["date_time"];
$str = "";
if($fieldname2 == true) $str = "checked";
?>
<tr>
<td><?= $fieldname1 ?></td>
<td><input type="checkbox" <?= $str ?> onclick="Sel_item('<?= $id ?>', '<?= $fieldname1 ?>')"></td>
</tr>
Upvotes: 1