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

محرك البحث

بدأه naz25 في 5 ديسمبر 2011 · 10 رد · 579 مشاهدة · في منتدى تطوير المواقع بـ PHP
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم

عملت محرك بحث ويشتغل بس مشكلته انه نتيجه البحث تظهر مو مرتبه يعني ماتظهر بنفس الجدول

وهذي الصورتين

قبل البحث:

ddfgk3.png

بعد البحث:

6j36zs.png

انا حابب انه يظهر البحث بنفس الجدول مثلا لو بحث عن ورد لونه بنك تختفي الوردات الثانيات وتظهر بس الوردات الي فيها بينك

<?php

session_start();                                                       //starting the session

include("connectdb1.php");                                            //Connect to database through include file

?>

                              <!------------------------------- Shop Form In HTML------------------------------->


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> Rosy Shop - Homepage</title>
<link rel="stylesheet" type="text/css" href="styles.css" />
</head>
<body>
      <center>
      <form action='./searchitem.php' method='get'>
	      <input type='text' name='keywords' size='20' value='' />
		  <input type='submit' size='20' value='Search' />

      </form>
	  </center>
<h1> Rosy Online Shop </h1>
<br />
<br />
<a href="shopcode.txt">View Code</a>
<table border="1">

	<?php

$sql = "SELECT * FROM products;";                                                                   //get everything from products table
$result = mysql_query($sql);

   echo("<center><table border = \"2\">");                                                          //set up a table to show the result 
   echo("<tr><td><b><p>Product Name</b></p></td><td><b><p>Product Image</b></p></td><td><b><p>Description</b></p></td><td><b><p>Price</b></p><td><b><p>Basket</b></p></td></tr>");


		while(list($pid, $pname, $pimage, $pdescription, $pprice) = mysql_fetch_row($result)) {      //loop round each record

			echo "<tr>";

				echo "<td>$pname</td>";                                                                     //display product name from products table in SQL database
			    echo("<td> <img src ='" .$pimage . ".png' alt= 'flower' /></td>");	                        //display product image from products table in SQL database
				echo "<td>$pdescription</td>";                                                              //display product description from products table in SQL database
				echo "<td>$pprice</td>";                                                                    //display product price from products table in SQL database
				echo "<td><a href=\"shoppingbasket.php?action=addItem&ID=$pid\">Add To Basket</a></td>";    //link to shoppingcart.php when user click on Add to basket link

			echo "</tr>";

		}

?>

<?php

                              //*********************************** Search Code In PHP *****************************************//



	if (isset($_GET['keywords']) && trim($_GET['keywords']) != '') {                                        //get the search varible from $keywords
		$keywords = trim($_GET['keywords']);                                                                //trim whitespace from $keywords

		$terms = explode(' ', $keywords);                                                                   // break the string $keywords into an array which will display the matching results from SQL database
		$query = "SELECT * FROM products WHERE ";                                                           // build SQL query which which will select everything from products table

		$i = 1; 
		foreach ($terms as $every) {                                                                       	// Build SQL query for each keyword entered in the input field
			if ($i == 1)
				$query .= "pname LIKE '%$every%' OR pdescription LIKE '%$every%'";                          // product name or product description is matching with the string 
			else 
				$query .= " OR pname LIKE '%$every%' OR pdescription LIKE '%$every%'";

			$i++;                                                                                           // increment $i by 1
		}

		$result  = mysql_query($query) or die('Could not execute query');                                   //get results
		$numrows = mysql_num_rows($result);

		if ($numrows > 0) { 

			while ($row = mysql_fetch_assoc($result)) {                                                     //display the results returned
				$pid = $row['pid'];
			    $pname = $row['pname'];
				$pimage = $row['pimage'];
				$pdescription = $row['pdescription'];
				$pprice = $row['pprice'];


				echo "<p><b>$pname</b><br/></p>";                                                           //display product name of what the user searched for on the screen with break before each record
				echo "<img src ='".$pimage.".png' alt= '' style='top:0px; left:0px;' />";                   //display product image on the screen	
				echo "<p>$pdescription<br/></p>";                                                           //display product descrpition of what the user searched for on the screen with break before each record
				echo "<p>$pprice<br/></p>";                                                                 //display product price of what the user searched for on the screen with break before each record
			}

		} else
			echo "<h1>Sorry, no results found for \"<b>$keywords</b>\" please try another search</h1>";     //display this message if there isn't any results that matching what the user searched for


		mysql_close();                                                                                      // close connection to SQL database
	}
