sasa
Staff Alumni-
Posts
2,804 -
Joined
-
Last visited
-
Days Won
1
Everything posted by sasa
-
$query = 'SELECT * FROM list WHERE percentage > "0.00"'; $results = mysql_query( $query ) or die( mysql_error() ); while( $row = mysql_fetch_array( $results ) ) { ... <etc.> echo $row["name"]; echo $row["percentage"]; $data[$row["name"]] = $row["percentage"]; }
-
SELECT option, COUNT(id) AS c FROM table GROUP BY option ORDER BY c LIMIT 20 not tested
-
having a small problem with this pagination script.
sasa replied to svgmx5's topic in PHP Coding Help
change <li><strong><?php echo $club_id++ ;?> to <li><strong><?php echo ++$offset; ?> -
<?php include("connect/login.php"); $query= "SELECT AID FROM answer WHERE (QID = 18) AND UID IN (SELECT UID FROM answer WHERE Answer = 33) ORDER BY AID ASC"; $result = mysql_query($query) or die(mysql_error()); $i = 0; $tmp = -1; while($row = mysql_fetch_array($result)){ if($row['AID'] > $tmp){ $i++; $tmp = $row['AID']; } echo $i; // echo $row['AID']; } ?>
-
change #ccc'/>(\\s+)</div>/ to #ccc'\\/>(\\s+)<\\/div>/
-
try <?php /* * To change this template, choose Tools | Templates * and open the template in the editor. */ $test = 'this is my website [http://www.google.com,2] profile'; $test = preg_split('/[\[\]]/', $test); $first = explode(' ', trim($test[0])); $url = split(',', $test[1]); $in = ''; if(count($first) < $url[1]) $url[1] = count ($first); for($i =0; $i < $url[1]; $i++){ $in = array_pop($first).' '. $in; } $out = implode(' ', $first). ' <a href="'. trim($url[0]) . '">' . trim($in) .'</a>'.$test[2]; print_r($out); ?>
-
try <?php include("connect/login.php"); $query= "SELECT AID FROM answer WHERE (QID = 18) AND UID IN (SELECT UID FROM answer WHERE Answer = 33) ORDER BY AID ASC"; $result = mysql_query($query) or die(mysql_error()); $i = 1; $start = false; $tmp = -1; while($row = mysql_fetch_array($result)){ if($start and $row['AID'] > $tmp){ $i++; $tmp = $row['AID']; } $start = true; echo $i; // echo $row['AID']; } ?>
-
in string is nothing but tags and strip_tags() function strip it all
-
ttry <?php /* * To change this template, choose Tools | Templates * and open the template in the editor. */ $test = Array ( '0' => Array ( 'service' => 'ServiceNname1', 'txcount' => 2, 'estdate' => '07-19-2010' ), '1' => Array ('service' => 'ServiceNname2', 'txcount' => 25, 'estdate' => '07-19-2010' ), '2' => Array ( 'service' => 'ServiceNname3', 'txcount' => 6, 'estdate' => '07-19-2010' ), '3' => Array ( 'service' => 'ServiceNname3', 'txcount' => 2545, 'estdate' => '07-19-2010' ), '4' => Array ( 'service' => 'ServiceNname2', 'txcount' => 269, 'estdate' => '07-19-2010' ), '5' => Array ( 'service' => 'ServiceNname3', 'txcount' => 2532, 'estdate' => '07-19-2010' ), '6' => Array ( 'service' => 'ServiceNname1', 'txcount' => 2, 'estdate' => '07-19-2010' ), '7' => Array ( 'service' => 'ServiceNname2', 'txcount' => 18, 'estdate' => '07-19-2010' ), '8' => Array ( 'service' => 'ServiceNname3', 'txcount' => 2, 'estdate' => '07-19-2010' ), '9' => Array ( 'service' => 'ServiceNname3', 'txcount' => 2533, 'estdate' => '07-19-2010' ), '10' => Array ( 'service' => 'ServiceNname2', 'txcount' => 58, 'estdate' => '07-19-2010' ), '11' => Array ( 'service' => 'ServiceNname3', 'txcount' => 2330, 'estdate' => '07-19-2010' ), '12' => Array ( 'service' => 'ServiceNname2', 'txcount' => 18, 'estdate' => '07-19-2010' ), '13' => Array ( 'service' => 'ServiceNname3', 'txcount' => 1, 'estdate' => '07-19-2010' ), '14' => Array ( 'service' => 'ServiceNname3', 'txcount' => 1247, 'estdate' => '07-19-2010' ), '15' => Array ( 'service' => 'ServiceNname2', 'txcount' => 15, 'estdate' => '07-19-2010' ), '16' => Array ( 'service' => 'ServiceNname4', 'txcount' => 438, 'estdate' => '07-19-2010' ), '17' => Array ( 'service' => 'ServiceNname3', 'txcount' => 391, 'estdate' => '07-19-2010' ), '18' => Array ( 'service' => 'ServiceNname2', 'txcount' => 43, 'estdate' => '07-19-2010' ), '19' => Array ( 'service' => 'ServiceNname4', 'txcount' => 33, 'estdate' => '07-19-2010' ), '20' => Array ( 'service' => 'ServiceNname3', 'txcount' => 2, 'estdate' => '07-19-2010' ), '21' => Array ( 'service' => 'ServiceNname3', 'txcount' => 920, 'estdate' => '07-19-2010' ), '22' => Array ( 'service' => 'ServiceNname2', 'txcount' => 62, 'estdate' => '07-19-2010' ), '23' => Array ( 'service' => 'ServiceNname4', 'txcount' => 38, 'estdate' => '07-19-2010' ), '24' => Array ( 'service' => 'ServiceNname3', 'txcount' => 7, 'estdate' => '07-19-2010' ), '25' => Array ( 'service' => 'ServiceNname3', 'txcount' => 2420, 'estdate' => '07-19-2010' ), '26' => Array ( 'service' => 'ServiceNname3', 'txcount' => 2, 'estdate' => '07-20-2010' ), '27' => Array ( 'service' => 'ServiceNname3', 'txcount' => 3093, 'estdate' => '07-20-2010' ), '28' => Array ( 'service' => 'ServiceNname1', 'txcount' => 8, 'estdate' => '07-20-2010' ), '29' => Array ( 'service' => 'ServiceNname2', 'txcount' => 82, 'estdate' => '07-20-2010' ), '30' => Array ( 'service' => 'ServiceNname3', 'txcount' => 4, 'estdate' => '07-20-2010' ), '31' => Array ( 'service' => 'ServiceNname3', 'txcount' => 2505, 'estdate' => '07-20-2010' ), '32' => Array ( 'service' => 'ServiceNname1', 'txcount' => 7, 'estdate' => '07-20-2010' ), '33' => Array ( 'service' => 'ServiceNname2', 'txcount' => 30, 'estdate' => '07-20-2010' ), '34' => Array ( 'service' => 'ServiceNname3', 'txcount' => 2, 'estdate' => '07-20-2010' ), '35' => Array ( 'service' => 'ServiceNname3', 'txcount' => 2274, 'estdate' => '07-20-2010' ), '36' => Array ( 'service' => 'ServiceNname1', 'txcount' => 7, 'estdate' => '07-20-2010' ), '37' => Array ( 'service' => 'ServiceNname2', 'txcount' => 40, 'estdate' => '07-20- 2010' )); $out = array(); foreach ($test as $row){ $s = $row['service']; $d = $row['estdate']; $t = $row['txcount']; if(isset ($out[$s][$d])) $out[$s][$d] += $t; else $out[$s][$d] = $t; } foreach ($out as $service => $row){ foreach ($row as $date => $cnt) echo "$service - $date - $cnt<br />\n"; } ?>
-
help putting img src into a string for an array element please
sasa replied to silverglade's topic in PHP Coding Help
you have twice '<img src=' part try $currentLocation = array ( 'teardrop_ocean_bg' => array ( 'level_1'=>"<img src='sundragon_environments/ocean/ocean1_FRAME.jpg' />" ) ); -
try preg_match_all('/<a href="([^"]+)"/', $finddl, $dllink); print_r($dllink[1]); not tested
-
<?php $test = '</w:r><w:r><w:rPr><w:b/><w:sz w:val="24"/></w:rPr><w:br/></w:r><w:r><w:rPr><w:b/> <w:sz w:val="24"/></w:rPr><w:br/></w:r><aml:annotation aml:id="2" w:type="Word.Bookmark.Start" w:name="something"/> <w:r> <w:rPr><w:sz w:val="24"/> <blkah> <blah> </w:rPr><w:t>THIS IS THE TEXT I WANT TO EXTRACT!</w:t></w:r><w:r><w:rPr><w:sz w:val="24"/></w:rPr><w:br/> </w:r><aml:annotation aml:id="2" w:type="Word.Bookmark.End"/><w:r><w:rPr><w:sz w:val="24"/></w:rPr><w:br/></w:r><w:r><w:rPr> <w:sz w:val="24"/></w:rPr><w:br/></w:r><w:r><w:rPr><w:sz w:val="24"/><w:highlight w:val="light-gray"/></w:rPr><w:t>NO MATCH</w:t>'; preg_match('/"Word\.Bookmark\.Start".*?>[\n\s]*([^<\n\s][^<\n]+)<.*?"Word\.Bookmark\.End"/s', $test, $out); //$out = strip_tags($out[1]); print_r($out); ?>
-
do you use strip_tags function on 2nd element of the array?
-
can you post 2nd string
-
you want 2nd element of array, isn't it?
-
try <?php $test = '</w:r><w:r><w:rPr><w:b/><w:sz w:val="24"/></w:rPr><w:br/></w:r><w:r><w:rPr><w:b/> <w:sz w:val="24"/></w:rPr><w:br/></w:r><aml:annotation aml:id="2" w:type="Word.Bookmark.Start" w:name="something"/> <w:r><w:rPr><w:sz w:val="24"/> </w:rPr><w:t>THIS IS THE TEXT I WANT TO EXTRACT!</w:t></w:r><w:r><w:rPr><w:sz w:val="24"/></w:rPr><w:br/> </w:r><aml:annotation aml:id="2" w:type="Word.Bookmark.End"/><w:r><w:rPr><w:sz w:val="24"/></w:rPr><w:br/></w:r><w:r><w:rPr> <w:sz w:val="24"/></w:rPr><w:br/></w:r><w:r><w:rPr><w:sz w:val="24"/><w:highlight w:val="light-gray"/></w:rPr><w:t>NO MATCH</w:t>'; preg_match('/"Word\.Bookmark\.Start"[^>]*>(.*)<[^>]*"Word\.Bookmark\.End"/s', $test, $out); $out = strip_tags($out[1]); print_r($out); ?>
-
or preg_match_all('<a href="[^"]*register.php" class=l>',$html,$links);
-
try <?php $str="123-456-789"; preg_match_all('/\d/', $str, $out); $num_of_digits = count($out[0]); echo $num_of_digits; ?>
-
try $i=0; while($Value = mysql_fetch_array($TheQuery)) { echo($i+=10); }
-
try $body = preg_replace('~(^| )'.$textlinksname.'\b~i', $replace,$body,200);
-
try $query = mysql_query("SELECT * FROM av_items ORDER BY av_items.date DESC LIMIT 20"); //remove GROUP BY part while ($row = mysql_fetch_assoc($query)) { $id = $row['id']; $date = $row['date']; $message = $row['message']; $entry_date = date("Ymd", $date); if ($entry_date !== $called_date) { echo '<h1 class="topic">'.av_date($date) .'</h1>'; //echo $message; $called_date=$entry_date; }echo $message, "<br />\n"; }
-
try <?php preg_match_all('~Select Row</label></td><td class="x1l x4x"><span class="x6">([^<]*)</span></td><td class="x1l x4x"><span class="x4">[^<]*</span></td><td class="x1l x4x"><span class="x4">([^<]*)</span></td><td class="x1l x4x"><span class="x4">[^<]*</span></td><td class="x1l x4x"><span class="x4">[^<]*</span></td><td class="x1l x4x"><br></td><td class="x1l x4x"><span class="x4">[^<]*</span></td><td class="x1l x4x"><span class="x6">([^<]*)</span~', $test, $out); foreach ($out[0] as $k => $v){ $a[$k] = array('id' => $out[1][$k], 'balance' => $out[3][$k], 'status' => $out[2][$k]); } print_r($a); ?>
-
in your 1st example result is cat but without lead whay cat is not removed ?
-
try <?php function scan_dir($path ){ $out = array(); $files = opendir($path); while ($f = readdir($files)){ if ($f=='.' or $f=='..' or $f['ektension']=='jpg' or $f['extension']=='JPG') continue; if (is_dir($path.'/'.$f)) $out = array_merge($out, scan_dir($path.'/'.$f)); else $out[] = $path. '/'. $f; } return $out; } $a = scan_dir(getcwd()); print_r($a); ?>
-
move line echo $message; after if block