Hi
I am trying to order the following query by price when the varaible $concern=="price"; But it is not working. Here is my code. -
-
-
for($key=0 ;$key<count($first);$key++)
-
{
-
if(($first[$key])>0.1){
-
$blank++;
-
$set=$key+1;
-
if($concern=="price"){
-
$sql2 = "SELECT * FROM laptop2 WHERE CODE=$set ORDER BY PRICE";
-
$query2 = $DB->Query($sql2);
-
}
-
-
echo'<p> <hr noshade="noshade" /></p>';
-
}
-
-
if($array = $DB->FetchArray($query2)){
-
-
echo "<table bgcolor=LightGrey border=1>\n";
-
echo"<tr><td>ID</td><td>Brand</td><td>Model</td><td>Processor (GHz)</td>
-
<td>Hard Drive (GB)</td><td> Graphic card (MB)</td>
-
<td>Battery life(Hours)</td><td>Multimedia</td><td>Price (£)</td></tr>\n";
-
// do {
-
-
printf("<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</d><td>%s</d><td>%s</d><td>%s</d> </tr>",$array['CODE'],$array['BRAND'],$array['MODEL'],$array['PROCESSOR (Ghz)'],
-
$array["STORAGE (GB)"],$array["GRAPHIC CARD (MB)"],$array["BATTERY"],$array["MULTIMEDIA"],$array["PRICE"]);
-
// print_r($array);
-
-
}while($array=$DB->FetchArray($query2));
-
echo"</table>\n";
-
Can you spot something?
Thanks
9 1333
I doubt your column 'price' is uppercase (PRICE - like you wrote in your query). Make it lowercase. Also, for the future's sake, you should *really* be using back-ticks around your column names and table names. -
-
SELECT
-
*
-
FROM
-
`laptop2`
-
WHERE
-
`code` = '{$set}'
-
ORDER BY
-
`price`
-
-
However, your columns may be uppercase and, if so, disregard my suggestion.
Thank you for your suggestions but in my columns price is uppercase.
Does your $DB->query() return any errors? Try echo()ing mysql_error() after you have performed the query.
$DB->query() does not return errors. What do you mean by echo()ing mysql_error()?
You can get the last error generated by mysql by mysql_error(). So, after the query, do this: Atli 5,058
Expert 4TB
That would be your standard: - $result = mysql_query($sql) or die(mysql_error());
If you have created yourself a class to handle the database interactions, you should add something to capture the error in case the query fails.
Edit: Seconds to late :]
I already have that added it my class
OK. What exactly is not working?
It is not sorting it by price, the results are still random.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: svilen |
last post by:
hello again.
i'm now into using python instead of another language(s) for
describing structures of data, including names, structure,
type-checks, conversions, value-validations, metadata etc....
|
by: Steven T. Hatton |
last post by:
The following works:
template <typename T>
struct ID3M{
static const T ID;
};
template <typename T>
const T ID3M<T>::ID = {{1,0,0},{0,1,0},{0,0,1}};
|
by: |
last post by:
The data file is a simple Unicode file with lines of text. BCP
apparently doesn't guarantee this ordering, and neither does the
import tool. I want to be able to load the data either sequentially...
|
by: Abdullah Kauchali |
last post by:
Hi folks,
Can one rely on the order of keys inserted into an associative Javascript
array? For example:
var o = new Object();
o = "Adam";
o = "Eve";
|
by: kaosyeti |
last post by:
i have a (hopefully) small problem. i have created a system where a user
enters customer information into a table through a form. this table has no
primary key. there are 9 fields on the form to...
|
by: Beowulf |
last post by:
I have the view below and if I use vwRouteReference as the rowsource
for a combo box in an MS Access form or run "SELECT * FROM
vwRouteReference" in SQL Query Analyzer, the rows don't come through...
|
by: bevanward |
last post by:
Hi All
I am finding unexpected results when inserted into a newly created
table that has a field of datatype int identity (1,1).
Basically the order I sort on when inserting into the table is...
|
by: Hartmut Dippon |
last post by:
Hi all,
I hope somebody can help me with following problem:
I have an application where I can drag&drop files/dirs from within explorer
onto my form.
If multiple files/dirs are selected I...
|
by: Rasjid |
last post by:
Hello,
I have just joined and this is my first post.
I have never been able to resolve the issue of order of evaluation in
C/C++ and the related issue of precedence of operators, use of...
|
by: DanicaDear |
last post by:
Hello again Bytes...I missed you!
First, background:
In a hotstick lab, we ship orders every two years. We ship a new order and the customer uses the new box to return the previous year's order....
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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,...
| |