?>

</body>
</html>
#2

طيب مهو انت حاطط صفحة البحث فيها الورد بعدين فيها نتايج البحث

ابدا الجدول قبل الwhile و و اقفله بعديها

@My Twitter

[spacing]

EGYPT

[/spacing]

#3

غيرته اخي لكذا بس لسه شوف كيف يظهر ماتظهر النتيجه بنفس الجدول

هذي الصوره بعد البحث

2u889w6.png

وهذا الكود

<?php

session_start();                                                       //starting the session

include("connectdb1.php");                                            //Connect to database through include file

?>

                              <!------------------------------- Homepage Form In HTML------------------------------->


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> Rosy Shop - Homepage</title>
<link rel="stylesheet" type="text/css" href="styles.css" />
</head>
<body>
      <center>
      <form action='./searchitem.php' method='get'>
	      <input type='text' name='keywords' size='20' value='' />
		  <input type='submit' size='20' value='Search' />

      </form>
	  </center>
<h1> Rosy Online Shop </h1>
<br />
<br />
<a href="shopcode.txt">View Code</a>
<table border="1">


<?php


if (isset($_GET['keywords']) && trim($_GET['keywords']) != '') {                                        //get the search varible from $keywords
		$keywords = trim($_GET['keywords']);                                                                //trim whitespace from $keywords

		$terms = explode(' ', $keywords);                                                                   // break the string $keywords into an array which will display the matching results from SQL database
		$query = "SELECT * FROM products WHERE ";                                                           // build SQL query which which will select everything from products table

		$i = 1; 
		foreach ($terms as $every) {                                                                       	// Build SQL query for each keyword entered in the input field
			if ($i == 1)
				$query .= "pname LIKE '%$every%' OR pdescription LIKE '%$every%'";                          // product name or product description is matching with the string 
			else 
				$query .= " OR pname LIKE '%$every%' OR pdescription LIKE '%$every%'";

			$i++;                                                                                           // increment $i by 1
		}

		$result  = mysql_query($query) or die('Could not execute query');                                   //get results
		$numrows = mysql_num_rows($result);

		if ($numrows > 0) { 

			while ($row = mysql_fetch_assoc($result)) {                                                     //display the results returned
				$pid = $row['pid'];
			    $pname = $row['pname'];
				$pimage = $row['pimage'];
				$pdescription = $row['pdescription'];
				$pprice = $row['pprice'];


				echo "<p><b>$pname</b><br/></p>";                                                           //display product name of what the user searched for on the screen with break before each record
				echo "<img src ='".$pimage.".png' alt= '' style='top:0px; left:0px;' />";                   //display product image on the screen	
				echo "<p>$pdescription<br/></p>";                                                           //display product descrpition of what the user searched for on the screen with break before each record
				echo "<p>$pprice<br/></p>";                                                                 //display product price of what the user searched for on the screen with break before each record
			}

		} else
			echo "<h1>Sorry, no results found for \"<b>$keywords</b>\" please try another search</h1>";     //display this message if there isn't any results that matching what the user searched for


		mysql_close();                                                                                      // close connection to SQL database
	}

?>

	<?php

