-1

I have a problem in cakephp

controller

$due = $this->Issue->find('all' , array('conditions' => array ('Issue.user_id'=>6)));
$this->set('due',$due);
$id = $due['0']['Issue']['book_id'];
$b = $this->Bookmaster->find('first' , array ('conditions' => array ('Bookmaster.id' => $bookid)));
$book = $this->Book->find('all',array('conditions' => array ('Book.id' =>$id)));
$bookid = $book['0']['Book']['bookmaster_id'];

Ctp contain

<h1> ISSUED BOOK DETAILS </h1>
<table width="200" border="2" bordercolor="#009933">
<tr>
<td> BOOK ID </td>
<td> TITLE </td>
<td> AUTHOR </td>
<td> EDITION </td>
<td>ISSUED ON  </td>
<td> DUE DATE </td>
<td> POTENTIAL FINE</td>
</tr>
 <?php foreach ($due  as $data  ) { ?> <tr> 

<td> <?php  echo $data['Issue']['book_id']; ?> </td> 
<td> <?php   echo $b ['Bookmaster']['title'] ;?></td> 
<td> <?php  echo $b['Bookmaster']['author'];?></td>  
<td> <?php  echo $b ['Bookmaster']['edition'];?> </td>  
<td> <?php echo $data['Issue']['issue_date_time']; ?> </td> 
<td> <?php  echo $data['Issue']['due_date']; ?> </td>  
<td> <?php echo $out['Fine']['fineamount'];?> </td> 
 </tr> <?php }?>
</table>

My problem is how can I manipulate with this with for loop. My loop is not iterating for bookmaster.. so how can I do that..

How can i increment the value of bookid

shajis001
  • 3
  • 3

1 Answers1

0

The problem is you are looping on $due, and the $b data is a key valued array (i.e. $b[0]['bd'], $b[1]['bd'], $b[2]['bd'], etc.) Therefore, the key (or the index) for the array you are searching for will not ever be aligned with the $due loop.

A better solution is to write a join so each record contains the information you require and the loop will be able to display the data you require. More requirements / information is required on your part to enable anyone here to offer a suggestion.

Chuck Burgess
  • 11,600
  • 5
  • 41
  • 74