0

Hi, i created a page with some radio buttons that each of them contains a certain number which i send them to action page for searching among the numbers that i inserted inside my table in data base.

but the question is here that i wanna select with some different methods like these samples below :

<?php 
include "../db.php"; $search=$_POST['radio']; //this is my radio value
?>
<?php $sql2=mysql_query("SELECT * FROM `table1` where price1<='$search' ");  

//price1 is one of the columns in my table that contains some different numbers 

$row=mysql_fetch_array($sql2); $product=$row['key']; if($product=='') { echo "404"; } else { ?>
<?php
//error_reporting(0);
//Rows
$imgRow = '<tr>';
$idRow = '<tr>';
 
$nn=6; //Number of items, we split this later
 
$s=mysql_query("SELECT * FROM `table1` where  price1 <= '$search' ");
 
$c=mysql_num_rows($s);
 
if($c%$nn==0){
	$cc=$c/$nn;	
}else{
	$cc=$c/$nn+1;	
}
 
//$cc : Number of pages
 
$ss=@$_REQUEST['ss']; //Start position (eg: 6)
$other_tables = "";
 
if($ss=="" || $ss==null){
	$ss = 0; //Set to zero because it is incremented later
}
 
//Pages
echo "<table border=\"0\" align=\"center\" style=\"text-align:center;\">";
$sql=mysql_query("SELECT * FROM `table1` where price1 <= '$search' ORDER BY `id` DESC LIMIT $ss,$nn");
$inc = 0;
while($r=mysql_fetch_array($sql)){
	$key=$r['id'];
	$id=$r['name'];  
	$img=$r['pic1'];
	if($inc == 0){
		$imgRow .= "<tr>";
		$idRow .= "<tr>";
	}
	$imgRow .= "<td title=\"مشاهده جزئیات محصول\"><a href=\"showproducts1-details.php?id=$key\" target=\"_self\" ><img src=\"../admin/products/productimages1/$img\" width=\"270\" height=\"330\" border=\"1\" /></a></td>";
	$idRow .= "<td><a href=\"showproducts1-details.php?id=$key\">$id</a></td>";
	++$inc;
	if($inc == 3 || $inc == 6 || $inc == mysql_num_rows($sql)){
		//Display Table
		echo $imgRow."</tr>";
		echo $idRow."</tr>";
		echo "</table>";
        echo "<br>";echo "<br>";echo "<br>";
		//To remove extra table
		if(mysql_num_rows($sql) <= 3){
			$inc = 7;
		}
 
		//Reset
		if($inc == 3){
			echo "<table border=\"0\" align=\"center\" style=\"text-align:center;\">";
			$imgRow = "<tr>";
			$idRow = "<tr>";
		}
	}
}
echo "</table>";
echo "<br>";
?>  </td>
  </tr>
</table>

<table width="820" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td>
<?php
$j=0;
echo"page numbers : ";
for($i=1;$i<=$cc;$i++){
	echo"<a href=\"searchproducts1-details.php?ss=$j\">$i</a>";
	echo"|";
	$j=$j+$nn; 
}}
?>
</td>
  </tr>
</table>

so, i don't know what i missed in my query ?

$sql2=mysql_query("SELECT * FROM `table1` where price1<='$search' ");

i should mentioned that i inserted correct numbers for testing.

and what about the query if i m going to search among the 100000 and 200000 ?

Edited by dr.4030: n/a

1
Contributor
1
Reply
2
Views
5 Years
Discussion Span
Last Post by dr.4030
0
$s=mysql_query("SELECT * FROM `table1` where  price1>200000&&price1<300000 ");

$s=mysql_query("SELECT * FROM `table1` where  price1>=300000 ");
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.