#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    1
    Rep Power
    0

    Need help on php, databases in dreamweaver cs6


    Hi all,

    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 ?

    Thanks!
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,466
    Rep Power
    594
    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.
  4. #3
  5. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,317
    Rep Power
    7170
    How can I let the username textfield to be automatically filled as the user has logged in at the login page initially.
    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.

    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?
    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.

    My 3rd database (reservation) will capture the info of username, title, price, and number of orders.
    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.

    Do i use insert record or update record?
    If the record already exists that you update it, if it doesn't, then you insert it.

    Do i create a relational table in phpmyadmin by linking it with the keys from tables (book and users)?
    This is not necessary.

    Will this be a many to many relationship?
    Yes

    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 ?
    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.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    10
    Rep Power
    0
    @E-Oreo. I think what is meant by the 'date of collection' is the day the user can collect the book.

    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 ?
    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.

IMN logo majestic logo threadwatch logo seochat tools logo