Ok, to preface myself, I’m a chef that does some programming as a hobby. No training in php in the slightest. I’ve been able to do what I’ve needed so far, but I would like some help with some questions I’ve come up with. The owner of the restaurant I work at wants me to create some pages to inventory tracking between stories, order pricing, etc.
1.)When do you decide to create a new database over using a new table? As of right now, I’ve been using just one database and adding whatever tables I need
2.)The one piece of ability for the project I’m about ready to start, is to be able to add new items to a table, which I’ve been able to do. But I’m going to need to call up all the tables rows, which I’ll do on the fly. It needs to handle 2 variables, quantity and price, that change consistently, and two that are static, location and type. Basically I was thinking of using two tables to do this. One listing the item, and the two constants, and also having an auto-id. The second would have row column names based on the auto-id of the first, something like 1Q 1P, 2Q 2P…100Q 100P, etc.Will that actually work for what I want/need to do?
3.)Hopefully final question for now. For the function I need to do, I want to use a while statement. Example in dumbed English
$insert ="";
$value = “”;
$i =1;
while(row = array(search)){
$insert = $insert + $i +"q, "
$iq = $i +“q”;
$ic = $i +“c”;
$insert = $insert + $i +"q, "+ $i +"c, “;
$value = $value + $_POST[$iq] +”, "+$_POST[$ic] + ", ";
$i++;
}
Truncate ", " off of $iq and $ic
Insert into tablename ($insert) Values ($value);
Would that theoretically work for what I Need to do