Jump to content

[SOLVED] Query help


dare87

Recommended Posts

I have this query:

 

$query="SELECT LotNum, Carat, Color, Clarity, Cert, Meas, Polish, Sym, Price FROM selling_data WHERE Shape='$sp'";

if ($crm==$crx) {

$query .= " AND Color='$crm'";

} else {

$query .= " AND Color BETWEEN '$crx' AND '$crm'";

}



if ($clm==$clx) {

$query .= " AND Clarity = '$clm'";

} else {

$query .= " AND Clarity BETWEEN '$clm' AND '$clx'";

}

if ($ctm>0 && $ctx>0 && $ctm!=$ctx) {

$query .= " AND Carat BETWEEN '$ctm' AND '$ctx'";

} elseif ($ctm!='' && $ctm==$ctx) {

$query .= " AND Carat='$ctm'";

} elseif ($ctm=='' && $ctx>0) {

$query .= " AND Carat <='$ctx'";

}



if ($pm>0 && $px>0) {

$query .= " AND Price BETWEEN '$pm' AND '$px'";

} elseif ($pm=='' && $px>0) {

$query .= " AND Price BETWEEN '1.0' AND '$px'";

}

else { $query .= " AND Price > '1'";

}

$query .= " ORDER BY Price ASC, Carat, Clarity ";

 

The problem I am having is that Clarity needs to be a number, but in my db it is not. In by db it is

 

Flawless

VVS-1

VVS-2

VS-1

VS-2

SI-1

SI-2

SI-3

I-1

I-2

I-3

 

I need them to equal

 

Flawless = 1

VVS-1 = 2

VVS-2 = 3

VS-1 = 4

VS-2 = 5

SI-1 = 6

SI-2 = 7

SI-3 = 8

I-1 = 9

I-2 = 10

I-3 = 11

 

How can I do this without changing my db?

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/128622-solved-query-help/
Share on other sites

I must be really stupid, I still don't get it. How does that return Flawless as 1? and VVS - 1 as 2? etc...

 

if ($clm==$clx) {

$query .= " AND Clarity = '$clm'";

} else {

$query .= " AND Clarity BETWEEN '$clm' AND '$clx'";

}

 

This is the part of the code that needs changing. I don't know what to do.

Link to comment
https://forums.phpfreaks.com/topic/128622-solved-query-help/#findComment-666660
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.