Jump to content

sasa

Staff Alumni
  • Posts

    2,804
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by sasa

  1.  $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"];
    }

  2. <?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'];
    }
    ?> 

  3. 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);
    ?>

  4. 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'];
    }
    ?>

  5. 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";
    }
    ?>

  6. <?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);
    ?>

  7. 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);
    ?>

  8. 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";
    }

  9. 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);
    ?>

  10. 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);
    ?>

×
×
  • 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.