0

I have php checkboxes and wanted to send its values in mysql using submit button if the checkboxes are check.

 while($grow = mysqli_fetch_array($gresult)) {
    $gsymbol = $grow['symbol'];
    $gclose = $grow['value'];
    echo "<tr><td style='width: 100px;'>".$gsymbol."</td><td>".$gclose.</td<td><input type = 'checkbox' name = 'markings' value = '".$gsymbol."'></td></tr>"};

my question is do I have to echo a form or is there are more easier way. Thanks

2
  • You haven't closed your quotes properly, definitely want to check on that. Commented May 6, 2017 at 3:12
  • Thanks for pointing that out. @cosmoonot Commented May 6, 2017 at 3:34

1 Answer 1

1

Maybe you would prefer to put PHP code inside your HTML. This is ugly, but I think it's better than echo the HTML.

It could be something like this:

<table>
<?php
while($grow = mysqli_fetch_array($gresult)):
    $gsymbol = $grow['symbol'];
    $gclose = $grow['value'];
?>
<tr>
    <td style='width: 100px;'><?php echo $gsymbol; ?></td>
    <td><?php echo $gclose; ?></td>
    <td><input type = 'checkbox' name = 'markings' value = "<?php echo $gsymbol; ?>" ></td>
</tr>
<?php endwhile; ?>

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.