Page 1 of 1

embedding mysql output in checkbox

Posted: Tue Oct 20, 2015 11:08 am
by publicGenome
Hi There,
I've browsed different pages, watched videos; but to no success I've been able to figure out on how to show mysql output in a checkbox. I'm pulling data from mysql, displaying them in a tabular format, using td, tr.
My goal is to select few entries, and send them to another page for processing. But I'm unable to get the value displayed here on php-html page. :(

I see a empty td with check box, my value isn't shown. Forward primer is shown if I echo it, but not displayed on the table.

Code: Select all

		foreach ($result as $row){
			echo "<tr>";	//row
			echo "<td>"."<input name=study[] disabled value=".$row['study']." </td>";
			$value_for=$row['forward_primer'];
			
			echo "<td> <input type=checkbox name=check[] value=$value_for/></td>"; //show check box here
			echo "<td>"."<input name=reverse_primer disabled value='".$row['reverse_primer']."'  /></td>";
			echo "<td>"."<input name=seq_platform disabled value='".$row['seq_platform']."' </td>";
			//'' to have spaces shown
			
			echo "</tr>"; //row ends
		}

Re: embedding mysql output in checkbox

Posted: Tue Oct 20, 2015 11:24 am
by Celauran
Attributes need quotes around their values.

Code: Select all

<?php foreach ($results as $row): ?>
<tr>
    <td><input type="text" name="study[]" value="<?= $row['study']; ?>" disabled></td>
    <td><input type="checkbox" name="check[]" value="<?= $row['forward_primer']; ?>"></td>
    <td><input type="text" name="reverse_primer" value="<?= $row['reverse_primer']; ?>" disabled></td>
    <td><input type="text" name="seq_platform" value="<?= $row['seq_platform']; ?>" disabled></td>
</tr>
<?php endforeach; ?>
Start with that and see if issues persist.

Re: embedding mysql output in checkbox

Posted: Fri Oct 23, 2015 1:53 pm
by publicGenome
Thank you for your reply. :) It helped.