Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 2 of 2
  1. #1
    Senior Member
    Join Date
    Feb 2005
    Location
    Canada
    Posts
    435
    Member #
    8983
    I am kind of new to database scripting i want to be able to search the database for a specific term supplied by the user and if found (it will more then likely be an exact match) add the value specified to a variable in php
    this is for a city search for a delivery company

    simplified:
    user types in term (barrie)
    php searches for barrie in the data base
    once found it gives the price for one of three types of delivery depending on users choice
    this price is stored in a variable for later manipulation
    Thee Pyro Wolf

  2.  

  3. #2
    Senior Member
    Join Date
    May 2003
    Location
    UK
    Posts
    2,354
    Member #
    1326
    So, when you say "it gives the price for one of three types of delivery depending on users choice", is this choice chosen by the same form that submits the city?

    If not, this code should return the price from a table where the city column's value is equal to the user submitted vakue.

    PHP Code:
    // Connect to DB

    $city $_POST['city'];
    $select_q "SELECT price FROM table WHERE city = '$city'";
    $result mysql_query($select_q) or die("error in selecting price, " mysql_error());
      while(
    $row mysql_fetch_array($result))
        {
          
    extract($row); // extract means we can skip the $row[''] part
         
    $dbprice $price;
        } 


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 08:37 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com