473,788 Members | 2,743 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Showing number of records returned after search

66 New Member
Hi all,

ive got a search working, as shown below... on the page i want to show how many records are returned, im sure this is pretty simple but cant really work it out.

any help or advice would be much appreiciated :-)

Expand|Select|Wrap|Line Numbers
  1.   <?php
  2.     include "flowermatchdbcnx.php";
  3.      $r = $_POST['occcas']; //users choice... e.g. birthday, anniversary etc.
  4.      $s = $_POST['style']; //display type... modern or classic.
  5.      $p = $_POST['price']; //price, need to be within the price range. 
  6.      $t = $_POST['type']; //flower suitability.... mother father collegue etc.
  7.      $pak = $_POST['pacakge']; //flowers packaging
  8.  
  9.     //The query to the database
  10.  
  11.  
  12.  
  13.     $query = ("SELECT * FROM products WHERE style IN ('$s') AND occcas IN ('$r') AND type IN ('$t') AND pacakge IN ('$pak') AND price IN ('$p')");
  14.  
  15. switch ($p){
  16.     case "1":$query=($query." WHERE Price BETWEEN 0 AND 20");break;
  17.     case "2":$query=($query." WHERE Price BETWEEN 21 AND 30");break;
  18.     case "3":$query=($query." WHERE Price BETWEEN 31 AND 40");break;
  19.     case "4":$query=($query." WHERE Price BETWEEN 41 AND 50");break;
  20.  
  21.             }
  22.  
  23.  
  24.     $result = mysql_query($query);
  25.     //while loop to go through database table search all matching records.
  26.  
  27.     while ($row = mysql_fetch_array($result, MYSQL_BOTH)) {
  28.  
  29.     echo "name :{$row['Product_ID']} <br>";
  30.     echo "type :{$row['style']} <br>";
  31.  
  32.  
  33. }
  34.  
  35. ?>
  36. </body>
  37.  
hope the code snippet above helps.

secondly, i may as ask while im here, ive had a problem searching for number ranges, i tried using the 'switch' statement above but it didnt work, so ive resorted adding a column stating 10 - 20 etc and it looks up that field in the table, what is the best way to search for a price range without changing the code above too much?
:-)
many thanks in advance
Dec 4 '07 #1
1 1505
Markus
6,050 Recognized Expert Expert
To the first question

i'm thinking you'd need the mysql_num_rows( )

Don't have time for the second question at the moment!

Hope that gets you someehwere.
Dec 4 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
8710
by: Martin Feuersteiner | last post by:
Dear Group I wonder whether you can give me a syntax example for a SQL Statement. Lets assume I've a table containing three columns ContactID (Primary Key), Firstname and Lastname. I would like to write a stored procedure which returns me the first ten records and increments an outside variable each time it runs. E.g If I run it the first time I pass the variable as 0 and it will return
4
38820
by: Lucky | last post by:
I have a vb.net windows app that connects to an access database. The database has 1 table. One of the columns is called "Address". A user enters any address into a textbox (txtValue) then clicks the Find button (cmdFind) and a datagrid displays all the rows with this address. The problem is that it will only find the the address if the user types it exactly as it's entered the the DB. For example: the address column has 123 Anystreet Rd....
3
3717
by: CSDunn | last post by:
Hello, I have a situation with MS Access 2000 in which I need to display report data in spreadsheet orientation (much like a datasheet view for a form). If you think of the report in terms of what a spreadsheet might show, the column names will actually be dynamic, based on data from a SQL Server 2000 database. The row data will also come from the same database. So in this case, I will have a main report and a subreport. I've already tried...
4
14398
by: Chris Tremblay | last post by:
I am trying to figure out how to go about retrieving the number of results returned from my queries in SQL server from VB.NET without using a the Select Count(*) query. The method that I was using was the following: Take the query that I am executing, copy the query and turn it into a count query, run the count query, then execute the original query. The reason for this is so that I can implememt public paging on my website. The...
10
6731
by: Robert | last post by:
How do you get an accurate count of the number of records returned from a query when using linked tables. I have an access 2003 database as a front end to another access 2003 database that contains only tables. I have linked the tables for the front end to the back end database. I am trying to set the recordsource of a form to a query established by the user to narrow the scope but I don't want to display the form if there are no...
15
1792
by: Hexman | last post by:
Hello All, How do I limit the number of detail records selected in a Master-Detail set using SQL? I want to select all master records for a date, but only the first 3 records for the details (based on the primary key of the detail record). I've been trying with "TOP 3", but can't get anywhere. Using Access 2000. Something like: SELECT t1.*, TOP 3 t2.*
4
1255
by: hygum | last post by:
I have a combobox on this testsite: sneleopard.dk/combobox.html it should show all records containing the search string while typing. But sometimes it only shows some of them, why? 1) type "spi" and it shows among others "spinat helbladet" 2) delete the search string and type "bla" 3) it should now among others show "spinat helbladet" again, but it doesnt, why? maybe its because that the function shows first records starting with the...
7
2951
by: underground | last post by:
I have a problem that I've spent countless hours on and I'm more than certain this is a obviuos issue to an expert but I am still learning. I have a paging script that I have modified to display a certian amount of records per page. But when I click on the next link , no new result are displayed it keep displaying the same result. Here is a sample of the script <?php include('hdb.html'); ?> <?php // Get the search variable from URL ...
1
1324
by: webcat | last post by:
hi all, how about this? I want to allow users to click a check box on a form to 'flag for testing' thats fine - works great but what if there is 100 records and the user wants to flag ALL of them for testing?
0
9656
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9498
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10370
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10113
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9969
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8995
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5402
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4074
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2896
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.