sasa
Staff Alumni-
Posts
2,804 -
Joined
-
Last visited
-
Days Won
1
Everything posted by sasa
-
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 }
-
SELECT * FROM table ORDER BY id DESC LIMIT 1
-
Search Script Working... but not...!!...soo close...
sasa replied to Alexhoward's topic in PHP Coding Help
add &q=$var to your PREV and NEXT links <a href='$page_name?start=$back&p_f=$p_f&q=$var'> -
change line $second = $first; to foreach ($first as $k => $v)$second[$k] = clone $v;
-
SELECT * FROM (select * from downloadz order by id DESC limit 70) AS xxx ORDER BY RAND()
-
Locating and Copying specific information from a websites Source Code
sasa replied to Styles2304's topic in PHP Coding Help
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); ?> -
where you ending table
-
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% ?>
-
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"; ?>
-
ups i mean echo "<td>".($i+1)."</td>";
-
change echo "<td>$i</td>"; to echo "<td>".$i+1."</td>";
-
change method from GET to POST
-
Access Variables without using Query String
sasa replied to ramesh_iridium's topic in PHP Coding Help
use session -
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
-
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\" />"; } ?>
-
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>'; } ?>
-
what is pk in your table registeruser userid is fk, isn't it?
-
can you post structure of your tables
-
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); ?>
-
in while loop you fetch result in variable $rowName but in print you use variable $rowcc
-
script still working
-
is it some php quiz? can i win something
-
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
-
1st echo "<IMG SRC='$row[screen1]' BORDER='0'>";
-
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(); ?>