Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Checkbox, MySQL ENTRY "true/false" to become "1/0"


OSC-Sevilla

Recommended Posts

I am modding order editor to incoporate my lead time addon that shows if the product carries a lead time and how many days, during editing the order the operatoer can change these the specs:

 

this piece of code refers to a checkbox that shows which product(s) have lead times

 

<td class="dataTableContent" valign="top"><input type="checkbox" title="Lead time Active: <?php echo $order->products[$i]['lead_time_days']; ?> DAYS" name="<?php echo "update_products[" . $orders_products_id . "][lead_time]"; ?>" <?php if (ORDER_EDITOR_USE_AJAX == 'true') { ?>onClick="updateProductsField('update', '<?php echo $orders_products_id; ?>', 'products_lead_time', this.checked, this)"<?php } ?> <?php if($order->products[$i]['lead_time']=='1'){ echo "checked=\"true\""; }?>"></td>

 

 

The problem i am having is the data form the check box enters mySQL as " true " or " false" - is is all well and good but i would like it to go in as "1" or "0"

 

My db is currently VARCHAR (5).

 

 

I ahve googled searched high and low but not found a straight forward solution.

 

Any ideas folks??

Link to comment
Share on other sites

I can't really figure it out with that code, but look for the code that actually enters the data into the database. You should be able to find where it is actually being updated and simply do a check. If active == true, then insert 1, else insert 0. Like this:

 

$somevariable = (activeleadtime == true ? 1 : 0);

Link to comment
Share on other sites

I have used HFT string find tool and not been able to find out the above: but the below is where its going in:

 

is it possible to add a string above to handle the conversion???

 

 

 

 

// Update orders_products Table

$Query = "UPDATE " . TABLE_ORDERS_PRODUCTS . " SET

products_model = '" . $products_details['model'] . "',

products_name = '" . oe_html_quotes($products_details['name']) . "',

products_price = '" . $products_details['price'] . "',

final_price = '" . $products_details['final_price'] . "',

products_tax = '" . $products_details['tax'] . "',

products_quantity = '" . $products_details['qty'] . "',

products_lead_time = '" . $products_details['lead_time'] . "',

products_lead_time_days = '" . $products_details['lead_time_days'] . "'

WHERE orders_id = '" . (int)$oID . "'

AND orders_products_id = '$orders_products_id';";

tep_db_query($Query);

Link to comment
Share on other sites

SOLVED - botched but solved

 

//not deleted=> updated

if ($products_details['lead_time']== ('on'||'true')){$products_lead_time = 1;}else {$products_lead_time = 0;};

// Update orders_products Table

$Query = "UPDATE " . TABLE_ORDERS_PRODUCTS . " SET

products_model = '" . $products_details['model'] . "',

products_name = '" . oe_html_quotes($products_details['name']) . "',

products_price = '" . $products_details['price'] . "',

final_price = '" . $products_details['final_price'] . "',

products_tax = '" . $products_details['tax'] . "',

products_quantity = '" . $products_details['qty'] . "',

products_lead_time = '" . $products_lead_time . "',

products_lead_time_days = '" . $products_details['lead_time_days'] . "'

WHERE orders_id = '" . (int)$oID . "'

AND orders_products_id = '$orders_products_id';";

tep_db_query($Query);

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...