Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.