embedding mysql output in checkbox

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
publicGenome
Forum Contributor
Posts: 110
Joined: Thu Apr 16, 2015 7:55 am

embedding mysql output in checkbox

Post 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
		}
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: embedding mysql output in checkbox

Post 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.
publicGenome
Forum Contributor
Posts: 110
Joined: Thu Apr 16, 2015 7:55 am

Re: embedding mysql output in checkbox

Post by publicGenome »

Thank you for your reply. :) It helped.
Post Reply