User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 330,298 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,830 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Nov 26th, 2007
Views: 1,601
I wont describe whats here, just figure it out yerself, enjoy =)
Last edited : Mar 27th, 2008.
php Syntax | 1 stars
  1. // Mass Language Manager
  2. function SaveAll() {
  3. // adding
  4. $_REQUEST['val'] = array_unique($_REQUEST['val']);
  5. foreach ($_REQUEST['val'] as $key => $keyValue) {
  6. if (!$keyValue OR !strlen(join('',$_REQUEST['new'][$key]))) continue;
  7. if (!($keyValue = alnum($keyValue))) continue;
  8. if (mb_strlen($keyValue)>25 OR $this->checkForKey($keyValue)) continue;
  9. foreach ($_REQUEST['new'] as $i => $arrLangVal) {
  10. foreach ($arrLangVal as $lang => $value) {
  11. if ($value) {
  12. $_REQUEST['new'][$i][$lang] = addslashes($value);
  13. } else {
  14. foreach ($arrLangVal as $l => $v) {
  15. if ($arrLangVal[$l]) {
  16. $_REQUEST['new'][$i][$lang] = addslashes($v);
  17. }
  18. }
  19. }
  20. }
  21. }
  22. $strSql = 'INSERT INTO '.$this->strTable.'
  23. (val, '.join(',',array_keys($_REQUEST['new'][$key])).')
  24. VALUES
  25. (\''.$keyValue.'\', \''.join('\',\'',array_values($_REQUEST['new'][$key])).'\')';
  26. $this->objDB->query($strSql);
  27. }
  28.  
  29. // deleting
  30. $delArr = array();
  31. if (count($_REQUEST['del'])) {
  32. foreach ($_REQUEST['del'] as $keyVal => $Y) {
  33. if ($Y!='Y') continue;
  34. $delArr[] = $keyVal;
  35. $strSql = 'DELETE FROM '.$this->strTable.' WHERE val=\''.$keyVal.'\'';
  36. $this->objDB->query($strSql);
  37. }
  38. }
  39.  
  40. // updating
  41. if (!count($_REQUEST['old'])) return;
  42. foreach ($_REQUEST['old'] as $keyValue => $arrLangVal) {
  43. if (in_array($keyValue,$delArr) OR !strlen(join('',$_REQUEST['old'][$keyValue]))) continue;
  44. $arrUpdateValues = array();
  45. foreach ($arrLangVal as $lang => $value) {
  46. if ($value) {
  47. $arrUpdateValues[] = $lang.'=\''.addslashes($value).'\'';
  48. } else {
  49. foreach ($arrLangVal as $lang => $value) {
  50. if ($arrLangVal[$lang]) {
  51. $arrUpdateValues[] = $lang.'=\''.addslashes($value).'\'';
  52. }
  53. }
  54. }
  55. }
  56. $strSql = 'UPDATE '.$this->strTable.'
  57. SET '.join(',',$arrUpdateValues).'
  58. WHERE
  59. val = \''.$keyValue.'\'';
  60. $this->objDB->query($strSql);
  61. }
  62. }
Comments (Newest First)
nav33n | Nearly a Posting Maven | Dec 11th, 2007
Sorry ! What does this code snippet do btw ?
cscgal | The Queen of DaniWeb | Dec 2nd, 2007
I don't get it? ... and I'm a PHP programmer. It looks like the function is part of a class that you aren't showing us. What are we saving??
Post Comment

Only community members can submit or comment on code snippets. You must register or log in to contribute.

DaniWeb Marketplace (Sponsored Links)
All times are GMT -4. The time now is 6:53 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC