fork download
  1. <?php
  2.  
  3. $paraUpadate="";
  4.  
  5. $colunas="ads_image_1,ads_image_2";
  6.  
  7. $praBanco="'im/pd/5ad3dd6bd58c86.55498080.jpg','im/pd/5ad3dd6bd5a312.43966416.jp'";
  8.  
  9.  
  10. $explodeColunas = explode(',', $colunas);
  11.  
  12. $explodePraBanco = explode(',', $praBanco);
  13.  
  14. for($i = 0; $i<count($explodeColunas); $i++){
  15.  
  16. $paraUpadate .= $explodeColunas[$i]."=".$explodePraBanco[$i].",";
  17.  
  18. }
  19.  
  20. //para retirar os 3 caracteres do final da string ,=, ( virgula sinal de igual virgula )
  21. $paraUpadate = substr($paraUpadate,0,-3);
  22.  
  23. $ads_title="Titulo";
  24. $ads_content="Contentissimo";
  25. $ads_price="Carissimo";
  26.  
  27. // edit_attempts ?? não seria
  28. $edit_attempts=23;
  29.  
  30. $editor_id=10;
  31.  
  32. //agora é só colocar esse resultado na declaração UPDATE
  33.  
  34. $smtp_process = "UPDATE public_ads SET ads_title = '$ads_title', ads_content = '$ads_content', ads_price = '$ads_price', edit_attempts = $edit_attempts + 1, $paraUpadate WHERE ads_id = '$editor_id'";
  35.  
  36.  
  37. echo $smtp_process;
Success #stdin #stdout 0.03s 23792KB
stdin
Standard input is empty
stdout
UPDATE public_ads SET ads_title = 'Titulo', ads_content = 'Contentissimo', ads_price = 'Carissimo', edit_attempts = 23 + 1, ads_image_1='im/pd/5ad3dd6bd58c86.55498080.jpg',ads_image_2='im/pd/5ad3dd6bd5a312.43966416.j WHERE ads_id = '10'