الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

how to search mysql?

مغلق
بدأه ephoenix في 7 ديسمبر 2004 · 1 رد · 481 مشاهدة · في منتدى تطوير المواقع بـ PHP
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

hello..

im a beginner in php coding

im trying to implement a code to search for a name of a book in the mysql database

theres something wrong with it, because instead of selecting the query im searching for it shows the whole table i already made in the myadmin

here is the code...

<!doctype html public "-//W3C//DTD HTML 4.0 //EN"> 
<html>
<head>
       <title>Retrieve Records from Db!</title>
</head>
<body>
<?php

 $host      = "localhost";
 $user      = "";
 $password  = "";
 $table     = "books";

       mysql_connect($host,$user,$password) or die("Failed to connect");
       mysql_select_db("POL") or die("Failed to select database");

       //store the results of select in a big array called $result
       $result = mysql_query("select * from $table) or die(mysql_error());

       while ($row = mysql_fetch_array($result))
       $sql = "Find INTO $table (ISBN,Author,Title,Keyword,Category)";
       
           if (mysql_query($sql))

{
           echo "ISBN: ";
           $row["ISBN"];
           echo "<br>";
           echo "AUTHOR: ";
            $row["Author"];
           echo "<br>";

           echo "TITLE: ";
            $row["Title"];
           echo "<br>";

           echo "KEYWORD: ";
           $row["Keyword"];
           echo "<br>";

           echo "CATEGORY: ";
           $row["Category"];
           echo "<br>";}

       mysql_free_result($result); //now free the array.
       echo "<br> <br>"
?>

<!--going back to start page-->
<a href="catalogue.htm"> Click Here to go back to entry page </a>
</body>
</html>

can you please help me in where is going bad??

تم تعديل هذه المشاركة بواسطة walcom في 7 ديسمبر 2004 في 16:46

#2
 $result = mysql_query("select * from $table) or die(mysql_error());

يجب ان تكون كالتالي

 $result = mysql_query("select * from $table." where bookname="C++ programming") or die(mysql_error());

راكان الحنيطي

Be Open Source

opensource-550x4752.gif

هذا الموضوع مغلق.

مواضيع مشابهة