I need some help with a mysql database

Discussion in 'MySQL' started by rhoula, Oct 9, 2008.

  1. #1
    Hi...
    I have a Mysql database with the following fields:

    id
    Name
    Phone
    Address1
    Address2
    Apt
    direction
    Orderfor
    card1
    cc2
    cc3

    All this information is stored in a table called "add_customer"

    I m trying to make a form that will search the database depending on the argument i enter.
    Example if I want to search by phone number I can just scroll down to phone and enter the phone number then the form will display the information inside another form which I can change and send back to the database.
    Please someone help.
    I will return the favor.
    Thank you
     
    rhoula, Oct 9, 2008 IP
  2. gzav

    gzav Peon

    Messages:
    46
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I'm having a hard time understanding what it is you want. Are you trying to develop a form that will edit an existing customer? What do you mean by a form within a form?
     
    gzav, Oct 9, 2008 IP
  3. rhoula

    rhoula Well-Known Member

    Messages:
    875
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    145
    #3
    Thank you for writing back. What I need is a form that will display information from a database. depending on the search argument. Let's say I enter a phone number and there is a customer with the phone number stored in the database. I want to be able to retrieve all the information, then be able to change the information if for example the customer moves to a new address.

    Thank you so much
     
    rhoula, Oct 9, 2008 IP
  4. gzav

    gzav Peon

    Messages:
    46
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Do you have any programming experience and just need guidance?

    To check for a person with a certain phone number you would do:
    $query = mysql_query("SELECT * FROM add_customer WHERE Phone = '" . $_GET['phone_search'] . "'");
    if(mysql_num_rows($query) > 0)
    echo "we found someone...";
    Code (markup):
    To get the persons information from the database that has a matching phone number:
    $row = mysql_fetch_array($query);
    echo "His name is " . $row['Name'];
    Code (markup):
    And to update a value you would do
    $query = mysql_query("UPDATE add_customer SET Phone = '" . $_GET['NEW_PHONE_NUMBER'] . "' WHERE Id = '" . $_GET['USER_ID'] . "'");
    if(mysql_num_rows($query) > 0) echo "Successfully updated"; else echo "Failed to update";
    Code (markup):
    Is that what you wanted?
     
    gzav, Oct 9, 2008 IP
  5. rhoula

    rhoula Well-Known Member

    Messages:
    875
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    145
    #5
    Thank you very much for your help.
    Unfortunately I don't know much about programming so if you could guide me I would be very grateful.
    How can I use the script you sent me?
    Thank you
     
    rhoula, Oct 9, 2008 IP