code_junkie

Setting status of other rows after INSERT

Nov 13th, 2011
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. <?php
  2. include "../../inc/config.inc.php";
  3. $temp = explode("_", $_REQUEST['element_id'] );
  4. $field = $temp[0];
  5. $id = $temp[1];
  6. $textboxval = stripslashes(mysql_real_escape_string(preg_replace('/[$]/',"",$_REQUEST["update_value"])));
  7. $query = "INSERT INTO notes ($field,status,date,c_id) VALUES ('$textboxval','1',NOW(),'$id')";
  8. mysql_query($query);
  9. echo($_REQUEST['update_value']);
  10. ?>
  11.  
  12. UPDATE notes SET status = 0
  13.  
  14. <?php
  15. include "../../inc/config.inc.php";
  16. $temp = explode("_", $_REQUEST['element_id'] );
  17. $field = $temp[0];
  18. $id = $temp[1];
  19. $textboxval = mysql_real_escape_stringstripslashes((preg_replace('/[$]/',"",$_REQUEST["update_value"])));
  20. // set older entries to 0 - to not show but show in history
  21. $hide_notes = "UPDATE notes SET status = 0";
  22. mysql_query($hide_notes);
  23.  
  24. // add new entry with status of 1 to show only latest note
  25. $query = "INSERT INTO notes ($field,status,date,c_id) VALUES ('$textboxval','1',NOW(),'$id')";
  26. mysql_query($query);
  27. echo($_REQUEST['update_value']);
  28. ?>
  29.  
  30. UPDATE notes SET status = 0 WHERE id != $newly_generated_id
  31.  
  32. $insert = mysql_query("INSERT INTO ...");
  33. $last_id = mysql_query("SELECT LAST_INSERT_ID()");
  34. $update = mysql_quqery("UPDATE notes SET status = 0 WHERE id != $last_id");
Add Comment
Please, Sign In to add comment