When I trying to insert some values, MySQL shows double entry. The first entry is correct, but second entry contains only zeros. Kindly help me..
My Controller codes are here:
$config['upload_path'] = './img/trainees/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '200';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$this->load->library('upload', $config);
$imgname ='';
if($this->upload->do_upload())
{
$data = $this->upload->data();
$imgname = $data['raw_name'].$data['file_ext'];
}
Above code is used to upload images in controller..
Remaining codes:
$this->load->model('newmodel');
$this->newmodel->NAME = $this->input->post("name");
$this->newmodel->AGE = $this->input->post("age");
$this->newmodel->PLACE = $this->input->post("place");
$this->newmodel->ADDRESS = $this->input->post("address");
$this->newmodel->PHONE = $this->input->post("phone");
$this->newmodel->MAIL = $this->input->post("email");
$this->newmodel->QUALI = $this->input->post("qualification");
$this->newmodel->OCCUP = $this->input->post("occupation");
$this->newmodel->MILMAID = $this->input->post("memberID");
$this->newmodel->COURSE = $this->input->post("course");
$this->newmodel->CENTRE = $this->input->post("centre");
$this->newmodel->REGDATE = date('d/m/Y');
$this->newmodel->IMGNAME= $imgname;
$mydata = $this->newmodel->insertuserdata();
$data = array(
'name' => $this->newmodel->NAME,
'age' => $this->newmodel->AGE,
'place' => $this->newmodel->PLACE,
'address' => $this->newmodel->ADDRESS,
'phone' => $this->newmodel->PHONE,
'email' => $this->newmodel->MAIL,
'quali' => $this->newmodel->QUALI,
'occup' => $this->newmodel->OCCUP,
'milmaid' => $this->newmodel->MILMAID,
'course' => $this->newmodel->COURSE,
'centre' => $this->newmodel->CENTRE,
'regdate' => $this->newmodel->REGDATE,
'imgname' => $this->newmodel->IMGNAME,
);
$this->load->helper('url');
$this->load->view('users/admitcard',$data);
My Model codes are seem like this:
var $NAME = '';
var $AGE = 0;
var $PLACE = '';
var $ADDRESS = '';
var $PHONE = 0;
var $MAIL = '';
var $QUALI = '';
var $OCCUP = '';
var $MILMAID = '';
var $COURSE = '';
var $CENTRE = '';
var $REGDATE = '';
var $IMGNAME ='';
public function insertuserdata(){
$this->load->database();
$datas = array(
'Tname' => $this->NAME,
'Tage' => $this->AGE,
'Tplace' => $this->PLACE,
'TAddres' => $this->ADDRESS,
'Tph' => $this->PHONE,
'Tmail' => $this->MAIL,
'Tqualification' => $this->QUALI,
'Toccupation' => $this->OCCUP,
'TmilmaMemb' => $this->MILMAID,
'Tcourse' => $this->COURSE,
'Tcentre' => $this->CENTRE,
'regDate' => $this->REGDATE
);
$this->db->insert('tbl_trainers', $datas);
Try this code on your model
public function insertuserdata(){
$this->load->database();
$datas = array(
'Tname' => $this->input->post("name"),
'Tage' => $this->input->post("age"),
'Tplace' => $this->input->post("place"),
'TAddres' => $this->input->post("address"),
'Tph' => $this->input->post("phone"),
'Tmail' => $this->input->post("email"),
'Tqualification' => $this->input->post("qualification"),
'Toccupation' => $this->input->post("occupation"),
'TmilmaMemb' => $this->input->post("memberID"),
'Tcourse' => $this->input->post("course"),
'Tcentre' => $this->input->post("centre"),
'regDate' => date('d/m/Y')
);
$this->db->insert('tbl_trainers', $datas);
}
And simply call this model on your controller. Now your controller look like this-
public function yourMethod(){
$this->load->model('newmodel');
$this->newmodel->insertuserdata();
# And your rest code here...
}
Related
I'm trying to insert rows in my MySQL DB using contact form 7.
But it doesn't insert those elements, just five I see inserted.
Is there any limit for the array?
Tks a lot.
I'm using this code:
function contactform7_before_send_mail( $form_to_DB ) {
//set your db details
$mydb = new wpdb('test','test,','test','test');
$form_to_DB = WPCF7_Submission::get_instance();
if ( $form_to_DB )
$formData = $form_to_DB->get_posted_data();
$localorigem = $formData['local-origem'];
$dataatendimento = $formData['data-atendimento'];
$numeroprontuario = $formData['numero-prontuario'];
$numerocartaosus = $formData['numero-cartao-sus'];
$nomeusuario = $formData['nome-usuario'];
$sexo = $formData['sexo'];
$gestante = $formData=['gestante'];
$idgestacional = $formData=['id-gestacional'];
$datanascimento = $formData=['data-nascimento'];
$estadocivil = $formData=['estado-civil'];
$racacor = $formData=['raca-cor'];
$escolaridadeanos = $formData=['escolaridade-anos'];
$ocupacaotexto = $formData=['ocupacao-texto'];
$mydb->insert(
'test', array(
'local-origem' =>$localorigem,
'data-atendimento' =>$dataatendimento,
'numero-prontuario' =>$numeroprontuario,
'numero-cartao-sus' => $numerocartaosus,
'nome-usuario' => $nomeusuario,
'data-nascimento' => $datanascimento,
'id-gestacional' => $idgestacional,
'data-nascimento' = $datanascimento,
'estado-civil' = $estadocivil,
'raca-cor' = $racacor,
'escolaridade-anos' = $escolaridadeanos,
'ocupacao-texto' = $ocupacaotexto
) );
}
remove_all_filters ('wpcf7_before_send_mail');
add_action( 'wpcf7_before_send_mail', 'contactform7_before_send_mail' );
Please change this. UPDATED Answer
$gestante = $formData=['gestante'];
$idgestacional = $formData=['id-gestacional'];
$datanascimento = $formData=['data-nascimento'];
$estadocivil = $formData=['estado-civil'];
$racacor = $formData=['raca-cor'];
$escolaridadeanos = $formData=['escolaridade-anos'];
$ocupacaotexto = $formData=['ocupacao-texto'];
$mydb->insert(
'test', array(
'local-origem' =>$localorigem,
'data-atendimento' =>$dataatendimento,
'numero-prontuario' =>$numeroprontuario,
'numero-cartao-sus' => $numerocartaosus,
'nome-usuario' => $nomeusuario,
'data-nascimento' => $datanascimento,
'id-gestacional' => $idgestacional,
'data-nascimento' = $datanascimento,
'estado-civil' = $estadocivil,
'raca-cor' = $racacor,
'escolaridade-anos' = $escolaridadeanos,
'ocupacao-texto' = $ocupacaotexto
) );
To
$gestante = $formData['gestante'];
$idgestacional = $formData['id-gestacional'];
$datanascimento = $formData['data-nascimento'];
$estadocivil = $formData['estado-civil'];
$racacor = $formData['raca-cor'];
$escolaridadeanos = $formData['escolaridade-anos'];
$ocupacaotexto = $formData['ocupacao-texto'];
$mydb->insert(
'test', array(
'local-origem' =>$localorigem,
'data-atendimento' =>$dataatendimento,
'numero-prontuario' =>$numeroprontuario,
'numero-cartao-sus' => $numerocartaosus,
'nome-usuario' => $nomeusuario,
'data-nascimento' => $datanascimento,
'id-gestacional' => $idgestacional,
'data-nascimento' => $datanascimento,
'estado-civil' => $estadocivil,
'raca-cor' => $racacor,
'escolaridade-anos' => $escolaridadeanos,
'ocupacao-texto' => $ocupacaotexto
) );
How would I insert "_thumb" before file extension ?
for example 123.jpg into 123_thumb.jpg
please answer my question, it's been 3 days i didn't find the right way.. thank you
this is my view :
<div class="row service-box margin-bottom-40">
<!-- carousel -->
<div class="col-md-4">
<div class="carousel slide">
<?php
$reports_slide = $this->m_dashboard->report_slide();
foreach ($reports_slide as $row) {
echo '
<img width="100%" src="' . base_url() . 'img/report/thumbs/' . $row->report_img . '" class="mySlides">
';
} ?>
<script>
var slideIndex = 0;
carousel();
function carousel() {
var i;
var x = document.getElementsByClassName("mySlides");
for (i = 0; i < x.length; i++) {
x[i].style.display = "none";
}
slideIndex++;
if (slideIndex > x.length) {slideIndex = 1}
x[slideIndex-1].style.display = "block";
setTimeout(carousel, 2000); // Change image every 2 seconds
}
</script>
</div>
</div>
and this is my controller :
public function add_report()
{
$field_img = "img";
$field_thumb = "thumb";
$field_pdf = "pdf";
// this is for form field 1 which is an image....
$config['upload_path'] = '../img/report/';
$config['allowed_types'] = 'gif|jpg|png|pdf';
$config['max_size'] = '1024';
$config['remove_spaces'] = TRUE;
$config['overwrite'] = TRUE;
$this->load->view('includes/header');
$this->load->view('includes/menu');
if (isset($_POST['submit'])) {
if (isset($_FILES['img']['name']) && is_uploaded_file($_FILES['img']['tmp_name'])){
$config['file_name'] = '_image_'.$_POST['id_company'].'_'.$_POST['report_title'];
$this->upload->initialize($config);
$this->upload->do_upload($field_img);
$file_name = $this->upload->data();
$file_img = $file_name['file_name'];
$config = array(
'image_library' => 'gd2',
'source_image' => $file_name['full_path'],
'new_image' => '../img/report/thumbs/',
'create_thumb' => TRUE,
'maintain_ratio' => FALSE,
'width' => 827,
'height' => 1170,
);
$this->image_lib->clear();
$this->image_lib->initialize($config);
$this->image_lib->resize();
}
}
}
}
and this is my Model :
public function report_slide()
{
//report
$this->db->select('a.*, b.category_name, c.co_abbreviated_name, d.country_name, e.language, f.report_type, g.year, h.type');
$this->db->from('rc_report a, rc_category b, rc_company c, rc_country d, rc_language e, rc_report_type f, rc_year g, rc_gri h');
$this->db->where('b.id_category = a.id_category');
$this->db->where('c.id_company = a.id_company');
$this->db->where('d.id_country = a.id_country');
$this->db->where('e.id_language = a.id_language');
$this->db->where('f.id_report_type = a.id_report_type');
$this->db->where('g.id_year = a.id_year');
$this->db->where('h.id_gri = a.id_gri');
$this->db->order_by('g.year','desc');
$this->db->limit(5);
$query_report = $this->db->get();
$result_array=$query_report->result();
return $result_array;
}
English is not my native language, sorry for that.
For set à new name for your thumb, you just change this config
'new_image' => '../img/report/thumbs/'
When you do this you get the lot of informations about file
$file_name = $this->upload->data();
If you like inside the Ci::Upload, you see the function data return this
public function data($index = NULL)
{
$data = array(
'file_name' => $this->file_name,
'file_type' => $this->file_type,
'file_path' => $this->upload_path,
'full_path' => $this->upload_path.$this->file_name,
'raw_name' => substr($this->file_name, 0, -strlen($this->file_ext)),
'orig_name' => $this->orig_name,
'client_name' => $this->client_name,
'file_ext' => $this->file_ext,
'file_size' => $this->file_size,
'is_image' => $this->is_image(),
'image_width' => $this->image_width,
'image_height' => $this->image_height,
'image_type' => $this->image_type,
'image_size_str' => $this->image_size_str,
);
if ( ! empty($index))
{
return isset($data[$index]) ? $data[$index] : NULL;
}
return $data;
}
In your case what interests you it's
'raw_name' => substr($this->file_name, 0, -strlen($this->file_ext)),
Which give :
$config = array(
'image_library' => 'gd2',
'source_image' => $file_name['full_path'],
'new_image' => "../img/report/thumbs/".$file_name['raw_name']."_thumb.".$file_name['file_ext'],
'create_thumb' => TRUE,
'maintain_ratio' => FALSE,
'width' => 827,
'height' => 1170,
);
PS: See this Codeigniter image resize() thumbnail name issue
i use this extension : http://www.matmoo.com/digital-dribble/codeigniter/image_moo/
It's more successful than Codeigniter's own library. Especially when I want to save thumbnails in multiple sizes.
I'm stuck on a problem with updating image. I've created image upload which works fine but I also want it to be updated. When I add a need image it updates correctly but I if don't want to change the image and leave it as it is, then my current image can't be retrieve. Please help me
Here is my code:
Controller:
function edit_product($product_id)
{
$data = array('recipe_info' => $this->products_model->getRcipe($this->uri->segment(3)),
'product_id' => $this->uri->segment(3)
);
/*var_dump($data); die();*/
$this->load->view('edit_product', $data);
}
public function save_edit_recipe()
{
$thumnail="";
$stats = "";
$msg = "";
$filename = 'r_image';
$data = array(
'recipe_id' => $this->uri->segment(3),
'r_name' => $this->input->post('r_name'),
'r_image' => '',
'r_description' => $this->input->post('r_description'),
'time_id' => $this->input->post('cooking_time'),
'r_cal' => $this->input->post('calories'),
'r_serve' => $this->input->post('serving_size'),
'r_procedure' => $this->input->post('recipe_procedure')
);
$recipe_id = $this->products_model->update_product($this->uri->segment(3), $data);
foreach($this->input->post('ingredients') as $key => $value)
{
$menuData[] = array('recipe_id' => $this->input->post('recipe_id'),
'ingredient_id' => $value,
'category_id' => $this->input->post('recipe_category')
);
}
$this->products_model->saveMenu($menuData);
$config['upload_path'] = 'img/recipes/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = 1024 * 8 ;
$config['encrypt_name'] = true;
$this->load->library('upload',$config);
if (!$this->upload->do_upload($filename))
{
$stats = 'error';
$msg = $this->upload->display_errors('', '');
}else{
$uploadData = $this->upload->data('file_name');
if($uploadData['file_name'])
{
$thumnail = 'img/recipes/'.$uploadData['file_name'];
}else{
$thumnail = 'No thumnbail uploaded!';
}
$updateThumbData = array('recipe_id' => $this->input->post('recipe_id'),
'r_image' => $thumnail
);
$this->products_model->updataRecipeThumnail($updateThumbData);
}
redirect('dashboard');
}
Model:
function getRcipe($recipe_id)
{
$this->db->where('recipe_id', $recipe_id);
$query = $this->db->get('recipe');
return $query->result();
}
public function update_product($product_id, $data)
{
$this->db->where('recipe_id', $product_id);
$this->db->update('recipe', $data);
}
public function updataRecipeThumnail($data)
{
$this->db->where('recipe_id', $data['recipe_id']);
$this->db->update('recipe', $data);
}
i have updated in your script...please used this function... then your problem may be shortout..
public function save_edit_recipe()
{
$thumnail="";
$stats = "";
$msg = "";
$filename = 'r_image';
$data = array(
'recipe_id' => $this->uri->segment(3),
'r_name' => $this->input->post('r_name'),
'r_description' => $this->input->post('r_description'),
'time_id' => $this->input->post('cooking_time'),
'r_cal' => $this->input->post('calories'),
'r_serve' => $this->input->post('serving_size'),
'r_procedure' => $this->input->post('recipe_procedure')
);
$recipe_id = $this->products_model->update_product($this->uri->segment(3), $data);
foreach($this->input->post('ingredients') as $key => $value)
{
$menuData[] = array('recipe_id' => $this->input->post('recipe_id'),
'ingredient_id' => $value,
'category_id' => $this->input->post('recipe_category')
);
}
$this->products_model->saveMenu($menuData);
$config['upload_path'] = 'img/recipes/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = 1024 * 8 ;
$config['encrypt_name'] = true;
$this->load->library('upload',$config);
if (!$this->upload->do_upload($filename))
{
$stats = 'error';
$msg = $this->upload->display_errors('', '');
}else{
$uploadData = $this->upload->data('file_name');
if($uploadData['file_name'])
{
$thumnail = 'img/recipes/'.$uploadData['file_name'];
$updateThumbData = array(
'recipe_id' => $this->input->post('recipe_id'),
'r_image' => $thumnail
);
$this->products_model->updataRecipeThumnail($updateThumbData);
}else{
$thumnail = 'No thumnbail uploaded!';
}
}
redirect('dashboard');
}
I have the following code:
include "config.php";
error_reporting(0);
$idSuccess = 0;
if(isset($_POST['userName']))
{
$usr = $_POST['userName'];
$pwd = $_POST['userPwd'];
$sqlQ = "SELECT * FROM dr_users where dr_user_name='$usr' AND dr_user_pwd='$pwd' LIMIT 1";
$q = mysql_query($sqlQ);
if(mysql_num_rows($q) > 0)
{
$userO = mysql_fetch_assoc($q);
$userData = array('userID' => $userO['dr_user_id'], 'userName' => $userO['dr_user_name'], 'userPwd' => $userO['dr_user_pwd'], 'userEml' => $userO['dr_user_email'], 'privLvl' => $userO['dr_user_priv_level']);
$idSuccess = 1;
$uID = $userO['dr_user_id'];
$charQ = mysql_query("SELECT * FROM dr_chars WHERE dr_user_id='$uID'");
while($char = mysql_fetch_array($charQ))
{
$chars[] = $char;
$charID = $char['dr_char_id'];
$itemQ = mysql_query("SELECT * FROM dr_items WHERE dr_char_id='$charID'");
while($item = mysql_fetch_array($itemQ))
{
$itemData[] = array('itemID' => $item['dr_item_id'], 'itemName' => $item['dr_item_name'], 'itemDesc' => $item['dr_item_desc'], 'itemType' => $item['dr_item_type'], 'itemCost' => $item['dr_item_cost'], 'itemCurType' => $item['dr_item_cur_type'], 'itemAtk' => $item['dr_item_stat_atk'], 'itemDef' => $item['dr_item_stat_def'], 'itemEnd' => $item['dr_item_stat_end'], 'itemLuck' => $item['dr_item_stat_luck'], 'itemFileURL' => $item['dr_item_file_url'], 'itemStaff' => $item['dr_item_staff'], 'itemEquipped' => $item['dr_char_eqp'], 'spX' => $item['dr_static_pos_x'], 'spY' => $item['dr_static_pos_y']);
}
$charData[] = array('charID' => $char['dr_char_id'], 'charName' => $char['dr_char_name'], 'charRace' => $char['dr_char_race'], 'charLvl' => $char['dr_char_lvl'], 'charItems' => $itemData);
}
$resData = array('idSuccess' => $idSuccess, 'user' => $userData, 'chars' => $charData);
} else {
$resData = array('idSuccess' => $idSuccess);
}
echo json_encode($resData);
}
?>
I have successfully loaded character data from the table 'dr_chars' in my database. I'm trying to load the corresponding item data from the retrieved character ID and push it into the $charData array. So I can then easily encode & output it in a JSON format.
If my question isn't clear just ask and I'll try to explain the situation better. The JSON data is being outputted into flash for dynamic use.
I managed to fix this final code as follows:
<?php
include "config.php";
error_reporting(0);
$idSuccess = 0;
if(isset($_POST['userName']))
{
$usr = $_POST['userName'];
$pwd = $_POST['userPwd'];
$sqlQ = "SELECT * FROM dr_users where dr_user_name='$usr' AND dr_user_pwd='$pwd' LIMIT 1";
$q = mysql_query($sqlQ);
if(mysql_num_rows($q) > 0)
{
$userO = mysql_fetch_assoc($q);
$userData = array('userID' => $userO['dr_user_id'], 'userName' => $userO['dr_user_name'], 'userPwd' => $userO['dr_user_pwd'], 'userEml' => $userO['dr_user_email'], 'privLvl' => $userO['dr_user_priv_level']);
$idSuccess = 1;
$uID = $userO['dr_user_id'];
$charQ = mysql_query("SELECT * FROM dr_chars WHERE dr_user_id='$uID'");
$chars = array();
while($char = mysql_fetch_array($charQ))
{
$charID = $char['dr_char_id'];
$itemQ = mysql_query("SELECT * FROM dr_items WHERE dr_char_id='$charID'");
$items = array();
while($item = mysql_fetch_array($itemQ))
{
$items[] = array('itemID' => $item['dr_item_id'], 'itemName' => $item['dr_item_name'], 'itemDesc' => $item['dr_item_desc'], 'itemType' => $item['dr_item_type'], 'itemCost' => $item['dr_item_cost'], 'itemCurType' => $item['dr_item_cur_type'], 'itemAtk' => $item['dr_item_stat_atk'], 'itemDef' => $item['dr_item_stat_def'], 'itemEnd' => $item['dr_item_stat_end'], 'itemLuck' => $item['dr_item_stat_luck'], 'itemFileURL' => $item['dr_item_file_url'], 'itemStaff' => $item['dr_item_staff'], 'itemEquipped' => $item['dr_char_eqp'], 'spX' => $item['dr_static_pos_x'], 'spY' => $item['dr_static_pos_y']);
}
$chars[] = array('charID' => $char['dr_char_id'], 'charName' => $char['dr_char_name'], 'charRace' => $char['dr_char_race'], 'charLvl' => $char['dr_char_lvl'], 'charItems' => $items);
}
$resData = array('idSuccess' => $idSuccess, 'user' => $userData, 'chars' => $chars);
} else {
$resData = array('idSuccess' => $idSuccess);
}
echo json_encode($resData);
}
?>
I'm working on a php web application for a website, and I would like to pass some variables from one php file to another. I have tried the old fashion way with the include file but was not successful. I also tried to set the variables in global scope but still not working. The code in first.php file is:
function rc_getAvailableVehicles($pickup_timestamp, $return_timestamp, $vehicle_classes=array()) {
global
$wpdb;
$rc_currency = RC_Registry::get('rc_currency');
$where_classes = "";
if ($vehicle_classes) {
foreach($vehicle_classes as $vehicle_class) {
$where_classes[] = " v.class = '". $wpdb->escape($vehicle_class) ."'";
}
$where_classes = "AND (".implode(' OR ', $where_classes).") ";
}
$sql = "SELECT *
FROM ".$wpdb->rc_vehicles." v
WHERE v.quantity > (SELECT COUNT(*) FROM ".$wpdb->rc_bookings." b WHERE b.vehicle_id = v.vehicle_id AND ((UNIX_TIMESTAMP(b.pickup_date) >= '". (int)$pickup_timestamp ."' AND UNIX_TIMESTAMP(b.pickup_date) < '". (int)$return_timestamp ."') || (UNIX_TIMESTAMP(b.pickup_date) < '". (int)$pickup_timestamp ."' AND UNIX_TIMESTAMP(b.return_date) >= '". (int)$pickup_timestamp ."')) AND (b.status != 'new' AND b.status != 'canceled') AND b.trash = '0') ".$where_classes."AND v.status = '1' AND v.archive = '0'
ORDER BY v.rent ASC";
$results = $wpdb->get_results($sql,ARRAY_A);
$vehicles = array();
$rental_days = ceil(($return_timestamp-$pickup_timestamp)/91800);
$xfee = get_field('another_location_fee');
$xfee2 = get_field('return_to_another_location_fee_2');
if ($results) {
foreach ($results as $result) {
if ($result['image'] && file_exists(RC_UPLOADS_DIR . "vehicle_" . $result['image'])) {
$image = RC_UPLOADS_URL . 'vehicle_' . $result['image'];
$image_thumb = RC_UPLOADS_URL . 'cache/' . rc_image_resize(RC_UPLOADS_DIR . "vehicle_" . $result['image'], 220, 160);
} else {
$image = '';
$image_thumb = '';
}
$result['description'] = do_shortcode($result['description']);
$description = html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8');
global $GeneralPrice, $discount_price, $rent1, $rent5;
include_once ('file2.php');
//$GeneralPrice = $result['rent'];
$rent1 = $vehicle_meta['rent1'];
$rent2 = $vehicle_meta['rent2'];
$rent3 = $vehicle_meta['rent3'];
$rent4 = $vehicle_meta['rent4'];
$rent5 = $vehicle_meta['rent5'];
$rent6 = $vehicle_meta['rent6'];
$rent7 = $vehicle_meta['rent7'];
$rent8 = $vehicle_meta['rent8'];
$rent9 = $vehicle_meta['rent9'];
$rent10 = $vehicle_meta['rent10'];
$rent11 = $vehicle_meta['rent11'];
$rent12 = $vehicle_meta['rent12'];
$rent13 = $vehicle_meta['rent13'];
$rent14 = $vehicle_meta['rent14'];
$rent15 = $vehicle_meta['rent15'];
$rent16 = $vehicle_meta['rent16'];
$rent17 = $vehicle_meta['rent17'];
$rent18 = $vehicle_meta['rent18'];
$rent19 = $vehicle_meta['rent19'];
$rent20 = $vehicle_meta['rent20'];
$rent21 = $vehicle_meta['rent21'];
$rent22 = $vehicle_meta['rent22'];
$rent23 = $vehicle_meta['rent23'];
$rent24 = $vehicle_meta['rent24'];
$rent25 = $vehicle_meta['rent25'];
$rent26 = $vehicle_meta['rent26'];
$rent27 = $vehicle_meta['rent27'];
$rent28 = $vehicle_meta['rent28'];
$rent29 = $vehicle_meta['rent29'];
$rent30 = $vehicle_meta['rent30'];
$rent31 = $vehicle_meta['rent31'];
$rent32 = $vehicle_meta['rent32'];
$rent33 = $vehicle_meta['rent33'];
$rent34 = $vehicle_meta['rent34'];
$rent35 = $vehicle_meta['rent35'];
$rent36 = $vehicle_meta['rent36'];
$vehicle_meta = rc_getVehicleMeta($result['vehicle_id']);
$vehicles[$result['vehicle_id']] = array(
'vehicle_id' => $result['vehicle_id'],
'title' => $result['manufacturer']." ".$result['series'],
'manufacturer' => $result['manufacturer'],
'series' => $result['series'],
'year' => $result['year'],
'class' => $result['class'],
'image' => $image,
'image_thumb' => $image_thumb,
'description' => $description,
'seats' => $vehicle_meta['seats'],
'doors' => $vehicle_meta['doors'],
'baggages' => $vehicle_meta['baggages'],
'conditioning' => $vehicle_meta['conditioning'],
'transmission' => $vehicle_meta['transmission'],
'rent1' => $vehicle_meta['rent1'],
'rent2' => $vehicle_meta['rent2'],
'rent3' => $vehicle_meta['rent3'],
'rent4' => $vehicle_meta['rent4'],
'rent5' => $vehicle_meta['rent5'],
'rent6' => $vehicle_meta['rent6'],
'rent7' => $vehicle_meta['rent7'],
'rent8' => $vehicle_meta['rent8'],
'rent9' => $vehicle_meta['rent9'],
'rent10' => $vehicle_meta['rent10'],
'rent11' => $vehicle_meta['rent11'],
'rent12' => $vehicle_meta['rent12'],
'rent13' => $vehicle_meta['rent13'],
'rent14' => $vehicle_meta['rent14'],
'rent15' => $vehicle_meta['rent15'],
'rent16' => $vehicle_meta['rent16'],
'rent17' => $vehicle_meta['rent17'],
'rent18' => $vehicle_meta['rent18'],
'rent19' => $vehicle_meta['rent19'],
'rent20' => $vehicle_meta['rent20'],
'rent21' => $vehicle_meta['rent21'],
'rent22' => $vehicle_meta['rent22'],
'rent23' => $vehicle_meta['rent23'],
'rent24' => $vehicle_meta['rent24'],
'rent25' => $vehicle_meta['rent25'],
'rent26' => $vehicle_meta['rent26'],
'rent27' => $vehicle_meta['rent27'],
'rent28' => $vehicle_meta['rent28'],
'rent29' => $vehicle_meta['rent29'],
'rent30' => $vehicle_meta['rent30'],
'rent31' => $vehicle_meta['rent31'],
'rent32' => $vehicle_meta['rent32'],
'rent33' => $vehicle_meta['rent33'],
'rent34' => $vehicle_meta['rent34'],
'rent35' => $vehicle_meta['rent35'],
'rent36' => $vehicle_meta['rent36'],
'total_price' => $rc_currency->format((($rental_days*$GeneralPrice)-(($rental_days*$GeneralPrice) * ($discount_price)/100)+ $utime)),
'total_price_return_fee' => $rc_currency->format((($rental_days*$result['rent']) - ($rental_days*$result['rent']) * ($discount_price)/100)+ $xfee),
'total_price_return_fee2' => $rc_currency->format((($rental_days*$result['rent']) - ($rental_days*$result['rent'])*($discount_price)/100)+ $xfee2),
'daily_price' => $rc_currency->format((($GeneralPrice)-($GeneralPrice)*($discount_price)/100)+ ($utime / $rental_days)),
'daily_price_return_fee' => $rc_currency->format(($result['rent']-($result['rent'])* ($discount_price)/100)+ ($xfee / $rental_days)),
'daily_price_return_fee2' => $rc_currency->format(($result['rent']-($result['rent'])*($discount_price)/100) + ($xfee2 / $rental_days))
);
}
}
return $vehicles;
}
and I want to echo all the $rent variables in file2.php
I have tried the
echo $rent; without success!
You have problems with the order of the code
$vehicle_meta = rc_getVehicleMeta($result['vehicle_id']);
Should be BEFORE you populate rent variables, and
include_once ('file2.php');
Should be AFTER you populated rent variables.
You need to call a function in file1.php that exists in file2.php
ex. in file1.php you could call the function return_rent
return_rent($rent);
in file2 then you make the function
function return_rent($var){
echo $rent;
}
$pass = "anything";
include_once ('file2.php');
From file2.php you can access $pass variable.