[eluser]bsteve[/eluser]
Hello to all, i am developing my end of year project but i am stack some where,
I would like to generate reports from a result set created as a result of joining two tables.
this is the query.
$conn = Doctrine_Manager::connection();
$result= $conn->execute('
select p.*,v.*
from Patient p
INNER JOIN Visit v ON p.patient_number = v.patient_number');
$visits = $result->fetchAll();
$this->load->view('patient_visit', $visits);
Every time i try to manipulate the array in the view i get an error message that.
use of undefined variable visits.
below is how i am doing it in the view.
<?php $x =0; ?>
<?php for($x = 0; $x<=count($visits); $x++): ?>
<center>
<table cellspacing="0" cellpadding="5" width="50%" bgcolor="#B9AA81">
<tr><td><b>Patient number:</td>
<td><?php echo $visits[0]['patient_number']; ?></td>
<tr>
<td ><b>First name:</td>
<td><?php echo $visits[0]['first_name']; ?></td>
<tr>
<td> <b> Last name:</td>
<td><?php echo $visits[0]['last_name']; ?></td>
<tr>
<td> <b> Visit code:</td>
<td><?php echo $visits[0]['visit_code']; ?></td>
<tr>
<td> <b> Month:</td>
<td><?php echo $visits['month'];?></td>
<tr>
<td> <b> Visit date:</td>
<td><?php echo $visits['visit_date']; ?></td>
</tr>
</table>
<?php $x++; ?>
<?php endfor; ?>
I would be happy to receive any help.