Jump to content

sasa

Staff Alumni
  • Posts

    2,804
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by sasa

  1. try $longtext = preg_match('/\S{20,}/', $description); if(!$longtext) { if word is not longer than 20 characters do this else { if a word has more than 20 characters without any blank space do this }
  2. SELECT * FROM table ORDER BY id DESC LIMIT 1
  3. add &q=$var to your PREV and NEXT links <a href='$page_name?start=$back&p_f=$p_f&q=$var'>
  4. change line $second = $first; to foreach ($first as $k => $v)$second[$k] = clone $v;
  5. SELECT * FROM (select * from downloadz order by id DESC limit 70) AS xxx ORDER BY RAND()
  6. try <?php $your_name = 'SecretADC'; $patern = "/<td>$your_name<\/td><td>(.*?)<\/td><td>(.*?)<\/td><td>(.*?)<\/td><td align=\"right\">(.*?)<\/td>/"; $page = file_get_contents('http://starwarsgalaxies.station.sony.com/en_US/players/officers.vm?id=66953'); preg_match($patern,$page,$out); print_r($out); ?>
  7. look 1st if <?php if ($tireqty <5) $discount=1;// 1 to 4 no discount, must be 1 not 0 elseif ($tireqty <50) $discount=0.95; // 5 to 49 discount 5% elseif ($tireqty< 100) $discount=0.9; // 50 to 99 discount 10% else $discount=0.80; // 100 and more discount 20% ?>
  8. sasa

    PHP MATH HELP

    try <?php $num = 50000000; function calculate($num){ $num = preg_replace('/[^0-9\.]/','',$num); $tax_on = 0; $tax_to = 0; $cla=array(400000,250000,55000,0); $rate_to = array(0.02,0.01,0.01,0.005); $rate_on = array(0.02,0.015,0.01,0.005); foreach ($cla as $k => $v){ $x = $num > $v ? $num - $v: 0; $num -= $x; $tax_on += $x * $rate_on[$k]; $tax_to += $x * $rate_to[$k]; } return $tax_on + $tax_to; } function calculate_com($num){ $num = preg_replace('/[^0-9\.]/','',$num); $tax_on = 0; $tax_to = 0; $cla=array(40000000, 400000,250000,55000,0); $rate_to = array(0.01,0.015,0.01,0.01,0.005); $rate_on = array(0.015,0.015,0.015,0.01,0.005); foreach ($cla as $k => $v){ $x = $num > $v ? $num - $v: 0; $num -= $x; $tax_on += $x * $rate_on[$k]; $tax_to += $x * $rate_to[$k]; } return $tax_on + $tax_to; } echo 'calculate -> $'.number_format(calculate($num),2),"<br />\n"; echo 'calculate_com -> $'.number_format(calculate_com($num),2),"<br />\n"; ?>
  9. ups i mean echo "<td>".($i+1)."</td>";
  10. change echo "<td>$i</td>"; to echo "<td>".$i+1."</td>";
  11. change method from GET to POST
  12. if you want to find most popular id in one column use SELECT `img1`, COUNT(`id`) AS c FROM `imgs` GROUP BY `img1` ORDER BY c DESC if you want to find most popular id in all columns use SELECT imgs.img1 as img,count(distinct(i1.id)) as c FROM `imgs`,imgs as i1 where imgs.img1 in(i1.img1,i1.img2,i1.img3) group by imgs.img1 union SELECT imgs.img2 as img,count(distinct(i1.id)) as c FROM `imgs`,imgs as i1 where imgs.img2 in(i1.img1,i1.img2,i1.img3) group by imgs.img2 union SELECT imgs.img3 as img,count(distinct(i1.id)) as c FROM `imgs`,imgs as i1 where imgs.img3 in(i1.img1,i1.img2,i1.img3) group by imgs.img3 order by c desc or reorganize your db
  13. try <?php if ($check > $timeout) { echo "<img src=\"http://"; echo $_SERVER['HTTP_HOST']; echo "/backend/images/offline.png\" />"; } else if($check > $nearly) { echo "<img src=\"http://"; echo $_SERVER['HTTP_HOST']; echo "/backend/images/timeout.png\" />"; } else { echo "<img src=\"http://"; echo $_SERVER['HTTP_HOST']; echo "/backend/images/online.png\" />"; } ?>
  14. try <?php $results = $ltr->result(); $i = 0; $max_columns = 2; $total = sizeof($results); $num_rows = ($total/$max_columns); //foreach ($ltr->result() as $row){ you don't need to do same query again foreach ($results as $row){ if($i == 0) echo '<tr valign="top">'; echo '<td><a title="'. url_title($row->title) .'" href="' .base_url(). 'movies/review/' .$row->rid. '/' .url_title($row->title). '.html">' .$row->title. '</a> (' .$row->year. ')<br />'; echo check_review_score($row->score),'</td>'; if(++$i == $max_columns){ echo "</tr>"; $i=0; } // endif }//endforeach; if($i > 0) { for($j=$i; $j<$max_columns;$j++) echo "<td> </td>"; echo '</tr>'; } ?>
  15. what is pk in your table registeruser userid is fk, isn't it?
  16. can you post structure of your tables
  17. try <?php foreach($results as $result) echo '<a title="'. url_title($result->title) .'" href="' .base_url(). 'movies/review/' .$result->rid. '/' .url_title($result->title). '.html">' .$result->title. '</a> (' .$result->year. ')<br />'; //echo check_review_score($results->score); ?>
  18. in while loop you fetch result in variable $rowName but in print you use variable $rowcc
  19. is it some php quiz? can i win something
  20. look <?php // Let's show all errors error_reporting(E_ALL); $arr = array('fruit' => 'apple', 'veggie' => 'carrot'); // Correct print $arr['fruit']; // apple print $arr['veggie']; // carrot // Incorrect. This works but also throws a PHP error of // level E_NOTICE because of an undefined constant named fruit // // Notice: Use of undefined constant fruit - assumed 'fruit' in... print $arr[fruit]; // apple // Let's define a constant to demonstrate what's going on. We // will assign value 'veggie' to a constant named fruit. define('fruit', 'veggie'); // Notice the difference now print $arr['fruit']; // apple print $arr[fruit]; // carrot // The following is okay as it's inside a string. Constants are not // looked for within strings so no E_NOTICE error here print "Hello $arr[fruit]"; // Hello apple // With one exception, braces surrounding arrays within strings // allows constants to be looked for print "Hello {$arr[fruit]}"; // Hello carrot print "Hello {$arr['fruit']}"; // Hello apple // This will not work, results in a parse error such as: // Parse error: parse error, expecting T_STRING' or T_VARIABLE' or T_NUM_STRING' // This of course applies to using superglobals in strings as well print "Hello $arr['fruit']"; print "Hello $_GET['foo']"; // Concatenation is another option print "Hello " . $arr['fruit']; // Hello apple ?> from http://www.php.net/manual/en/language.types.array.php
  21. 1st echo "<IMG SRC='$row[screen1]' BORDER='0'>";
  22. change link to <script src="../images/getpics.php?dir=bla" type="text/javascript"></script> and sctript to <? Header("content-type: application/x-javascript"); $dirname=$_GET['dir']; function returnimages($dirname=".") { $pattern="\.(jpg|jpeg|png|gif|bmp)$"; $files = array(); $curimage=0; if($handle = opendir($dirname)) { while(false !== ($file = readdir($handle))){ if(eregi($pattern, $file)){ $filedate=date ("M d, Y H:i:s", filemtime($file)); echo 'galleryarray[' . $curimage .']=["' . $file . '", "'.$filedate.'"];' . "\n"; $curimage++; } } closedir($handle); } return($files); } echo "var galleryarray=new Array();" . "\n"; returnimages(); ?>
×
×
  • 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.