[eluser]rash[/eluser]
Hi hungdp
Thanks for youe reply.
I tried what u said but it didn't working..Check my code..
in Controller.php
\[code\]
public function room_allocation()
{
$data = array();
$data['student_id'] = $_POST['student_id'];
$data['hostel_id'] = $_POST['hostel_id'];
$hostel_id=$_POST['hostel_id'];
$this->view->hostellist=$this->model->hostelList();
$this->view->studentlist=$this->model->studentList();
$this->view->hostelroomlist=$this->model->hostelroomList($hostel_id);
$this->view->render('hostel/room_allocation', $data);
}
\[/code\]
in view.php here is my code
\[code\]
<table width="100%" border="0" cellspacing="3" cellpadding="2">
<tr>
<td>Student Name :</td>
<td><select name="student_id" id="student_id">
<option value="0">-- Select --</option>
<?php
foreach($this->studentlist as $key=> $value){?>
<option value="<?php echo $value['student_id']; ?>"<?php if($student_id==$value['student_id']){ echo " selected"; }?>><?php echo $value['student_name']; ?></option>
<?php } ?>
</select></td>
</tr>
<tr>
<td width="29%">Hostel Name :</td>
<td width="71%"><select name="hostel_id" id="hostel_id">
<option value="0">-- Select --</option>
<?php
foreach($this->hostellist as $key1=> $value1){?>
<option value="<?php echo $value1['hostel_id']; ?>"<?php if($hostel_id==$value1['hostel_id']){ echo " selected"; }?>><?php echo $value1['hostel_name']; ?></option>
<?php } ?>
</select></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="submit" id="submit" value="Show Rooms" /></td>
</tr>
</table>
<table width="100%" border="0" cellspacing="3" cellpadding="2">
<tr>
<td><strong>SL No.</strong></td>
<td><strong>Room No.</strong></td>
<td><strong>Students Per Room</strong></td>
<td><strong>Availability</strong></td>
<td><strong>Rent</strong></td>
<td><strong>Status</strong></td>
</tr>
<?php
$slno=0;
//print_r($this->hostelroomlist);
foreach($this->hostelroomlist as $key2 => $value2) {
$slno++;
?>
<tr>
<td><?php echo $slno;?></td>
<td><?php echo $value2['room_no']; ?></td>
<td><?php echo $value2['stud_proom']; ?></td>
<td><?php echo $value2['availability']; ?></td>
<td><?php echo $value2['rent']; ?></td>
<td><?php $avstatus=$value2['availability']; if($avstatus=="0"){echo "No Availability";}else{?><a href="<?php echo URL;?>hostel/stud_allocate/<?php echo $value2['room_id'];?>?stud_id=<?php //echo $stud_id;?>">Allocate</a><?php } ?></td>
</tr>
<?php } ?>
</table>
\[/code\]
but in dropdown it didn't showing the selected data which i selected last time..
thanks