0

I'm doing a delete page, and this part is the part where all the data were supposed to be echoed. but, the problem is I don't really know how to print the checkbox within the php. The line 6 is wrong. Kind men, do show me how to write it correctly.

<?php
while($rows=mysql_fetch_array($query)){

    echo '<tr>   
        <td>'
        <input name="checkbox[]" type="checkbox" id="checkbox[]" value=".$rows['id'].">  
        '</td>

        <td>'.$rows['Hw_tag'].'</td>
        <td>'.$rows['Hw_name'].'</td>
        <td>'.$rows['Hw_specs'].'</td>
        <td>'.$rows['Hw_purchaseDate'].'</td>
        <td>'.$rows['Hw_warrantyExpire'].'</td>
        <td>'.$rows['vendor_ID'].'</td>
        <td>'.$rows['invoive_ID'].'</td>

        </tr>';
}
?>
3
Contributors
4
Replies
5
Views
4 Years
Discussion Span
Last Post by MarkieJye
0

A standard array of checkboxes:

<input type="checkbox" id="unicycle" name="cycle[]" value="1">I have one wheel.
<input type="checkbox" id="bicycle" name="cycle[]" value="2">I have two wheels.
<input type="checkbox" id="tricycle" name="cycle[]" value="3">I have three wheels.

Now, echoed with PHP:

<?php 
//escaping the double quotes:
echo "<input type=\"checkbox\" id=\"unicycle\" name=\"cycle[]\" value=\"1\">I have one wheel.";
//using single quotes:
echo "<input type='checkbox' id='bicycle' name='cycle[]' value='2'>I have two wheels.";
?>

And finally, echoed with PHP including dynamic vars:

<?php
//escaping double quotes:
echo "<input type=\"checkbox\" id=\"unicycle\" name=\"cycle[]\" value=\"".$rows['id']."\">I have one wheel.";
//single quotes with concatenation:
echo "<input type='checkbox' id='bicycle' name='cycle[]' value='".$rows['id']."'>I have two wheels.<br />";
//for easy writing/reading:
$var_without_quotes = $rows['id'];
echo "<input type='checkbox' id='tricycle' name='cycle[]' value='$var_without_quotes'>I have three wheels.<br />";
?>

Does that answer your question?

0

thank you..but, i still don't know how to use it in my codings..because im echoing it in a loop..

0
<?php 
$i =0
while($rows=mysql_fetch_array($query)){
   echo "<input type = 'checkbox' name = 'Checkbox'".$i."'>";
$i++;
}
?>

Sorry, I dont know if i understand your question.. but i think the checkbox[] array is a counter?I guess?
Can you please elaborate it more?

Thanks
-Alex

0

nope..it's actually checkbox, that hold my 'id' information.. so, instead if echoing the actual id, I echoed the checkbox.. clicking on the checkbox means you're selecting the id that it holds...and, yes it's an array...

:)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.