Hi all, ive got a search function running on a database, the action performed by the form is shown below, within the 'else' statement i would like to show roughly 5 random rows from the sql table (alternative products) if you like.
please find below the script im currently running for the search, the else statment just shows 'no results found' message at the moment.
many thanks in advance for any who can help: -
<table width="40%" border="0" align="center" cellpadding="0" cellspacing="0">
-
<tr>
-
<td><img src="graphics/sunflowerbanner.jpg" width="830" height="227" /></td>
-
</tr>
-
<tr>
-
<td><?php
-
include "flowermatchdbcnx.php";
-
$r = @$_POST['occcas']; //users choice... e.g. birthday, anniversary etc.
-
$s = @$_POST['style']; //display type... modern or classic.
-
$p = @$_POST['price']; //price, need to be within the price range.
-
$t = @$_POST['type']; //flower suitability.... mother father collegue etc.
-
$pak = @$_POST['pacakge']; //flowers packaging
-
-
-
-
//The query to the database
-
-
-
-
$query = ("SELECT * FROM products WHERE style IN ('$s') AND occcas IN ('$r') AND type IN ('$t') AND pacakge IN ('$pak') AND price IN ('$p')");
-
-
-
$result = mysql_query($query);
-
$result_count = mysql_num_rows($result);
-
//while loop to go through database table search all matching records.
-
if ($row = mysql_fetch_array($result)) {
-
//start of table... sets table headers
-
echo "<table border='1'><tr><td>name</td><td>type</td></tr>";
-
//returns results and puts them in ajoining table
-
printf ("<tr><td>%s</td><td>%s</td><td>%s</td></tr></table>",$row[8], $row[6], $row[5]);
-
-
}else {
-
echo "there were no matches found, please find some alternatives below";
-
}
-
-
?></td>
-
</tr>
-
<tr>
-
<td><div align="center"><?PHP echo "$result_count\n"; ?></div></td>
-
</tr>
-
</table>
-
-
-
-
1 1727
You could do another query using Rand() within your query. Such as:
[PHP]
$query = "SELECT * FROM table ORDER BY Rand() LIMIT 2";
[/PHP]
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Beyonder |
last post by:
I have five tables in my database, there are actually NO common fields
between them, not even a KEY or ID or anything like that, except for
the "body" of a blob field. and that text is not identical, just a
portion of that text is identical.
each table has 5 fields, all different except the blob, which is
called "message", so normally I use...
|
by: Voetleuce en f?nsievry |
last post by:
G'day
I'm looking for a script that can search multiple instances of Google
(or other search engines optionally). The user types in a single word
in the text field, presses ENTER or the submit button, and the browser
launches several instances of Google with the single word + other
search terms.
I would like to have this script because...
|
by: Alpha |
last post by:
Hi,
I'm working on a Windows applicaton with VS 2003 on windows 2000. I have a
listbox that I have binded to a dataset table, "source" which has 3 columns.
I would like to display 2 of those columns, "scode" and "sname", as 1 column
(if not possible then 2 columns will be fine) in the listbox. Can the
listbox display 2 columns information...
|
by: tshad |
last post by:
Can you do a search for more that one string in another string?
Something like:
someString.IndexOf("something1","something2","something3",0)
or would you have to do something like:
if ((someString.IndexOf("something1",0) >= 0) ||
((someString.IndexOf("something2",0) >= 0) ||
|
by: M. David Johnson |
last post by:
I cannot get my OleDbDataAdapter to update my database
table from my local dataset table. The Knowledge Base
doesn't seem to help - see item 10 below.
I have a Microsoft Access 2000 database which indexes
computer magazine articles for personal reference.
I am developing a Visual Basic.NET program whose sole
purpose is to enter new...
| |
by: assgar |
last post by:
Hi
Developemnt on win2003 server. Final server will be linux
Apache,Mysql and PHP is being used.
I use 2 scripts(form and process).
The form displays multiple dynamic rows with chechboxs, input box for units of service, description of the service and each row has its own dropdown list of unit fees that apply.
Each dynamically created...
|
by: simon |
last post by:
hello,
relatively new to .net, i'm using vb.net and the 2.0 .net platform
I'm trying to display a grid that has a text box on the left in one
cell (with a hidden ID), which will be associated to multiple rows
(events) on the right. each row on the right will also have a text
box
-------------------------------------------------------
...
|
by: assgar |
last post by:
Hi
Multiple rows of dynamically created data is retrived from the database and displayed properly.
When I get 50 rows displayed scrolling is necessary.
The problem is when I scroll to see the items at the bottom of the list the rows get blurred (jumbled).
To be specific at the top and bottom rows of the list are displayed properly but in...
|
by: imrannawabkhan |
last post by:
I was working on project page where I required to get the row data from mySql db in side the table cells. I knew how to use the php script to get the row data into the table cells like.
Id | Name | Exame | Nos
1 | Nasir | Maths | 25
2 | Abdulla | Maths | 50...
|
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...
|
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...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
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...
|
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...
|
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...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
| |
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...
| |