Add, Search, Delete Records from Database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • donno
    New Member
    • Apr 2007
    • 3

    Add, Search, Delete Records from Database

    Hi everyone, Im new to php and ive to create a website for uni with the discription below...

    Design a MySQL database which contains customer information, including name, address, post code, telephone number, email address, type (saler or buyer) and appointment.

    The web site provides three main functions:
    (1) Allow the agent to add new customer to the database
    (2) Allow the agent to search a customer by name
    (3) Allow the agent to remove a customer information from the database


    Can anyone help me?? I havent a clue, where to start or wot to do.

    Hope for a response soon,

    Many thanks guys

    Donno
  • exoskeleton
    New Member
    • Sep 2006
    • 104

    #2
    hi good sir... there are so many tutorials about adding,deleting and searching on the web. try to search...

    but i will give you very basic code for adding :)

    for example, a form: page1.php

    [HTML]<form action="page2.p hp" method="post" name="addrec">
    <input type="text" name="fname" value="">
    <input type="submit" name="submit" value="Add">
    </form>[/HTML]

    page2.php

    [PHP]$fname = $_POST['fname'];

    // place your database connection here

    $sql ="INSERT INTO table_name (firstname) VALUES ('$fname')";
    $exe = mysql_query($sq l);[/PHP]

    hope it'l helps....more power

    Comment

    • exoskeleton
      New Member
      • Sep 2006
      • 104

      #3
      in searching lets say page1.php still the form to be used.....

      page3.php

      [PHP]$fname=$_POST['fname'];

      // place your database connection here
      $dbhost = "localhost" ;
      $dbuser = "mysql";
      $dbpass = "dbpassword ";
      $dbname = "test";
      //Connect to MySQL Server
      mysql_connect($ dbhost, $dbuser, $dbpass);
      //Select Database
      mysql_select_db ($dbname) or die(mysql_error ());

      $sqlsearch = "SELECT * FROM table_name WHERE firstname = '$fname'";
      $exe = mysql_query($sq lsearch);

      while($field = mysql_fetch_arr ay($exe)) {

      $firstname = $field['firstname'];
      echo $firstname;

      }[/PHP]

      more power...

      Comment

      Working...