English 中文(简体)
在洛普有不同标签的多个检查箱
原标题:Multiple checkboxes with Different label in Loop
  • 时间:2012-01-12 13:14:53
  •  标签:
  • php
<?php
    $r=mysql_query("SELECT city.id as city_id, locality.id,locality.area_name  ".
                   "FROM city, locality  ".
                   "WHERE city.id = locality .city_id order by city_id"); 

    while($rss=mysql_fetch_object($r))
    {
?>
<legend><?=$rss->city_id?></legend>
<input type="checkbox" name="sub_type[]" id="sub_type" value="<?=$rss->id?>" />
<span><?=$rss->area_name?></span><br/>
<?php
    }
?>

我正在用城市身份标识展示地区名称。 问题是,由于环绕,每个地区的名称都添加了这一标识。 我怎么能够阻止身份证多次重复,以便检查箱按照他们所属的城市身份证分类?

问题回答

修改<代码><legend>,即outside<>。 the。

(And use a <label> not a <span> 页: 1

如何:

<?php
$r=mysql_query("SELECT city.id as city_id, locality.id,locality.area_name  ".
               "FROM city, locality  ".
               "WHERE city.id = locality .city_id order by city_id"); 
$previous =   ;
while($rss=mysql_fetch_object($r)) { ?>
    <?php if (empty($previous) || $previous != $rss->city_id) { ?>
        <legend><?=$rss->city_id?></legend>
    <?php } ?> 
    <?php $previous = $rss->city_id; ?>
    <input type="checkbox" name="sub_type[]" id="sub_type" value="<?=$rss->id?>" />
    <span><?=$rss->area_name?></span><br/>
<?php
}
?>




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签