$sql = "SELECT * FROM products;";                                                                   //get everything from products table
$result = mysql_query($sql);

   echo("<center><table border = \"2\">");                                                          //set up a table to show the result 
   echo("<tr><td><b><p>Product Name</b></p></td><td><b><p>Product Image</b></p></td><td><b><p>Description</b></p></td><td><b><p>Price</b></p><td><b><p>Basket</b></p></td></tr>");


		while(list($pid, $pname, $pimage, $pdescription, $pprice) = mysql_fetch_row($result)) {      //loop round each record

			echo "<tr>";

				echo "<td>$pname</td>";                                                                     //display product name from products table in SQL database
			    echo("<td> <img src ='" .$pimage . ".png' alt= 'flower' /></td>");	                        //display product image from products table in SQL database
				echo "<td>$pdescription</td>";                                                              //display product description from products table in SQL database
				echo "<td>$pprice</td>";                                                                    //display product price from products table in SQL database
				echo "<td><a href=\"shoppingbasket.php?action=addItem&ID=$pid\">Add To Basket</a></td>";    //link to shoppingcart.php when user click on Add to basket link

			echo "</tr>";

		}

?>
</table>
<br />
<!-- link to shoppingcart.php page -->
<center><b><a href="shoppingbasket.php">View Your Shopping Basket</a></b></center>                                      
<br />

</body>
</html>
#4

شوف ده كدة انا عدلته سريعا لضيق الوقت بس ما جربتوش بصراحة .

<?php

session_start();                                                       //starting the session

include("connectdb1.php");                                            //Connect to database through include file

?>

                              <!------------------------------- Homepage Form In HTML------------------------------->


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> Rosy Shop - Homepage</title>
<link rel="stylesheet" type="text/css" href="styles.css" />
</head>
<body>
      <center>
      <form action='./searchitem.php' method='get'>
              <input type='text' name='keywords' size='20' value='' />
                  <input type='submit' size='20' value='Search' />

      </form>
          </center>
<h1> Rosy Online Shop </h1>
<br />
<br />
<a href="shopcode.txt">View Code</a>
<table border="1">


<?php


if (isset($_GET['keywords']) && trim($_GET['keywords']) != '') {                                        //get the search varible from $keywords
                $keywords = trim($_GET['keywords']);                                                                //trim whitespace from $keywords

                $terms = explode(' ', $keywords);                                                                   // break the string $keywords into an array which will display the matching results from SQL database
                $query = "SELECT * FROM products WHERE ";                                                           // build SQL query which which will select everything from products table

                $i = 1; 
                foreach ($terms as $every) {                                                                            // Build SQL query for each keyword entered in the input field
                        if ($i == 1)
                                $query .= "pname LIKE '%$every%' OR pdescription LIKE '%$every%'";                          // product name or product description is matching with the string 
                        else 
                                $query .= " OR pname LIKE '%$every%' OR pdescription LIKE '%$every%'";

                        $i++;                                                                                           // increment $i by 1
                }

                $result  = mysql_query($query) or die('Could not execute query');                                   //get results
                $numrows = mysql_num_rows($result);

                if ($numrows > 0) {

                    // I STARTED HERE HUSSEIN AHMED

                echo "<table width='100%'>
                <tr>
                <td class='head' width='35%'>NAME</td>
                <td class='head' width='40%'>IMAGE</td>
                <td class='head' width='15%'>DESCRIPTION</td>
                <td class='head' width='10%'>PRICE</td>
                </tr>";

                        while ($row = mysql_fetch_assoc($result)) {                                                     //display the results returned
                                $pid = $row['pid'];
                            $pname = $row['pname'];
                                $pimage = $row['pimage'];
                                $pdescription = $row['pdescription'];
                                $pprice = $row['pprice'];


                                echo "<tr><p><b><td>$pname</td></b><br/></p>";                                                           //display product name of what the user searched for on the screen with break before each record
                                echo "<td><img src ='".$pimage.".png' alt= '' style='top:0px; left:0px;' /></td>";                   //display product image on the screen       
                                echo "<p><td>$pdescription</td><br/></p>";                                                           //display product descrpition of what the user searched for on the screen with break before each record
                                echo "<p><td>$pprice</td><br/></p></tr>";                                                                 //display product price of what the user searched for on the screen with break before each record
                        }
                        echo "</table>";

                } else
                        echo "<h1>Sorry, no results found for \"<b>$keywords</b>\" please try another search</h1>";     //display this message if there isn't any results that matching what the user searched for


                mysql_close();                                                                                      // close connection to SQL database
        }



