Simple html php form to insert date and 3 numbers maybe with comma/point to mysql

Hi to all,

it’s been a few days I am trying to make a php/html form that is asking me the date(from date picker), my weight number, my waist number and my burned calories number. All these to be added to a database table I have created already. The numbers may have a comma/point for example I may weight 86.4 or 86,4 kg.
I have also created the columns.
I tried to follow some online examples but I don’t have the time anymore. What is the best thing to do;
Thank you in advance for any replies.

mysql> DESCRIBE fitness;
+----------+---------+------+-----+---------+-------+
| Field    | Type    | Null | Key | Default | Extra |
+----------+---------+------+-----+---------+-------+
| date     | date    | YES  |     | NULL    |       |
| weight   | int(11) | YES  |     | NULL    |       |
| waist    | int(11) | YES  |     | NULL    |       |
| calories | int(11) | YES  |     | NULL    |       |
+----------+---------+------+-----+---------+-------+

If you need a decimal value, then you want to use a decimal type in the database. Which you need depends on the precision and size that you will be storing. https://dev.mysql.com/doc/refman/8.0/en/floating-point-types.html

I’ll also point out that your table needs one if not two additional columns. You need a primary key, that can be a surrogate key, an int field that auto increments; or it can be a composite key binding the date and the next column I think it missing, a user id.

Sponsor our Newsletter | Privacy Policy | Terms of Service