March 29th, 2013, 11:40 AM
Need help on php, databases in dreamweaver cs6
I need to clarify that I am very new to phpmyadmin, mysql, and databases. This is what i am stucked with.
Currently, I have one table (book) which contains these attributes (ISBN(primary key), title, author, publisher, price etc) in my database (book)
I have the other table (users) which contains these attributes (username (primary key), password, name, DOB etc) in my database (user)
Let me explain the series of steps first. An user logs in on the log in page successfully, and he will be directed to the main page, then he will type or select his search terms, then the results page will display the relevant results in the master list, then he will select the specific result to go to the detailed page containing more information.
What I want now is to create a reservation page. If the user likes the specific book in the detailed page, he can click reserve it, and will be directed to the reservation page.
I intend to have these search textfields: Username, Title, Price, Number of orders.
How can I let the username textfield to be automatically filled as the user has logged in at the login page initially. Also, how can I let the title and price textfield to be automatically filled, as the user has clicked reserve it at the specific detailed page? I intend that the user just key in number of orders and press submit button. My 3rd database (reservation) will capture the info of username, title, price, and number of orders. Do i use insert record or update record?
Do i create a relational table in phpmyadmin by linking it with the keys from tables (book and users)? Will this be a many to many relationship? I intend my third table to have these attributes (reservation no (primary key), username, title, price, no, of orders and date of collection?
Moreover, how do I auto generate the date of collection (for e.g. it will be 5 days after the point of time when the user click the submit button) in my third table ?
March 29th, 2013, 01:05 PM
There are a several of possibilities depending on how you have your scripts set up. It sounds like you can do all of this from a single page. However, if you want to use multiple pages then you can communication between them with session variables.
There are 10 kinds of people in the world. Those that understand binary and those that don't.
March 30th, 2013, 10:26 AM
Presumably your login system uses a session variable to store some reference to the user who is currently logged in; you would use that value.
Pass an identifier for the book that they clicked on, then use a select query to retrieve the rest of the data from the database. However, unless you intend to allow the user to change the price of the book, you shouldn't use a textfield for it.
You shouldn't use 'title' as your foreign key in this table; you should use ISBN because that's the primary key in your books table.
If the record already exists that you update it, if it doesn't, then you insert it.
This is not necessary.
I don't understand this question. What is a date of collection?
Most of the people here don't use dreamweaver. I can tell you how to do something in PHP, but I can't tell you how to use dreamweaver to do it.
March 30th, 2013, 12:32 PM
@E-Oreo. I think what is meant by the 'date of collection' is the day the user can collect the book.
You are going to need to use the MySQL function DATE_ADD. So, for example lets say the user submitted the reservation on '2013-03-30' you would need to do the following to get the 5 days after submission DATE_ADD('2013-03-30', INTERVAL 5 DAY). This would give you the collection date as '2013-04-04' . I recommend you have a column that stores the date of submission.