elentz Posted July 29, 2007 Share Posted July 29, 2007 Given the code below, I need to run the queries according to the IF statement. Can some one show me how to do this?? Thanks alot! $taxablequote = "SELECT `vtiger_quotes`.`quoteid`, `vtiger_accountscf`.`cf_455` FROM `vtiger_quotes` Inner Join `vtiger_account` ON `vtiger_quotes`.`accountid` = `vtiger_account`.`accountid` Inner Join `vtiger_accountscf` ON `vtiger_accountscf`.`accountid` = `vtiger_account`.`accountid` WHERE `vtiger_quotes`.`quoteid` = '$record'"; $RESULT = MYSQL_QUERY($taxablequote,$conn); if (cf_455 = 1) { $quotetaxable = "update vtiger_quotes set salestax = subtotal * .06 Where quoteid = $record"; $result = mysql_query($quotetaxable,$conn)} else {$quotenontaxable = "update vtiger_quotes set salestax = "0.00" where quoteid = $record"; $result = mysql_query($quotenontaxable,$conn)}; $grandtotal = "update vtiger_quotes set total = subtotal + s_h_amount + salestax - adjustment"; $result = mysql_query($grandtotal,$conn); Quote Link to comment Share on other sites More sharing options...
Daniel0 Posted July 29, 2007 Share Posted July 29, 2007 It is probably if (cf_455 = 1) { which is wrong. It should probably be if ($cf_455 = 1) { Quote Link to comment Share on other sites More sharing options...
Barand Posted July 29, 2007 Share Posted July 29, 2007 or even if ($cf_455 == 1) { Quote Link to comment Share on other sites More sharing options...
elentz Posted July 29, 2007 Author Share Posted July 29, 2007 Well, I tried if ($cf_455 = 1){ and if ($cf_455 ==1){ Neither one worked any other suggestions? Thanks Quote Link to comment Share on other sites More sharing options...
AndyB Posted July 29, 2007 Share Posted July 29, 2007 "didn't work" doesn't help. If $cf_455 is a defined value it should work with the comparison operator == (as Barand posted). On the other hand, if $cf_455 is taken from a database, you need to abstract it from the query result before using it. Quote Link to comment Share on other sites More sharing options...
elentz Posted July 29, 2007 Author Share Posted July 29, 2007 Sorry about the doesn't work. If I comment out the If / Else statements my page loads just fine (without doing what I want). I think you might have something there about abstracting the cf_455. I tried to echo it to the screen without the if/Else and I got nothing, other than what I got with all the if/else commented out. I'll see what I can do to extract it. If I am right I should be OK if/when I can echo it to the screen along with the page itself. Thanks Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted July 29, 2007 Share Posted July 29, 2007 isset($cf_455) and empty($cf_455) might help Quote Link to comment Share on other sites More sharing options...
elentz Posted July 29, 2007 Author Share Posted July 29, 2007 PC Nerd, Where would I apply that? Sorry just enough of a nerd to be dangerous! Thanks Quote Link to comment Share on other sites More sharing options...
AndyB Posted July 29, 2007 Share Posted July 29, 2007 Where would I apply that? Nowhere if the value of $cf_455 is coming from the database - it'll always be 'set' and never 'empty'. Where does $cf_455 come from - database or user input? Quote Link to comment Share on other sites More sharing options...
elentz Posted July 29, 2007 Author Share Posted July 29, 2007 The very first query is where cf_455 comes from. Although I can't get it to even echo on the page. If I run that query in phpmyadmin I get either a 1 or 0 result depending on the quoteid I use. The quoteid is in a session that is used elsewhere on the page in other queries down the page from this one. So I think I might not be getting the cf_455 info and that might be why it is failing. Thanks Quote Link to comment Share on other sites More sharing options...
Barand Posted July 29, 2007 Share Posted July 29, 2007 After the mysql_query, you could extract (mysql_fetch_assoc($RESULT)); Quote Link to comment Share on other sites More sharing options...
elentz Posted July 30, 2007 Author Share Posted July 30, 2007 Well, I think I have the problem identified. I believe I am not getting the value of cf_455. So I have changed my query to only get the field cf_455. I can't seem to get the output of that query. Here is what I have not: $sql = 'SELECT ' . ' `vtiger_accountscf` . `cf_455` ' . ' FROM ' . ' `vtiger_quotes` ' . ' Inner Join `vtiger_account` ON `vtiger_quotes` . `accountid` = `vtiger_account` . `accountid` ' . ' Inner Join `vtiger_accountscf` ON `vtiger_accountscf` . `accountid` = `vtiger_account` . `accountid` ' . ' WHERE ' . ' `vtiger_quotes` . `quoteid` = \ '16124\' LIMIT 0, 30; $RESULT = MYSQL_QUERY($sql,$conn); Print '$cf_455'; At this point if I could get the information onto the page I will be happy. Then I need to get it to get the other queries to work. Thanks for looking at my stuff! Ed Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.