$sql = "SELECT * FROM products;";                                                                   //get everything from products table
$result = mysql_query($sql);

   //echo("<center><table border = \"2\">");                                                          //set up a table to show the result 
   //echo("<tr><td><b><p>Product Name</p></b></td><td><b><p>Product Image</b></p></td><td><b><p>Description</b></p></td><td><b><p>Price</b></p><td><b><p>Basket</b></p></td></tr>");

                                    // I STARTED HERE HUSSEIN AHMED

                echo "<table width='100%'>
                <tr>
                <td class='head' width='35%'>NAME</td>
                <td class='head' width='40%'>IMAGE</td>
                <td class='head' width='15%'>DESCRIPTION</td>
                <td class='head' width='10%'>PRICE</td>
                </tr>";
                while(list($pid, $pname, $pimage, $pdescription, $pprice) = mysql_fetch_row($result)) {      //loop round each record

                        echo "<tr>";

                                echo "<td>$pname</td>";                                                                     //display product name from products table in SQL database
                            echo("<td> <img src ='" .$pimage . ".png' alt= 'flower' /></td>");                          //display product image from products table in SQL database
                                echo "<td>$pdescription</td>";                                                              //display product description from products table in SQL database
                                echo "<td>$pprice</td>";                                                                    //display product price from products table in SQL database
                                echo "<td><a href=\"shoppingbasket.php?action=addItem&ID=$pid\">Add To Basket</a></td>";    //link to shoppingcart.php when user click on Add to basket link

                        echo "</tr>";

                }
                echo "</table>";

?>
</table>
<br />
<!-- link to shoppingcart.php page -->
<center><b><a href="shoppingbasket.php">View Your Shopping Basket</a></b></center>                                      
<br />

</body>
</html>

@My Twitter

[spacing]

EGYPT

[/spacing]

#5

rqvhuw.png

يطلع كذا اخي حسين غلط

#6

لا يا صديقي مظبوطة تمام اهي بس انت ظبط اعدادات الجدول نفسه

<table border="1'>

و مكان حدد عرض الخانات و اتجاهها

                <tr>
                <td width='35%' align="left">NAME</td>
                <td width='40%' align="left">IMAGE</td>
                <td width='15%' align="left">DESCRIPTION</td>
                <td width='10%' align="left">PRICE</td>
                </tr>"

و هكذا انما هو الجدوا ظاهر مظبوط كل واحدة في الخانة بتاعتها الي بايظ التنسيق بس

2

@My Twitter

[spacing]

EGYPT

[/spacing]

#7

عدلته اخي واشتغل الحمدلله بس في شي بسيط لسه غلط ان عنوان الجدول بعد السيرتش يظهر تحت

262470l.png

الكود بعد التعديل

<?php

session_start();                                                       //starting the session

include("connectdb1.php");                                            //Connect to database through include file

?>

                              <!------------------------------- Homepage Form In HTML------------------------------->


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> Rosy Shop - Homepage</title>
<link rel="stylesheet" type="text/css" href="styles.css" />
</head>
<body>
      <center>
      <form action='./searchtable.php' method='get'>
              <input type='text' name='keywords' size='20' value='' />
                  <input type='submit' size='20' value='Search' />

      </form>
          </center>
<h1> Rosy Online Shop </h1>
<br />
<br />
<a href="shopcode.txt">View Code</a>
<table border="1">


<?php


