RE: [PHP] Displaying value different from actual value

2002-09-11 Thread Jay Blanchard

[snip]
I'm not sure this is possible, but here's what I'd like to do:
I know that in order for a set of records from MySQL to display in
numerical order on a web page, you need to make the column type
Integer, but here's my situation:

I'm creating a database of contracts that my organization has.
Normally, there is a dollar amount on these contracts, and I'd like to
be able to sort by that value (therefore the Integer column type).
However, we have some fee-based contracts, and I'd like a way to display
the amount as Fee Based even though I can't enter this in the database
because of the column type.  Is there a way in PHP to have it display
this although with some kind of if/then statement or something of that sort?

Contract A  Fee-based
Contract B  7
Contract C   1250
Contract D  5
[/snip]

Pseudocode

if($contract_amount ==  || $contract_amount == NULL){
   print(Fee-based);
}

HTH! Peace ...

Jay

*
* Texas PHP Developers Conf  Spring 2003*
* T Bar M Resort  Conference Center*
* New Braunfels, Texas  *
* Contact [EMAIL PROTECTED]   *
*   *
* Want to present a paper or workshop? Contact now! *
*



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Displaying value different from actual value

2002-09-11 Thread Dave Rosenberg

Thanks Jay.  How would that work into something like:

printf(bTotal Budget:/b  $%sbr\n, mysql_result($result,0,budget));

or

printf(trtd%s/tdtd%s/tdtd%s/tdtd%s/tdtd%s/tdtd%s/tdtd%s/td/trtr\n,
 
$myrow[0], $myrow[0], $myrow[4], $myrow[8], $myrow[9],  $myrow[7], 
$myrow[10]);

Thanks,
Dave

Jay Blanchard wrote:
 [snip]
 I'm not sure this is possible, but here's what I'd like to do:
 I know that in order for a set of records from MySQL to display in
 numerical order on a web page, you need to make the column type
 Integer, but here's my situation:
 
 I'm creating a database of contracts that my organization has.
 Normally, there is a dollar amount on these contracts, and I'd like to
 be able to sort by that value (therefore the Integer column type).
 However, we have some fee-based contracts, and I'd like a way to display
 the amount as Fee Based even though I can't enter this in the database
 because of the column type.  Is there a way in PHP to have it display
 this although with some kind of if/then statement or something of that sort?
 
 Contract A  Fee-based
 Contract B  7
 Contract C   1250
 Contract D  5
 [/snip]
 
 Pseudocode
 
 if($contract_amount ==  || $contract_amount == NULL){
print(Fee-based);
 }
 
 HTH! Peace ...
 
 Jay
 
 *
 * Texas PHP Developers Conf  Spring 2003*
 * T Bar M Resort  Conference Center*
 * New Braunfels, Texas  *
 * Contact [EMAIL PROTECTED]   *
 *   *
 * Want to present a paper or workshop? Contact now! *
 *
 
 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Displaying value different from actual value

2002-09-11 Thread Jay Blanchard

[snip]
Thanks Jay.  How would that work into something like:

printf(bTotal Budget:/b  $%sbr\n, mysql_result($result,0,budget));

or

printf(trtd%s/tdtd%s/tdtd%s/tdtd%s/tdtd%s/tdtd%s/t
dtd%s/td/trtr\n,
$myrow[0], $myrow[0], $myrow[4], $myrow[8], $myrow[9],  $myrow[7],
$myrow[10]);
[/snip]

You have to do the test prior to the output, checking the value of $myrow[n]
that represents the contract value. I would have to see more of your code to
see where to implement the test.

HTH! Peace ...

Jay

*
* Texas PHP Developers Conf  Spring 2003*
* T Bar M Resort  Conference Center*
* New Braunfels, Texas  *
* Contact [EMAIL PROTECTED]   *
*   *
* Want to present a paper or workshop? Contact now! *
*



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Displaying value different from actual value

2002-09-11 Thread Zak Greant

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On September 11, 2002 07:57, Dave Rosenberg wrote:
 I'm not sure this is possible, but here's what I'd like to do:
 I know that in order for a set of records from MySQL to display in
 numerical order on a web page, you need to make the column type
 Integer, but here's my situation:

 I'm creating a database of contracts that my organization has.
 Normally, there is a dollar amount on these contracts, and I'd like to
 be able to sort by that value (therefore the Integer column type).
 However, we have some fee-based contracts, and I'd like a way to display
 the amount as Fee Based even though I can't enter this in the database
 because of the column type.  Is there a way in PHP to have it display
 this although with some kind of if/then statement or something of that
 sort?

 Contract A  Fee-based
 Contract B  7
 Contract C   1250
 Contract D  5

  Hi Dave,

  You can also do this in your SQL query.

  For example:

  If your table contains this:
+--+-+
| contract | amount  |
+--+-+
| Jillco   | 100 |
| Jackco   |   1 |
| ChrisInc |NULL |
+--+-+

  The the following select:

SELECT contract, IFNULL(amount, Fee Based) amount FROM contracts;

  will return:
Jillco  100
Jackco  1
ChrisincFee Based

Cheers!
- -- 
Zak Greant [EMAIL PROTECTED]
MySQL Community Advocate

Feed the Dolphin! Order MySQL support from the MySQL developers at
https://order.mysql.com/?ref=mzgr

Gosh, Batman! The nobility of the almost-human porpoise. --Robin
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE9f6iab6QONwsK8bIRAjoJAJ9rswcUKNzR5z9wD7HaKqJ42raiwgCeOzVs
TMSVwY5J18Y3zeEmRut9Wyg=
=G1gi
-END PGP SIGNATURE-


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php