PHP - Add Or Into If Stament
Hello,
i have the following statement in my code if($slide[active] == "0"){ echo("<div style='background: url(/img/new.png) no-repeat; padding-left: 23px; font-weight: bold;'>$slide[title]. $slide[fname] $slide[lname]</div>"); }else{ echo("$slide[title]. $slide[fname] $slide[lname]"); } ?><?php this makes any database entry thats has field 'active' set to '0' appear in bold and with a 'NEW!' image appear to the side of it. How could i alter this so that it would also make these changes (bold and 'new' image) to any entry that also had field named 'payeddeposit' set to 'no'? many thanks, gavin Similar TutorialsI have a dilemma. Maybe it's an easy fix but i just cant see the solution. My code already works without preparing the sql. The problem is preparing the sql and building the dynamic query. In a nut shell, I have a form with 10 different fields. And depending on which field gets data, I build my query so that it only works on the fields the user typed something into. let me summarize .... I have a basic query that starts off like this $updatestring = ""; $query = "UPDATE table a SET "; if field1 set then $updatestring = $updatestring . " field1 = field1val " if field2 set then $updatestring = $updatestring . " field2 = field1val " if field3 set then $updatestring = $updatestring . " field3 = field1val " if field4 set then $updatestring = $updatestring . " field4 = field1val " and so on .... Finally $query = $query . $updatestring which can end up looking like: UPDATE table a SET field1 = field1val, field3 = field1val .... depending on which fields were set. I take care of commas and so on. Like I said this works. However, to prepare the statement really complicates things because if it looks like this: UPDATE table a SET field1 = ? , field3 = ? how do I know which variable to bind to the param out of the 10 possible fields ? How do I build the string types and place them in the right order? Do you see my dilemma? mysqli_stmt_bind_param($stmt, 'ii', $field1val, $field3val); Any help would be appreciated. I will also post this in the mysql section. Thanks, JT then |