Page 1 of 1

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

Posted: Wed Nov 02, 2005 3:42 pm
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>

Posted: Wed Nov 02, 2005 4:27 pm
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?