/    Sign up×
Community /Pin to ProfileBookmark

"IF" situation

Help:

I have 4 entries in data base as follows: priceperhour, priceperday, pricepermonth,priceperyear

Only one entry is filled up, remainining the other three as zero

How can I call the only one entry that is used?

If I say $priceperhour $priceperday $pricepermonth $priceperyear it shows 0,00 0,00 0,00 0,00

I think that can be solved with a “If” “and” “or” “else” situations. But how?

Thanks ?

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@NogDogDec 03.2006 — If using MySQL (not sure what other DBMS's have this function):
<i>
</i>SELECT GREATEST(priceperhour, priceperday, pricepermonth, priceperyear) AS price
FROM table_name
Copy linkTweet thisAlerts:
@JoseSilvaauthorDec 03.2006 — If using MySQL (not sure what other DBMS's have this function):
<i>
</i>SELECT GREATEST(priceperhour, priceperday, pricepermonth, priceperyear) AS price
FROM table_name
[/QUOTE]



Thank you for your reply.

As a new on this here it is the way I did but does not work:

$order=0;

$sql="select * from prime where situatio=1 and image!=0 order by id desc limit 3";

SELECT GREATEST(priceperhour, priceperday, pricepermonth, priceperyear) AS price FROM prime

$result= mysql_db_query("habit", $sql);

while ($regist=mysql_fetch_array($result)) {

$id=$regist["id"];

$place=$regist["place"];

$type=$regist["type"];
$ref=$regist["reference"];
$city=$regist["city"];
$datain=$regist["data_in"];
$title=$regist["title"];

$price=number_format($price,2,",",".");
$order++;


Can you help? I do use MySQL

Thanks
Copy linkTweet thisAlerts:
@chazzyDec 03.2006 — For one, you need to use proper syntax.

In this case, can you expand the * in the "select *" part of your query?

once you do that, replace columnList below

[code=php]
$sql="select [columnList],GREATEST(priceperhour, priceperday, pricepermonth, priceperyear) AS price from prime where situatio=1 and image!=0 order by id desc limit 3";
[/code]
Copy linkTweet thisAlerts:
@JoseSilvaauthorDec 03.2006 — Thank you guys.

It works
×

Success!

Help @JoseSilva spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...