Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search script in MYSQL

Status
Not open for further replies.

mercury1

Programmer
Sep 23, 2002
8
US
I wish to create a search script in MYSQ on Linux server.

I have the following fields:

PART NUMBER
MFR
QUANTITY

Thank you for any help or advise you can offer.

Mike
 
only in MySql ? I would suggesuse of a sciptin language like PHP. However, MySql uses SQL - SELECT to get data



[ponder]
----------------
ur feedback is a very welcome desire
 
I am open to any suggestions. Can you provide a PHP script.

Thank you!!!
 
Steps are
1. connect to MySql with hostname, username, passwd,
2. select ur database
3. get ur query handle
4. get yr data in yr way. I got in HTML tables. For proper viewing of this file u have to put ithe following code in a webserver and view as web page

u can execute this query in php directly as php filename.php

Last but not least get a good book on PHP and visit
Code:
<HTML>
<BODY>
<?PHP
        $host = &quot;linux&quot; ;
        $user = &quot;MyName&quot; ;
        $paswd = &quot;MyPasswd&quot; ;
        $db = &quot;MyDb&quot; ;
        $qry = &quot;SELECT * From MyTable&quot; ;
        mysql_connect(&quot;$host&quot;, &quot;$user&quot;, &quot;$paswd&quot;)
                or die(&quot;No connection to host&quot;) ;
        mysql_select_db(&quot;$db&quot;) or die(&quot;Cannot select $db&quot;) ;
?>
<!--
        Could be wriiten with PHP block using print comd.
        Out to show that only needed command in PHP to avoid uneccessary parsing overheads
-->
<TABLE>
<?
        $result = mysql_query($qry) ;

        while ($row = mysql_fetch_array($result))
        {
                print(&quot;<TR>
                                <TD>$row[PrtNo]</td>
                              <TD>$row[Mfr]</td>&quot;) ;

                $no = $row['Qty'] * 5 ;

                // Please note that case the filed name is in quotes.

                /* Earlier were already in double quotes so no need to  quote twice
                 Single and double quotes have behaviourail diiference
                   When field names are used as array subscript names they should match case and spelling of the field in SQL.
                i.e. if SELECT Prtno, mfr then subscript would be
                $row[Prtno] or $row[mfr]
        */
                print(&quot;<TD>$no</td></tr>&quot;) ;
        }
?>
</table>
</body>
</html>
for further PHP queries got o PHP forum at forum434



[ponder]
----------------
ur feedback is a very welcome desire
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top