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.


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


4 Years
Discussion Span
Last Post by MarkieJye

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:

//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:

//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?


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

$i =0
   echo "<input type = 'checkbox' name = 'Checkbox'".$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?



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.