#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2000
    Posts
    9
    Rep Power
    0
    I am trying to serach a record from mysql table with php query.

    following is the code.

    when we use mysql_select_db();
    what should be the datbase name.

    when we use mysql_quer() we give table name.
    how this table name is different from the databse name<html>

    <head>

    <title> SAVDHAN.COM SEARCH </title>
    </head>

    <body bgcolor="#C0C0C0" topmargin="40" leftmargin="50">

    <h1 ALIGN=CENTRE><font color="#FF0000">SEARCH ON INDIVIDUAL NAME</font> </h1>

    <p>&nbsp;</p>

    <hr>

    <hr>

    <?php

    /* Check that Fst name or sr name is inserted for serach */
    if ($submit)
    {

    if (!$Fst_name & !$Sr_name)

    {

    $error = "Sorry! Enter the LASt NAME or FIRST NAME to get the serch Result!";

    }

    else

    {

    // process form

    //echo "Thank You!";


    // Connect to MySQL database and open the required table

    $db = mysql_connect("localhost", "root");

    mysql_select_db("test1",$db);


    $result = mysql_query ("SELECT * Amount FROM test1 WHERE First_name = "Fst_name",$db);


    if ($myrow = mysql_fetch_array($result))
    {

    echo "<table border=1>n";


    do {

    // list the search details if it is an indiviual

    if (!$myrow["Comp_name"])

    {
    echo "<tr><td>Name</td><td>Bank Name</td><td>Amount</td></tr>n";


    printf("<tr><td>%s %s</td><td>%s</td><td>%s</td></tr>n", $myrow["First_name"], $myrow["Sur_name"], $myrow["Bank_name"], $myrow["Amount"]);

    }


    } while ($myrow = mysql_fetch_array($result));


    echo "</table>n";]=74
    }


    }

    }

    ?>


    <form method="POST" action="<?php echo php_self ?>">

    <p>Last Name <input type="text" size="20"
    maxlength="40" name="Sr_name"> </p>

    <p>First Name <input type="text" size="20"
    maxlength="40" name="Fst_name"></p>

    <p><input type="submit" name="indv_search" value="Search"> <input
    type="reset" name="indv_rest" value="Reset"></p>

    </form>

    <p>&nbsp;</p>

    <hr>

    <hr>
    </body>
    </html>


  2. #2
  3. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    19
    The database is the name of the database, the table name is the name of the table. A database is a collection of tables. It hasn't any records of it's own:

    Database
    |
    --Table
    | |
    | -- Records
    | |
    | -- Columns
    |
    --Table
    | |
    | -- Records
    | |
    | -- Columns

Similar Threads

  1. Check MySQL Version thru PHP
    By wolftrap1 in forum PHP Development
    Replies: 2
    Last Post: February 11th, 2004, 09:51 PM
  2. Replies: 0
    Last Post: January 30th, 2004, 02:22 PM
  3. MySQL Select query
    By MrTee1 in forum MySQL Help
    Replies: 0
    Last Post: January 30th, 2004, 12:16 PM
  4. PHP to import csf into mysql
    By benjimcc in forum PHP Development
    Replies: 1
    Last Post: January 28th, 2004, 01:26 PM
  5. PHP 5 (MYSQL vs. SQLite)
    By ignition in forum PHP Development
    Replies: 1
    Last Post: January 23rd, 2004, 01:13 PM

IMN logo majestic logo threadwatch logo seochat tools logo