Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

PHP and MySQL question

Options
  • 25-09-2008 3:12pm
    #1
    Registered Users Posts: 5,356 ✭✭✭


    Hi all,

    I've given myself a little task and it's sort of part of a project in work. But if i cant do it it's no big deal they will just drop it lol


    So i've a small access database with dealers we have across Ireland.

    The way it should work is like this,

    When someone starts to look for a dealer they will 1st have to select there "County" then they will select product type "Plasma / Incar etc"

    after these to selections a list of dealer in there selected county should appear in a list with Name, Address and Phone number.

    I'm totally new to this so I'm learning,

    I've been looking on php.net but i dont really know where to start.


    My test database is small and has the following fields/tables
    ID | company | address1 | address2 | county | phone | email | product1 | product2

    and i've added in some random info.
    Whats my next step?


Comments

  • Closed Accounts Posts: 12,382 ✭✭✭✭AARRRGH


    The form will be used to create the sql, so if they choose "Dublin" and "County" and submit the form, the next page which is a PHP page will read these values and create SQL based on them. This will be something along the lines of
    $county = $_POST["county"]; // county is the name of the form field
    $product = $_POST["product"]; // product is the name of the form field
    

    Your SQL would then look something like
    select * from table where county = $county and product = $product
    

    You then extract the results which are returned and display them on the screen.

    Note your table isn't well designed. Read about "normalisation" to see what I mean.

    You should probably have it like
    Company table: ID | Name | Address1 | Address2
    Product table: ID | Company_ID | Name
    

    Or something like that.


  • Registered Users Posts: 5,356 ✭✭✭NeVeR


    Hi thanks.

    I'll have a go and see how i get on,

    Just a questions

    Where you have $county is that linking to my database table named $county ?


  • Closed Accounts Posts: 12,382 ✭✭✭✭AARRRGH


    No, $county is a variable which contains whatever county value the user chose from the html form.

    So -

    User submits some information from the form, including a county and a product
    You collect this information and put it into variables, such as $county and $product
    You then use these variables in your SQL

    A great book on PHP and MySQL is "PHP & MySQL Web Development" by Luke Welling. It's well worth the investment.


  • Closed Accounts Posts: 975 ✭✭✭squibs


    A great book on PHP and MySQL is "PHP & MySQL Web Development" by Luke Welling. It's well worth the investment.

    +1
    One of the best technical books I've read (and I've read many)


  • Registered Users Posts: 9,579 ✭✭✭Webmonkey


    squibs wrote: »
    +1
    One of the best technical books I've read (and I've read many)
    Yep its what got me started too


  • Advertisement
  • Users Awaiting Email Confirmation Posts: 351 ✭✭ron_darrell


    I realise you're new so this suggestion may not be ideal but simple AJAX would deliver what you're looking for without all the back and forths for the user. As the drop down for the county is selected it updates the next drop down with town or dealer as appropriate and so on. http://www.w3schools.com/php http://www.w3schools.com/ajax http://www.tizag.com/phpT/ are all good reference sites for newbies.

    Regards,
    RD


Advertisement