Present list, is this possible?
Posted: Sun Mar 28, 2004 8:10 am
Hello,
First of all I'm a beginner at php/mysql, so that's why my 'logic' might not be correct.
What I want to do is get our baby presents list online so friends that live far away can choose a present and order it by email.
I have a mysql database with two tables:
a) presents (id;name;fk_customer;sold_yn)
b) customers (id;name;email)
By running a query on sold_yn (=1 or 0) I have a php page that shows me a table with the presents that haven't been selected/sold yet.
I've added a new column to this table with a check box (guess that's my first mistake).
Under the table there's a form with input fields for the name and email of the customer (who will be our friends) and a submit button.
What I'd like to happen is that visitors can check/uncheck the presents they choose, fill in the form underneath the list and then press submit.
By pressing submit they would receive a thankyou email, the shop would receive an email with the order and the database would be updated.
the database update
This is how I would do it in a regular database I'm used to work with:
- the customer info is inserted in the database, the new customer id is stored in a temporary field.
- then there would be a loop on the table to see what records are checked. (id of checked presents stored in a variable? But I don't now how to do that because how am I going to name this variable and it changes row by row...aaargh, so I would need an array or something)
- these checked records are updated in the table (fk_customer- that's just been added to the database and who's id is in a temp field, I guess a variable; sold_yn = 1) - I know the second field is not really necessary but I'd like to keep it that way.
the emails
- one thankyou email is being send to the customer
- one order email is being send to the shop
Can anybody help cause I'm stuck. As far as I understood only records in a form can be updated, but my results appear in a table. Grrrr...I'm going crazy. Do I really have to zoom in the product (with a link or so), then update and then go back to the main page.
I realise this is a long question but if you could put me in the right direction it would be great!
Thank you, thank you, thank you.
First of all I'm a beginner at php/mysql, so that's why my 'logic' might not be correct.
What I want to do is get our baby presents list online so friends that live far away can choose a present and order it by email.
I have a mysql database with two tables:
a) presents (id;name;fk_customer;sold_yn)
b) customers (id;name;email)
By running a query on sold_yn (=1 or 0) I have a php page that shows me a table with the presents that haven't been selected/sold yet.
I've added a new column to this table with a check box (guess that's my first mistake).
Under the table there's a form with input fields for the name and email of the customer (who will be our friends) and a submit button.
What I'd like to happen is that visitors can check/uncheck the presents they choose, fill in the form underneath the list and then press submit.
By pressing submit they would receive a thankyou email, the shop would receive an email with the order and the database would be updated.
the database update
This is how I would do it in a regular database I'm used to work with:
- the customer info is inserted in the database, the new customer id is stored in a temporary field.
- then there would be a loop on the table to see what records are checked. (id of checked presents stored in a variable? But I don't now how to do that because how am I going to name this variable and it changes row by row...aaargh, so I would need an array or something)
- these checked records are updated in the table (fk_customer- that's just been added to the database and who's id is in a temp field, I guess a variable; sold_yn = 1) - I know the second field is not really necessary but I'd like to keep it that way.
the emails
- one thankyou email is being send to the customer
- one order email is being send to the shop
Can anybody help cause I'm stuck. As far as I understood only records in a form can be updated, but my results appear in a table. Grrrr...I'm going crazy. Do I really have to zoom in the product (with a link or so), then update and then go back to the main page.
I realise this is a long question but if you could put me in the right direction it would be great!
Thank you, thank you, thank you.