Jump to content
Sign in to follow this  
Cronos

[Решено] Запись значения в базу

Recommended Posts

Доброго времени суток. Решил сделать инфу о том какой курьер доставляет заказ.

 

Сделал следующее:

 

/var/www/html/admin/view/template/sale/order_sale.tpl

	      <tr>
                <td class="left"><?php echo $entry_courier; ?></td>
                <td class="left"><select name="courier">
                    <?php foreach ($couriers as $courier) { ?>
                    <?php if ($courier['id'] == $courier_id) { ?>
                    <option value="<?php echo $courier['id']; ?>" selected="selected"><?php echo $courier['surname']; ?></option>
                    <?php } else { ?>
                    <option value="<?php echo $courier['id']; ?>"><?php echo $courier['surname']; ?></option>
                    <?php } ?>
                    <?php } ?>
                  </select></td>
              </tr>

Это вывод фамилий курьеров. Для них своя таблица.

 

/var/www/html/admin/controller/sale

$this->data['couriers'] = $this->model_sale_order->getCouriers();

Получаем всех курьеров.

 

/var/www/html/admin/model/sale/order.php

	public function getCouriers() {
		$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "curiers");
		
		return $query->rows;
	}

Функция для выбора из таблицы курьеров.

$this->db->query("UPDATE `" . DB_PREFIX . "order` SET firstname = '" . $this->db->escape($data['firstname']) . "', lastname = '" . $this->db->escape($data['lastname']) . "', email = '" . $this->db->escape($data['email']) . "', telephone = '" . $this->db->escape($data['telephone']) . "', fax = '" . $this->db->escape($data['fax']) . "', payment_firstname = '" . $this->db->escape($data['payment_firstname']) . "', payment_lastname = '" . $this->db->escape($data['payment_lastname']) . "', payment_company = '" . $this->db->escape($data['payment_company']) . "', payment_company_id = '" . $this->db->escape($data['payment_company_id']) . "', payment_tax_id = '" . $this->db->escape($data['payment_tax_id']) . "', payment_address_1 = '" . $this->db->escape($data['payment_address_1']) . "', payment_address_2 = '" . $this->db->escape($data['payment_address_2']) . "', payment_city = '" . $this->db->escape($data['payment_city']) . "', payment_postcode = '" . $this->db->escape($data['payment_postcode']) . "', payment_country = '" . $this->db->escape($payment_country) . "', payment_country_id = '" . (int)$data['payment_country_id'] . "', payment_zone = '" . $this->db->escape($payment_zone) . "', payment_zone_id = '" . (int)$data['payment_zone_id'] . "', payment_address_format = '" . $this->db->escape($payment_address_format) . "', payment_method = '" . $this->db->escape($data['payment_method']) . "', payment_code = '" . $this->db->escape($data['payment_code']) . "', shipping_firstname = '" . $this->db->escape($data['shipping_firstname']) . "', shipping_lastname = '" . $this->db->escape($data['shipping_lastname']) . "',  shipping_company = '" . $this->db->escape($data['shipping_company']) . "', shipping_address_1 = '" . $this->db->escape($data['shipping_address_1']) . "', shipping_address_2 = '" . $this->db->escape($data['shipping_address_2']) . "', shipping_city = '" . $this->db->escape($data['shipping_city']) . "', shipping_postcode = '" . $this->db->escape($data['shipping_postcode']) . "', shipping_country = '" . $this->db->escape($shipping_country) . "', shipping_country_id = '" . (int)$data['shipping_country_id'] . "', shipping_zone = '" . $this->db->escape($shipping_zone) . "', shipping_zone_id = '" . (int)$data['shipping_zone_id'] . "', shipping_address_format = '" . $this->db->escape($shipping_address_format) . "', shipping_method = '" . $this->db->escape($data['shipping_method']) . "', shipping_code = '" . $this->db->escape($data['shipping_code']) . "', comment = '" . $this->db->escape($data['comment']) . "', order_status_id = '" . (int)$data['order_status_id'] . "', affiliate_id  = '" . (int)$data['affiliate_id'] . "', date_modified = NOW(),  courier_id  = '" . (int)$data['courier_id'] . "' WHERE order_id = '" . (int)$order_id . "'");
		

Добавил в запрос на редактирование заказа еще 1 переменную courier_id = '" . (int)$data['courier_id'] . "'

 

Вся загвоздка в том что я не знаю как из селекта (см. скриншот) взять id выбранного курьера и записать его в переменную $data['courier_id'], для последующего добавления в базу...

 

Подскажите как работает механизм "взятия" значения переменной из полей... Читал документацию, попробовал - не получилось...

 

На скриншоте селект из которого нужно взять значение.

094307c13dc582df232ae9b615a29224.png

 

 

 

 

Share this post


Link to post
Share on other sites

<select name="courier">
>>

<select name="courier_id">

Share this post


Link to post
Share on other sites

Не знаю как поставить +1. Спасибо!

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.