EllisLab text mark
Advanced Search
     
Need a but of help please!!
Posted: 19 November 2012 03:04 PM   [ Ignore ]
Avatar
Joined: 2011-06-09
661 posts

I need to know the best why to convert all of this to Active record stuff and split into controllers and models then produce PDF output, I already have dompdf installed and running on something else, but this is mashing my head I cant get my head round it and some of you pros out there should be able to help me within a matters of minutes.

<?php
date_default_timezone_set
("UTC");
$autokey $this->uri->segment(3);

$code=$_POST['code'];
echo 
"<table border='0' cellspacing='2'>";

 
  for (
$i 1$i $code$i++)
  
{
   
//Variable Variable Names!
   
$meetingDate $_POST['Date'];
   
${"hours{$i}"}=$_POST['hours'.$i];//current agency code
   
${"minutes{$i}"}=$_POST['minutes'.$i];//current agency code
   
$meetingtime ${"hours{$i}"}.":".${"minutes{$i}"};
   
$time strtotime$meetingtime );
   
$mytime date'H:i'$time );
   
${"AgencyCode{$i}"}=$_POST['AgencyCode'.$i];//current agency code
   
${"CustCode{$i}"}=$_POST['CustCode'.$i];//current customer code
   
${"Books{$i}"}=$_POST['Books'.$i];//current book code
   
${"remarks{$i}"}=$_POST['remarks'.$i];//Remarks for current meeting
   
${"cuttings{$i}"}=$_POST['cuttings'.$i];//Cuttings for current meeting
   
$Agencyquery "SELECT `Company` FROM  `tblclients` WHERE `AutoKey` = '".${"AgencyCode{$i}"}."'";
   
$Agencyresult mysql_query($Agencyquery);
   
   while (
$Agency_array mysql_fetch_assoc($Agencyresult))
   

    
echo "<tr><td><b>Agent: ".$Agency_array['Company']."</b><p>"//Print out the agency the following books are for
    
$Custquery "SELECT `Company` FROM  `tblclients` WHERE `AutoKey` = '".${"CustCode{$i}"}."'";
    
$Custresult mysql_query($Custquery);
    echo 
"Meeting occured on the "$meetingDate." at "$meetingtime"</td></tr><p>";
    echo 
"<tr><td>";
    while (
$Cust_array mysql_fetch_assoc($Custresult))
    
{
    
echo "<u>Customer: ".$Cust_array['Company']."</tr></u><p>";
    echo 
"<td>Remarks: "${"remarks{$i}"}."<p>";//remarks for agency
    
echo "Cuttings: "${"cuttings{$i}"}."<p>";//cuttings for agency
    
}
    
echo "<b>Books:</b><p>";
   
}
   
if (${"Books{$i}"})
   
{
    
foreach (${"Books{$i}"as $B)
    
{
     $Bookquery 
"SELECT BookName, Cost, AgencyID FROM  `tblbook` WHERE `BookID` = '".$B."'";
     
$Bookresult mysql_query($Bookquery);
     while (
$Book_array mysql_fetch_assoc($Bookresult))
     

      
echo $Book_array['BookName']." @ £";//now know AgencyID for each book
      
printf(".2f\n"$Book_array['Cost']);
      echo 
"<p>";
     
}
    }
   } 
   
echo "</tr></td>";
  
}

echo "</table>";

?> 

Need the above changing to CI active record stuff if any one can re-do this for me

Any takers? If you can do it free great if not buyt know you can do it and it wont take you long I’ll gladly send some beer vouchers(£,$) for you!

 Signature 

Thanks,

=== Loving CI & Still Learning it…===

 
Posted: 20 November 2012 01:34 PM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2011-06-09
661 posts

Anyone?

 Signature 

Thanks,

=== Loving CI & Still Learning it…===

 
Posted: 20 November 2012 01:53 PM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Joined: 2012-08-10
16 posts

Where is this code located?

 
Posted: 20 November 2012 04:43 PM   [ Ignore ]   [ # 3 ]   [ Rating: 0 ]
Avatar
Joined: 2011-06-09
661 posts

Currently just in a controller.

 Signature 

Thanks,

=== Loving CI & Still Learning it…===

 
Posted: 20 November 2012 05:06 PM   [ Ignore ]   [ # 4 ]   [ Rating: 0 ]
Avatar
Joined: 2011-06-09
661 posts

So thats my point I need to know how to make the controller proper with a model to grab all the relevant data like shown above then be able to save and retrive data into database and PDF.

 Signature 

Thanks,

=== Loving CI & Still Learning it…===

 
Posted: 21 November 2012 11:26 AM   [ Ignore ]   [ # 5 ]   [ Rating: 0 ]
Avatar
Joined: 2011-06-09
661 posts

Apologies the above code is in a view file and I need someone to help me transport to it controller/models if possible please.

 Signature 

Thanks,

=== Loving CI & Still Learning it…===