Click to See Complete Forum and Search --> : Calling SQL DB


JoseSilva
12-05-2006, 08:46 AM
Hi

I hpe I can explain my problem.

I have on MySQL DB
1. pricemin
2. pricemax
3.priceperday
4.priceperweek
5.pricepermonth
6.priceperyear

questions:How...

1. to show only pricemin even if the other variables are or not filled
2. to show only pricemin and pricemax even if other variables are for not filled
3. to show only priceperday even if the other are or not filled ...and so on

Here it is what did I have done it:

$order=0;
$sql="select * from prime where situation=1 and image!=0 order by id desc limit 6";
$result= mysql_db_query("prime", $sql);
while ($regist=mysql_fetch_array($result)) {
$id=$regist["id"];
$title=$regist["title"];
$pricemin=$regist["pricemin"];
$pricemax=$regist["pricemax"];
$priceperday=$regist["priceperday"];
$priceperweek=$regist["priceperweek"];
$pricepermonth=$regist["pricepermonth"];
$priceperyear=$regist["priceperyear"];
$type=$regist["type"];
$ref=$regist["reference"];
$city=$regist["city"];
$state=$regist["state"];
$country=$regist["country"];
$datain=$regist["data_in"];
$pricemin=number_format($pricemin,2,",",".");
$pricemax=number_format($pricemax,2,",",".");
$priceperday=number_format($priceperday,2,",",".") ;
$priceperwek=number_format($priceperwek,2,",",".") ;
$pricepermonth=number_format($pricepermonth,2,",", ".");
$priceperyear=number_format($priceperyear,2,",",". ");
$description=$regist["description"];
$ordem++;
echo "


<table border='0' cellpadding='0' cellspacing='0' style='border-collapse: collapse' width='100%' id='AutoNumber1'>
<tr>
<td width='75%' colspan='3' bgcolor='#e5d387'><font FACE='verdana' SIZE='1' COLOR='#0000FF'><b>
$tipo ,&nbsp; For Sale in or To Let &nbsp;$cidade,&nbsp; $sate &nbsp;<font FACE='verdana' SIZE='2' COLOR='#006000'>$country</font></b></td>
<td align='right' width='25%' bgcolor='#e5d387'><font FACE='verdana' SIZE='1' COLOR='#ff0000'><b>
€ $pricemin - € $pricemax - € $priceperday - € $priceperweek - € $pricepermonth - - € $priceperyear</font></b></td>
<td width='2%' bgcolor='#e5d387'></td>
</tr>
<tr>
<td align='right' width='1%'><a href='ver_imo.php?lang=$lang&id=$id'><IMG border='0'
SRC='admin/get_miniature.php?img=2&client=$id&max_width=80'></a></td>
<td width='2%'></td>
<td width='100%' colspan='2' valign='top'><p class='text' align='justify'><font FACE='verdana' SIZE='2' COLOR='#006000'><b>$title</b><font FACE='verdana' SIZE='1' COLOR='#000000'>- $description</td>
<td></td>
</tr>
<tr>
<td width='100%' colspan='5'></td>
</tr>
</table>

";
}

What did I got? I did get the desctitpion, city, estate,country, type, ref, Id right. But the price I do get: 0,00 - 0,00 - 0,00 - 0,00 - 0,00 - 0,00 where suppose to get eighteir the first or the second one or both, or the third or fourth or fifht or sixth or the last four or all at same time depending of the situation.

Did I make mself clear? Any help?

Thanks

chazzy
12-05-2006, 07:53 PM
I'm not sure what you mean. are you trying to say that out of the 6 columns, only 1 will have a value, and you only want to get that 1?

sounds like a case statement would be your best bet.

JoseSilva
12-06-2006, 05:38 AM
I'm not sure what you mean. are you trying to say that out of the 6 columns, only 1 will have a value, and you only want to get that 1?

sounds like a case statement would be your best bet.


Hi

I solved the situation using one variable for each one at diferent places.

Thanks anyway