Newbie needs advice on query search

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Paul Revere
    New Member
    • Nov 2006
    • 2

    #1

    Newbie needs advice on query search

    Hi, all of you! I am new to this community. I am a web designer and a friend of mine and I have a server and manage websites (mostly ours but also a few clients). I manage the sites and he does the database management. My friend, an expert at javascript and java programming, is burning out on programming and he doesn't want to do it anymore. I'm stuck, on my own.

    So ... now I have to learn PHP (can't use CGI) and database management. I have no problem accessing the database and managing records, and I have no problem connecting to the database with scripts, but I am just learning how to query and return results.

    I have been pulling my hair out for a week trying to figure out the following:

    I have three independent searches on one page. Each search will call a separate page (I think). On this same page, there are two text searches. I need to be able to have success at the simplest text search first before I can move on to the other text search and the drop down menu search.

    My first query needs to result in three fields being extracted from the database table. In this case it is town, number, and sub_number. The results need to return on a page in rows (unlimited) but each hyperlinked. These hyperlinks will be links to internal HTML pages. That's it. I just need to know the proper query syntax and code. If I can make this work, then I will have a better understanding about how to progress further, especially trying to succeed with three searches from one page. Many thanks to anyone who can help me.
  • exoskeleton
    New Member
    • Sep 2006
    • 104

    #2
    hi sir, i will try to help ...here's the logic...

    page1.html:
    [HTML]
    <form name="form1" method="post" action="page2.p hp">

    firstname: <input name="firstname " type="text" id="firstname" >
    lastname: <input name="lastname" type="text" id="lastname">
    <input type="submit" name="Submit" value="Submit">
    </form>
    [/HTML]

    page2.php
    [PHP]
    // database connection
    // codes here........... .
    // getting the entry from page1
    if (isset($_POST['Submit'])) {

    $firstname = $_POST['firstname'];
    $lastname = $_POST['lastname'];

    $SQL="SELECT * FROM tbl_name WHERE column_uname = '$firstname' AND column_lname = '$lastname'";

    $Execute = @mysql_query($S QL) or die(@mysql_erro r());

    while ($field = @mysql_fetch_ar ray($Execute)) {

    // assigning value to variable from the result
    $firstname = $field['column_uname'];
    $lastname = $field['column_lname'];

    // output the result
    echo $firstname;
    echo $lastname;
    // break
    echo "<br />";

    } // End while
    } // End if

    [/PHP]

    Hope it helps a little sir...Good Luck!!!
    More power...

    Comment

    • Paul Revere
      New Member
      • Nov 2006
      • 2

      #3
      Dear exoskeleton,

      Thank you very much! I spent a week looking for this, and even paid a few dollars for help at Experts Exchange, but it was like pulling teeth to get my "Expert" to give me some proper code. Great job! Thanks a mil!

      Paul Revere

      Comment

      Working...