if (isset($_GET['keywords']) && trim($_GET['keywords']) != '') {                                        //get the search varible from $keywords
                $keywords = trim($_GET['keywords']);                                                                //trim whitespace from $keywords

                $terms = explode(' ', $keywords);                                                                   // break the string $keywords into an array which will display the matching results from SQL database
                $query = "SELECT * FROM products WHERE ";                                                           // build SQL query which which will select everything from products table

                $i = 1; 
                foreach ($terms as $every) {                                                                            // Build SQL query for each keyword entered in the input field
                        if ($i == 1)
                                $query .= "pname LIKE '%$every%' OR pdescription LIKE '%$every%'";                          // product name or product description is matching with the string 
                        else 
                                $query .= " OR pname LIKE '%$every%' OR pdescription LIKE '%$every%'";

                        $i++;                                                                                           // increment $i by 1
                }

                $result  = mysql_query($query) or die('Could not execute query');                                   //get results
                $numrows = mysql_num_rows($result);

                if ($numrows > 0) {


				echo "<table width='100%' border='2'>
                <tr>
                 <td class='head' width='20%'><p>Name</p></td>
                 <td class='head' width='1%'><p>Image</p></td>
                 <td class='head' width='50%'><p>Decription</p></td>
                 <td class='head' width='4%'><p>Price</p></td>
				 <td class='head' width='4%'><p>Basket</p></td>

				 </tr>";


                        while ($row = mysql_fetch_assoc($result)) {                                                     //display the results returned
                                $pid = $row['pid'];
                            $pname = $row['pname'];
                                $pimage = $row['pimage'];
                                $pdescription = $row['pdescription'];
                                $pprice = $row['pprice'];


                                echo "<tr><p><b><td>$pname</td></b><br/></p>";                                                           //display product name of what the user searched for on the screen with break before each record
                                echo "<td><img src ='".$pimage.".png' alt= '' style='top:0px; left:0px;' /></td>";                     //display product image on the screen       
                                echo "<p><td>$pdescription</td><br/></p>";                                                             //display product descrpition of what the user searched for on the screen with break before each record                                                                 //display product price of what the user searched for on the screen with break before each record
                                echo "<p><td>$pprice</td><br/></p>";
								echo "<td><a href=\"shoppingbasket.php?action=addItem&ID=$pid\">Add To Basket</a></tr>";
					   }

                        echo "</table>";

                } else
                        echo "<h1>Sorry, no results found for \"<b>$keywords</b>\" please try another search</h1>";     //display this message if there isn't any results that matching what the user searched for


                mysql_close();                                                                                      // close connection to SQL database
        }



$sql = "SELECT * FROM products;";                                                                   //get everything from products table
$result = mysql_query($sql);


                                    // I STARTED HERE HUSSEIN AHMED

                echo "<table width='100%' border='2'>
                <tr>
                 <td class='head' width='20%'><p><b>Product Name</b></p></td>
                 <td class='head' width='1%'><p><b>Product Image</b></p></td>
                 <td class='head' width='50%'><p><b>Product Description</b></p></td>
                 <td class='head' width='9%'><p><b>Product Price</b></p></td>
				 <td class='head' width='4%'><p><b>Basket</b></p></td>


                </tr>";
                while(list($pid, $pname, $pimage, $pdescription, $pprice) = mysql_fetch_row($result)) {      //loop round each record

                        echo "<tr>";

                                echo "<td>$pname</td>";                                                                     //display product name from products table in SQL database
                            echo("<td> <img src ='" .$pimage . ".png' alt= 'flower' /></td>");                          //display product image from products table in SQL database
                                echo "<td>$pdescription</td>";                                                              //display product description from products table in SQL database
                                echo "<td>$pprice</td>";                                                                    //display product price from products table in SQL database
                                echo "<td><a href=\"shoppingbasket.php?action=addItem&ID=$pid\">Add To Basket</a></td>";    //link to shoppingcart.php when user click on Add to basket link

                        echo "</tr>";

                }
                echo "</table>";

