Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why are my checkboxes showing as textboxes...?

Status
Not open for further replies.

dunskii

Programmer
Sep 14, 2001
107
AU
Hi all,

I dont know if this is a php, html or something else.

I am trying to have a table of ckeckboxes where the data is from a query.

Anyway whan i view the page the checkboxes are showing as textboxes.

Heres the code:

<input type=\&quot;checkbox\&quot; name=\&quot;'. $myrow[&quot;admis_id&quot;] .'\&quot;>

thanks again,

dunskii
 
Try this:


// Within php
?>
<!-- out side php -->
<INPUT TYPE=&quot;checkbox&quot; NAME=&quot;<? $myrow[&quot;admis_id&quot;] ?>&quot;>
<!-- out side php -->
<?
// Within php



Even when the php is wrong, it should display checkboxes.

Charl

 
i did that and know there are checkboxes showing, but now the names arent showing.

heres the code:

<?php

$db = mysql_connect(&quot;localhost&quot;, &quot;root&quot;);

mysql_select_db(&quot;fjc&quot;,$db);

$res2 = mysql_query(&quot;SELECT * FROM areas&quot;,$db);

$myrow = mysql_fetch_array($res2);


$cols = 3;
$counter = 1;

print '<center><table width=\&quot;40%\&quot; align=\&quot;center\&quot; cellspacing=\&quot;4\&quot;><tr>';
while ($myrow = mysql_fetch_array($res2)) {
if (is_int($counter / $cols)) {

?>
<td><input type=&quot;checkbox&quot; name=&quot;<? $myrow[&quot;area_id&quot;]?>&quot;> <span class=&quot;text&quot;><? $myrow[&quot;area&quot;] ?></span></td></tr><tr>

<?
}
else {
?>

<td><input type=&quot;checkbox&quot; name=&quot;<? $myrow[&quot;area_id&quot;] ?>&quot;> <span class=&quot;text&quot;><? $myrow[&quot;area&quot;] ?></span></td>

<?
}
$counter++;
}
print '</tr></table></center>';

?>


thanks in advance

dunskii
 
First of all Dunskii,

What names aren't showing? I guess you mean the text near the checkbox, and not the the name property from the checkbox.

Try this:


<?php

$db = mysql_connect(&quot;localhost&quot;, &quot;root&quot;);

mysql_select_db(&quot;fjc&quot;,$db);

$res2 = mysql_query(&quot;SELECT * FROM areas&quot;,$db);

// Why do you take one row out of the array?? Don't!
//
$myrow = mysql_fetch_array($res2);


$cols = 3;
$counter = 1;

print '<center><table width=\&quot;40%\&quot; align=\&quot;center\&quot; cellspacing=\&quot;4\&quot;><tr>';
while ($myrow = mysql_fetch_array($res2)) {
if (is_int($counter / $cols)) {

?>
<td><input type=&quot;checkbox&quot; name=&quot;<? echo($myrow[&quot;area_id&quot;]); ?>&quot;><span class=&quot;text&quot;><? echo($myrow[&quot;area&quot;]); ?></span></td></tr><tr>

<?
}
else {
?>

<td><input type=&quot;checkbox&quot; name=&quot;<? echo($myrow[&quot;area_id&quot;]); ?>&quot;> <span class=&quot;text&quot;>echo($myrow[&quot;area&quot;]); ?></span></td>

<?
}
$counter++;
}
print '</tr></table></center>';

?>


Let me know if it worked,


Charl
 
thanks for that charl,

its working for the 3rd column but the first 2 are show this
echo($myrow[&quot;area&quot;]); ?> instead of the checkbox descrition

thanks for all your help,

dunskii
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top