I've searched if the same question exists but i can't find any answer to this or tutorial.
If have have a database table in MySQL (product_table
) with 8 columns starting with product_id
, product_name
, time_created
, reference_code
, product_color
, product_type
, product_price
, product_description
.
I just want to know if it is possible to generate reference_code
based on the fields around it, like product_name
, time_created
.
So let's say:
product_name = Hat
time_created = 2017-09-18 17:08:21
product_color = red
I would like the reference_code(reference_code
) to look like this just as example could be any of the following, it should just be based on the product's own details.
reference_code = Hat2017-09-18red
reference_code = Hat20170918red
reference_code = Hat17:08:21red
Any help or link to a description would be much appreciated.
Of course you can.
The issue is if you want to do it as a proccess in your db or as a result in the PHP.
If you are submiting a form while you proccess the data you can create a variable and assign it to the field in question:
$newvariable = $_POST['a'].$_POST['b'].$_POST['c'];
As a procedure, I recomend you to see this post:
how to write procedure to insert data in to the table in phpmyadmin?