Jump to content

sasa

Staff Alumni
  • Posts

    2,804
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by sasa

  1. try $ids = "(567|7878)"; $sql = 'SELECT `id` FROM `video` WHERE `word_id` REGEXP '(^|,)'.$ids.'(,|$)';
  2. <?php $test = '/MAINWORD/something/else ......'; $out = preg_replace('/\/([^\/]+)\/.*/is', '\1', $test); echo $out; ?>
  3. add some space before ORDER BY " ORDER BY ...
  4. http://www.regular-expressions.info/repeat.html#greedy
  5. change your form to WHILE($fetch=mysql_fetch_assoc($res)){ echo "<td><input type=text name=desBox[] value='".$fetch['prod_id']."'>".$fetch['prod_name']."</td> <td><input type=text name=quantBox[]></td> <td><input type=text name=teethBox[]></td>"; echo "</tr>";} echo "</table>"; and on submitr page do ... foreach($-POST['desBox'] as $key = $prod_id){ $quant = $_POST['quantBox'][$key]; $teeth = $_POST['teethBox'][$key]; if($quant > 0){ //insert in db } } ....
  6. <?php $page = '<LI id=1773_tab2_[12]>Dice <LI id=1773_tab2_[13]>Dog Treats <LI id=1773_tab2_[14]>Easter Eggs <LI id=1773_tab2_[15]>Fire <LI id=1773_tab2_[16]>Flowers <LI id=1773_tab2_[17]>Foliage <LI id=1773_tab2_[16]>Grass <LI id=1773_tab2_[18]>Hearts <LI id=1773_tab2_[19]>Lightning '; preg_match_all('/\[(\d+)(\].*)/', $page, $matchesarray); $used = array(); $last = max($matchesarray[1]); foreach ($matchesarray[1] as $k => $i) { if(in_array($i, $used)){ $last++; $page = str_replace($matchesarray[0][$k], '['.$last.$matchesarray[2][$k], $page); $used[] = $last; } else $used[] = $i; } echo $page; ?>
  7. change sprintf('%2d-%2d-', $now['mday'], $now['mon']) to sprintf('%d-%d-', $now['mday'], $now['mon'])
  8. change <?php $i=0; while ($i < $num) { $invoiceID=mysql_result($result,$i,"invoiceID"); $USERID=mysql_result($result,$i,"USERID"); $CLIENTID=mysql_result($result,$i,"CLIENTID"); $amount=mysql_result($result,$i,"amount"); $Discount=mysql_result($result,$i,"Discount"); $balance = $amount - (($amount/100)*$Discount); ?> to <?php $i=0; $total_amount=0; $total_balance =0; while ($i < $num) { $invoiceID=mysql_result($result,$i,"invoiceID"); $USERID=mysql_result($result,$i,"USERID"); $CLIENTID=mysql_result($result,$i,"CLIENTID"); $amount=mysql_result($result,$i,"amount"); $Discount=mysql_result($result,$i,"Discount"); $balance = $amount - (($amount/100)*$Discount); $total_amount += $amount; $total_balance += $balance; ?> and after while loop just echo totals
  9. try <?php function replace($array, $file) { $file = 'html/'.$file.'.html'; $file = file_get_contents('./'.$this->template.$file); foreach ($array as $key => $val) $file = str_replace($key, $val, $file); echo $file; return; } ?>
  10. or <?php $text = 'bla <img src="http://someurl.com/img1.gif" /> bla '; $text = htmlspecialchars_decode($text); $text = preg_replace('/<img [^>]*>/', '', $text); echo $text; ?>
  11. <?php foreach ($_POST as $id => $value) { if (preg_match('/^test_[0-9]+_here$/',$id)){ $sql= 'INSERT INTO table SET id="'.$id.'", value="'.$value.'"'; if (!mysqli_query($link, $sql)) echo 'Error updating with new automation request: ' . mysqli_error($link); exit(); } } ?>
  12. look preg_replace_callback() function
  13. try $stake=number_format((str_replace(',', '', $mem_tot_gold)/str_replace(',', '', $tot_gold))*100,2);
  14. if rating is 0.5 do you like to display 05.jpg or 10.jpg? <?php $test = .5; echo $im= sprintf('%02d.jpg', ceil($test*2)*5),"<br />\n"; echo $im= sprintf('%02d.jpg', (floor($test*2)+1)*5); ?>
  15. try preg_replace("/( |>)(http:\/\/[a-zA-Z-0-9._?\/\s]+)/", " <a href=\"$2\">$2</a>", $test); or preg_replace("/[^\"'=](http:\/\/[a-zA-Z-0-9._?\/\s]+)/", "<a href=\"$1\">$1</a>", $content);
  16. try <?php $test = '<fruit="Carrots">Carrots<class="fruit">4,3<class="fruit">13,00'; preg_match_all('/<fruit="([^"]*)"\D+>[0-9,]+\D+>([0-9,]+)/', $test, $out); $out = array_combine($out[1], $out[2]); print_r($out); ?>
  17. try <?php $test = Array ( '0' => Array ( 'ssc_skill_categories' => 'Web', 'sc_skill_categories' => 'Programming' ), '1' => Array ( 'ssc_skill_categories' => 'Actionscript', 'sc_skill_categories' => 'Programming' ), '2' => Array ( 'ssc_skill_categories' => 'C#', 'sc_skill_categories' => 'Programming' ), '3' => Array ( 'ssc_skill_categories' => 'CSS', 'sc_skill_categories' => 'Programming' ), '4' => Array ( 'ssc_skill_categories' => 'Graphic', 'sc_skill_categories' => 'Designers' ), '5' => Array ( 'ssc_skill_categories' => 'Logo', 'sc_skill_categories' => 'Designers' ), '6' => Array ( 'ssc_skill_categories' => 'Illistration', 'sc_skill_categories' => 'Designers' ), '7' => Array ( 'ssc_skill_categories' => 'Animation', 'sc_skill_categories' => 'Designers' ) ); $table = array(); foreach ($test as $a) $table = array_merge($table, array_values ($a)); $table = array_unique($table); $table = array_chunk($table, 5); foreach ($table as $k => $r) $table[$k] = '<td>'. implode('</td><td>', $r).'</td>'; echo '<table border="3"><tr>', implode('</tr><tr>', $table),'</tr></table>'; ?>
  18. change $stringData = $conv++; to $stringData = $conv+1; or $stringData = ++$conv;
  19. try <?php $message = '>deleteall: blah sasa'; $cmdPrefx = '>'; if(stripos($message, $cmdPrefx.'deleteall: ') === 0) echo substr(strchr($message, ' '), 1); ?>
  20. try <?php $test = '<a class="thickbox" title="someimage.jpg" href="../wp-content/gallery/misc/someimage.jpg?820270487"> <img id="thumb420" class="thumb" src="../wp-content/gallery/misc/thumbs/thumbs_someimage.jpg?340050829" alt="" width="160" height="88" /></a> <a class="thickbox" title="someimage.jpg" href="../wp-content/gallery/misc/someimage.jpg?820270487"> </a>'; $pattern = '/(="\.\.\/wp-content\/gallery\/[^\?]*)\?[^"]*/is'; $test = preg_replace($pattern, '\1', $test); $pattern = '/<a\s+class="thickbox"[^>]+>\s*<\/a>/'; $test = preg_replace($pattern, '', $test); print_r($test ); ?>
  21. <?php $test = '((n+11)!/(n-k)^(-1))'; $test = explode('/', substr($test, 1, -1)); $out = 'frac{'. implode('}{', $test).'}'; echo $out; ?>
  22. try $pattern ='/this.src=\'([^\']+)\'/i';
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.