mercredi 6 janvier 2016

Make an associative array in a form in a check box input

I am trying to send an associative array in a form, in which I am trying to send the package_id,business_name,business_id,category_name. Now it is working fine, and the output is like this

array (size=1)
  0 => 
    array (size=2)
      0 => string '5 category name (Catering) business name (The Emperor's Table)' (length=62)
      1 => string '35 category name (Pizza) business name (Rendezvous)' (length=51).

How can I send the values in the check box so that my output will be like this

array (size=1)
  0 => 
    array (size=2)
      0 => string '5, category name (Catering), business name (The Emperor's Table)' (length=62)
      1 => string '35, category name (Pizza), business name (Rendezvous)' (length=51)

My form code

<?php
$matchFound=False;
$name=array();
$id=array();
$image=array();
$bizid=array();
$desc=array();
$price=array();
$store=array();
$bizname=array();
$checklist=array();
$name_two=array();
$bizid_two=array();
$i=0; 
?>
<div class="container">
<ul class="breadcrumb">
<li><a href="<?php yii::app()->request->baseUrl;?>/package/utilityfinder">Utility Finder</a>
</li>
<li class="active">Search Package</a></li>
</ul>
    <form action="<?php echo yii::app()->request->baseUrl;?>/package/utilityfindertwo" method="GET">
<div class="container">

<div class="col-md-12">
<div class="small gap-small"></div>

<div class="col-md-2 col-md-offset-10">
<input type="submit" class="btn btn-primary" value="Make Customize Package">
</div>
</div>
</div>
<div class="row">
<div class="col-md-9">

<ul class="booking-list">

 <?php if(isset($value)){
 foreach($results as $utility){
      $name[]=$utility['package_name'];
      $id[]=$utility['id']; //business package id
        $bizid[]=$utility['business_id'];
        $image[]=$utility['image'];
        $desc[]=$utility['package_detail'];
        $price[]=$utility["price"];
        $image[]=$utility["image"];
        $bizname[]=$utility["business_name"];
        $pid[]=$utility["package_id"];

       $matchFound=True;


      ?>   
<li>
<a class="booking-item" href="<?php echo Yii::app()->request->baseUrl;?>/businesspackage/packagebusiness/<?php echo $id[$i];?>">

    <div class="row">
<div class="col-md-4">
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo $image[$i]?>" alt="Image Alternative text" title="Nandos" />
</div>
<div class="col-md-5">
   <div class="booking-item-rating">
<ul class="icon-group booking-item-rating-stars">
</div>
 <h5 class="booking-item-title"><?php echo $bizname[$i];?></h5>
  <p><i class="fa fa-shopping-cart"></i> <?php echo $name[$i]; ?></p>
    <p class="booking-item-description"><?php echo $desc[$i];?></p>

</div>
  <div class="col-md-3">
<!--   http://ift.tt/1PNPgzY;
<div class="row">
    <div class="col-md-9"> <span class="booking-item-price"><?php echo "Rs-".$price[$i];?></span></div>
<div class="col-md-3">
    <input class="i-check" type="checkbox" name="checklist[]" value="<?php  echo $pid[$i]." category name (".$name[$i].") business name (".$bizname[$i].")"; ?>">

</div>    


  </div></div></div>
</a>

</li>
<?php $i++;
 }}?>

 <?php if ($matchFound==False && $value!=''){?>
 <?php echo "No Results Found. Please Try again";} ?>
</ul>

</div>
</div>
        </form>
<div class="gap"></div>
</div>




Aucun commentaire:

Enregistrer un commentaire