telsiin Posted February 12, 2008 Share Posted February 12, 2008 hello everyone I am trying to detriment if a recorder exist in a table. If the record exist then I would like to change the form button from an Insert record to an Update record as well as the form name. now in this specific test I know that the record does exist however my button won't change to "Update record " am I using the isset/!isset function correctly or should I be using a different function as Always thank to in advance if(!isset($row_Recordset1['CharID'])) { $val="Insert record"; $nam="MM_insert"; if(isset($row_Recordset1['CharID'])) { $val="Update record"; $nam="MM_update"; <td nowrap align="right"> </td> <td><input type="submit" value="<?php echo $val; ?>"></td> </tr> </table> <input type="hidden" name="<?php echo $nam; ?>" value="form1"> <input type="hidden" name="CharID" value="<?php echo $row_Recordset1['CharID']; ?>"> </form> Quote Link to comment Share on other sites More sharing options...
mikefrederick Posted February 12, 2008 Share Posted February 12, 2008 I typically do $a=mysql_query("select * from...where...") and then use if(mysql_num_rows($a)=='0') { insert } else { update } Quote Link to comment Share on other sites More sharing options...
toplay Posted February 12, 2008 Share Posted February 12, 2008 You forgot the closing right curly braces: if(!isset($row_Recordset1['CharID'])) { $val="Insert record"; $nam="MM_insert"; } if(isset($row_Recordset1['CharID'])) { $val="Update record"; $nam="MM_update"; } or can be written like: if(isset($row_Recordset1['CharID'])) { $val="Update record"; $nam="MM_update"; } else { $val="Insert record"; $nam="MM_insert"; } Quote Link to comment Share on other sites More sharing options...
elpaisa Posted February 12, 2008 Share Posted February 12, 2008 for what i undestand about your question, this is more or less your answer: if($row_Recordset1['CharID'] > 1) { $val="Insert record"; $nam="MM_insert"; } else { $val="Update record"; $nam="MM_update"; } 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.