How to set a variable as X if Y is true...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Curtis782
Forum Commoner
Posts: 31
Joined: Tue Oct 25, 2005 3:34 pm

How to set a variable as X if Y is true...

Post by Curtis782 »

When I am adding a new record via my add.php script, I'd like to add some code that functions as follows: if an invoice number is entered, set status as "Closed". I thought I could do this with the following code but when I view the data in the DB (after typing in an invoice #), I see it did not work:

Code: Select all

<p><span class="style9">Invoice #</span><br><input name="invoiceNum" id="invoiceNum" type="text" class="style10" size="20"></p><?php
if ($myrow["invoiceNum"] != "") { $myrow["status"] = "Closed"; }
For what it's worth, I do have the following bit of code before the above code:

Code: Select all

<select name="status" class="style12" id="status">
<option selected>Open</option>
<option>In-Process</option>
<option>Closed</option>
</select>
User avatar
Nathaniel
Forum Contributor
Posts: 396
Joined: Wed Aug 31, 2005 5:58 pm
Location: Arkansas, USA

Post by Nathaniel »

Are you running an update query on the database with the $myrow["status"] value after your the first block of code you posted?
Post Reply