?>
</table>
<br />
<!-- link to shoppingcart.php page -->
<center><b><a href="shoppingbasket.php">View Your Shopping Basket</a></b></center>                                      
<br />

</body>
</html>

تم تعديل هذه المشاركة بواسطة naz25 في 6 ديسمبر 2011 في 06:39

#8

ده لانها مكررة من اول السطر 100 انا مش عارف انت كنت عامل اظهار للنتائج تاني عشان كدة عملتلك جدول كمان

امسح من السطر 100 و هي هتظبط ان شاء الله

@My Twitter

[spacing]

EGYPT

[/spacing]

#9

امسح كله من 100 لين تحت؟

لو مسحت من مائه لتحت حيختفي الجدول

echo "<table width='100%' border='2'> 
                // <tr> 
                 // <td class='head' width='20%'><p><b>Product Name</b></p></td> 
                 // <td class='head' width='1%'><p><b>Product Image</b></p></td> 
                 // <td class='head' width='50%'><p><b>Product Description</b></p></td> 
                 // <td class='head' width='9%'><p><b>Product Price</b></p></td> 
                                 // <td class='head' width='4%'><p><b>Basket</b></p></td> 


                // </tr>"; 
                // while(list($pid, $pname, $pimage, $pdescription, $pprice) = mysql_fetch_row($result)) {      //loop round each record 

                        // echo "<tr>"; 

                                // echo "<td>$pname</td>";                                                                     //display product name from products table in SQL database 
                            // echo("<td> <img src ='" .$pimage . ".png' alt= 'flower' /></td>");                          //display product image from products table in SQL database 
                                // echo "<td>$pdescription</td>";                                                              //display product description from products table in SQL database 
                                // echo "<td>$pprice</td>";                                                                    //display product price from products table in SQL database 
                                // echo "<td><a href=\"shoppingbasket.php?action=addItem&ID=$pid\">Add To Basket</a></td>";    //link to shoppingcart.php when user click on Add to basket link 

                        // echo "</tr>"; 

                // } 
                // echo "</table>";
#10

مش كله طبعا امسح و جرب يعني امسح السطور الي فيها الجدول و كدة جرب انا اصلي والله اليومين دول مشغول جدا جدا .

@My Twitter

[spacing]

EGYPT

[/spacing]

#11

اخي حسين غيرته بس شوف المشكله ايش يصير

قبل البحث عنوان الجدول يختفي

30wqw6a.png

وهذا بعد البحث شغال تمام

5r78y.png

<?php 

session_start();                                                       //starting the session 

include("connectdb1.php");                                            //Connect to database through include file 

?> 

                              <!------------------------------- Homepage Form In HTML-------------------------------> 


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<title> Rosy Shop - Homepage</title> 
<link rel="stylesheet" type="text/css" href="styles.css" /> 
</head> 
<body> 
      <center> 
      <form action='./s.php' method='get'> 
              <input type='text' name='keywords' size='20' value='' /> 
                  <input type='submit' size='20' value='Search' /> 

      </form> 
          </center> 
<h1> Rosy Online Shop </h1> 
<br /> 
<br /> 
<a href="shopcode.txt">View Code</a> 
<table border="1"> 


<?php 


