[PHP] Displaying value different from actual value

2002-09-11 Thread Dave Rosenberg

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


-- 
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




[PHP] Multi-Word Searches

2002-07-02 Thread Dave Rosenberg

I'm putting together a PHP/MySQL search and have run into a minor 
problem.  I have a text field to fill in a keyword on one page and that 
brings up another PHP page 
.com/showkey.php?id=divisionsearch=Bob%20Cobb.  Within that new 
page, you can sort the results by ID, and to do this I made the 
hyperlink go to, for example, showkey.php3?id=projectsearch=$search. 
  When I do this, however, it shortens the $search variable from Bob 
Cobb or Bob%20Cobb to just Bob.  Can anyone help?  Thanks Dave

?php
$db = mysql_connect(localhost, webmstr);
mysql_select_db(contracts,$db);
$result = mysql_query(SELECT * FROM contracts WHERE project = '$search' 
OR agency = '$search' OR location = '$search' OR description = '$search' 
OR account = '$search' OR contact = '$search' OR division = '$search' 
ORDER BY $id,$db);
echo table width=750 border=1 cellspacing=0 cellpadding=1\n;
echo trtd width=255bfont face=arial size=2
a href=showkey.php3?id=projectsearch=$searchProject Title/a/td
td width=50bfont face=arial size=2a 
href=showkey.php3?id=statussearch=$search..


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




[PHP] Preventing Identical Form Fields

2002-02-07 Thread Dave Rosenberg

Pretty simple question, I think:

I'm creating a PHP form and want to prevent users from entering the same 
response in more than one form field.  How can I have the script check 
for identical fields on POST?

Thanks
  Dave


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




Re: [PHP] Preventing Identical Form Fields

2002-02-07 Thread Dave Rosenberg

Thanks Chris, but I have about 10 different fields and want to make sure 
none of those are the same.

Dave

Chris Wright wrote:

 With javascript onSubmit, but that ain't php, so with
 if($form1==$form2){sendthembackwitherrors()}
 
 ---
 Christopher Wright
 303 447 2496 x 107
 www.netinfra.com
 
 We'll take care of it.
 
 Net Infrastructure has definitely helped our company, even though we're
 not in the US, Net Infrastructure has been a key part in the success of
 our business. Juan Carlos Saravia
 
 
 -Original Message-
 From: Dave Rosenberg [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, February 07, 2002 9:30 AM
 To: [EMAIL PROTECTED]
 Subject: [PHP] Preventing Identical Form Fields
 
 
 Pretty simple question, I think:
 
 I'm creating a PHP form and want to prevent users from entering the same
 
 response in more than one form field.  How can I have the script check 
 for identical fields on POST?
 
 Thanks
   Dave
 
 
 


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




Re: [PHP] Preventing Identical Form Fields

2002-02-07 Thread Dave Rosenberg

Thanks y'all!  Everything's workin great now.

Jon Haworth wrote:

With javascript onSubmit, but that ain't php, so with
if($form1==$form2){sendthembackwitherrors()}

Thanks Chris, but I have about 10 different fields and want to make sure 
none of those are the same.

 
 You could brute force it:
 
 $ok = true;
 if ($field1 == $field2 || $field1 == $field3 ||  ) $ok = false;
 if ($field2 == $field3 || $field2 == $field4 ||  ) $ok = false;
 if ($ok == false) sendThemBackWithErrors ();
 
 
 Or you could use array_unique:
 
 // Substitute $_GET if you're using GET instead of POST ;-)
 if ($_POST != array_unique ($_POST)) sendThemBackWithErrors ();
 
 I'm not sure if this second one would work - I don't know if you can do
 straight comparisons of arrays - but the idea is to check that the submitted
 array is the same as the array with all the duplicates removed (if it isn't,
 there was a duplicate).
 
 
 HTH
 Jon
 
 


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