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> Link to comment https://forums.phpfreaks.com/topic/90768-issetisset-function/ 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 } Link to comment https://forums.phpfreaks.com/topic/90768-issetisset-function/#findComment-465272 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"; } Link to comment https://forums.phpfreaks.com/topic/90768-issetisset-function/#findComment-465273 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"; } Link to comment https://forums.phpfreaks.com/topic/90768-issetisset-function/#findComment-465276 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.