if (isset($_GET['keywords']) && trim($_GET['keywords']) != '') {                                        //get the search varible from $keywords 
                $keywords = trim($_GET['keywords']);                                                                //trim whitespace from $keywords 

                $terms = explode(' ', $keywords);                                                                   // break the string $keywords into an array which will display the matching results from SQL database 
                $query = "SELECT * FROM products WHERE ";                                                           // build SQL query which which will select everything from products table 

                $i = 1;  
                foreach ($terms as $every) {                                                                            // Build SQL query for each keyword entered in the input field 
                        if ($i == 1) 
                                $query .= "pname LIKE '%$every%' OR pdescription LIKE '%$every%'";                          // product name or product description is matching with the string  
                        else  
                                $query .= " OR pname LIKE '%$every%' OR pdescription LIKE '%$every%'"; 

                        $i++;                                                                                           // increment $i by 1 
                } 

                $result  = mysql_query($query) or die('Could not execute query');                                   //get results 
                $numrows = mysql_num_rows($result); 

                if ($numrows > 0) { 


                                echo "<table width='100%' border='2'> 
                <tr> 
                 <td class='head' width='20%'><p>Name</p></td> 
                 <td class='head' width='1%'><p>Image</p></td> 
                 <td class='head' width='50%'><p>Decription</p></td> 
                 <td class='head' width='4%'><p>Price</p></td> 
                                 <td class='head' width='4%'><p>Basket</p></td> 

                                 </tr>"; 


                        while ($row = mysql_fetch_assoc($result)) {                                                     //display the results returned 
                                $pid = $row['pid']; 
                            $pname = $row['pname']; 
                                $pimage = $row['pimage']; 
                                $pdescription = $row['pdescription']; 
                                $pprice = $row['pprice']; 


                                echo "<tr><p><b><td>$pname</td></b><br/></p>";                                                           //display product name of what the user searched for on the screen with break before each record 
                                echo "<td><img src ='".$pimage.".png' alt= '' style='top:0px; left:0px;' /></td>";                     //display product image on the screen        
                                echo "<p><td>$pdescription</td><br/></p>";                                                             //display product descrpition of what the user searched for on the screen with break before each record                                                                 //display product price of what the user searched for on the screen with break before each record 
                                echo "<p><td>$pprice</td><br/></p>"; 
                                                                echo "<td><a href=\"shoppingbasket.php?action=addItem&ID=$pid\">Add To Basket</a></tr>"; 
                                           } 

                        echo "</table>"; 

                } else 
                        echo "<h1>Sorry, no results found for \"<b>$keywords</b>\" please try another search</h1>";     //display this message if there isn't any results that matching what the user searched for 


                mysql_close();                                                                                      // close connection to SQL database 
        } 



$sql = "SELECT * FROM products;";                                                                   //get everything from products table 
$result = mysql_query($sql); 


                                    // I STARTED HERE HUSSEIN AHMED 

                // echo "<table width='100%' border='2'> 
                 // <tr> 
                  // // <td class='head' width='20%'><p><b>Product Name</b></p></td> 
                  // // <td class='head' width='1%'><p><b>Product Image</b></p></td> 
                 // // <td class='head' width='50%'><p><b>Product Description</b></p></td> 
                  // // <td class='head' width='9%'><p><b>Product Price</b></p></td> 
                   // <td class='head' width='4%'><p><b>Basket</b></p></td> 


                 // </tr>"; 
               while(list($pid, $pname, $pimage, $pdescription, $pprice) = mysql_fetch_row($result)) {      //loop round each record 

                        echo "<tr>"; 

                                 echo "<td>$pname</td>";                                                                     //display product name from products table in SQL database 
                            echo("<td> <img src ='" .$pimage . ".png' alt= 'flower' /></td>");                          //display product image from products table in SQL database 
                                echo "<td>$pdescription</td>";                                                              //display product description from products table in SQL database 
                                echo "<td>$pprice</td>";                                                                    //display product price from products table in SQL database 
                                echo "<td><a href=\"shoppingbasket.php?action=addItem&ID=$pid\">Add To Basket</a></td>";    //link to shoppingcart.php when user click on Add to basket link 

                        echo "</tr>"; 

                 } 
                 echo "</table>"; 

?> 
</table> 
<br /> 
<!-- link to shoppingcart.php page --> 
<center><b><a href="shoppingbasket.php">View Your Shopping Basket</a></b></center>                                       
<br /> 

</body> 
</html>

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