Results 1 to 1 of 1

Thread: Using forms to Query Multiple names

  1. #1
    Join Date
    Aug 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Using forms to Query Multiple names

    I am trying to develope a dynamic website. I am using MySQL and PHP to do so. PLEASE HELP!!!!!!!!!!

    PROBLEM: I need to create a form that will allow my users to query information using a php form. I have wrote one that works. Although it only allows my users to search 1 name at a time (one name meaning "first, middle, last). My users need to be able to search for a minimum of 30 and a maximum of 70 names at one time.

    CODE:

    PHP Code:
    <form action="form4.php" method="POST">
    <table border=0 cellspacing=0 cellpadding=3>
    <td> <tr colspan= 3 allign=center>
    <h3> Input names to Search </h3>
    <td>
    Last Name
    <td>
    First Name
    <td>
    Middle Name
    </table>
    <input type="text" name="lastnameform">
    <input type="text" name="firstnameform">
    <input type="text" name="middlenameform">

    <p>

    <input type="submit" name= "submitbutt" value="get data">


     
     <?php 

    include ('connect.php');

    $dbname "movedb"
    mysql_select_db($dbname); 

    $lastnamesql $_POST ['lastnameform'];
    $firstnamesql $_POST ['firstnameform'];
    $middlenamesql $_POST ['middlenameform'];

    if (!
    $lastnamesql) {
        die (
    mysql_error()); }
    if (!
    $firstnamesql){
        die (
    mysql_error()); }
    if (!
    $middlenamesql) {
        die (
    mysql_error()); }
                      
    $sql mysql_query ("SELECT * FROM lacontribinfo WHERE lastname = '$lastnamesql' AND firstname='$firstnamesql' AND middlename = '$middlenamesql' ");
        
    if (!
    $sql) {
      die(
    '<p>Error retrieving database!<br />'.
          
    'Error: ' mysql_error() . '</p>'); 
    }
    while (
    $row mysql_fetch_assoc ($sql))  {
    print    
    "<h4>""Results returned""</h4>";
    print 
    "<table border=1>";


    print 
    "<td>" "Last Name" "<td>";
    print 
    "First Name" ."<td>";
    print 
    "Middle Name" "<td>";
    print 
    "Committee Name"."<td>";
    print 
    "<tr>" ;
    print 
    "<td>" .$row['lastname'];
    print 
    "<td>".$row['firstname'];
    print 
    "<td>".$row['middlename'];
    print 
    "<td>".$row['committeename'];



    print 
    "</table>";

    }

    ?>
    Last edited by Snookerman; 08-17-2009 at 07:16 AM.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •