Jump to content

sasa

Staff Alumni
  • Posts

    2,804
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by sasa

  1. <?php
    $test = "My code: <b>ss.34-some<img src='http://mydomain.com/images/slash.gif'  alt='$'>anothernum.123.word</b>
    My code: <b>other<img src='http://mydomain.com/images/slash.gif'  alt='$'>code.1234.test</b>
    My code: <b>and.another<img src='http://mydomain.com/images/slash.gif'  alt='$'>code</b>
    ... ";
    preg_match_all('/<b>[^<]*<img[^>]*alt=\'[^\']*\'[^>]*>[^<]+<\/b>/i', $test, $matches);
    foreach ($matches[0] as $v){
            $out[] = preg_replace('/<b>([^<]*)<img[^>]*alt=\'([^\']*)\'[^>]*>([^<]+)<\/b>/i', '\1\2\3', $v);
    }
    print_r($out);
    ?>

  2. ups i make some mistake

    $doc = new DOMDocument();
      $doc->load('inthenews.xml');
      $inthenews = array();
      foreach ($doc->getElementsByTagName('item') as $node) {
          preg_match('/<img\s[^>]*>/i', $node->getElementsByTagName('description')->item(0)->nodeValue, $out); //
          $itemRSS = array ( 
          'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
          'link' => $node->getElementsByTagName('link')->item(0)->nodeValue,
          'desc' => $out[0]
          );
        array_push($inthenews, $itemRSS);
      }

  3. $doc = new DOMDocument();
      $doc->load('inthenews.xml');
      $inthenews = array();
      foreach ($doc->getElementsByTagName('item') as $node) {
          preg_match('/<img\s[^>]*/i', $node->getElementsByTagName('description')->item(0)->nodeValue, $out)
          $itemRSS = array ( 
          'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
          'link' => $node->getElementsByTagName('link')->item(0)->nodeValue,
          'desc' => $out
          );
        array_push($inthenews, $itemRSS);
      }

    not tested

  4. if i understu what you want try

    <?php
    // $file = $dossier_cam_autres_fichiers.'/'.nomValide($_FILES['fichierhtml']['name']);
    // Open up the file and read the content
    // $current = file_get_contents($file);
    
    // SAMPLE CODE
    $current = '[invisible]
    [titre]Title sample 1[/titre]
    [texte]Texte sample 1[/texte]
    [/invisible]
    [invisible]
    [titre]Title sample 2[/titre]
    [texte]Texte sample 2[/texte]
    [/invisible]
    [invisible]
    [titre]Title sample 3[/titre]
    [texte]Texte sample 3[/texte]
    [/invisible]';
    
    function my_replace($m){
        static $i = 0;
        $id=md5($i++);
        $m[1] = preg_replace('/\[texte\](.*?)\[\/texte\]/s',
                '<a href="#" onclick="showhide(\''.$id.'\'); return(false);">\1</a>', $m[1]);
        $m[1] = preg_replace('/\[titre\](.*?)\[\/titre\]/s',
                '<div style="display: none;" id="'.$id.'">
    \1
    </div>', $m[1]);
        return $m[1];
    }
    //first select invisible tag(s)
    $out = preg_replace_callback('/\s*\[invisible\](.*?)\[\/invisible\]/s', 'my_replace',$current);
    echo $out;
    ?>

  5. <?php
    $test = '
    [invisible]
    [titre]$var1[/titre]
    [texte]$var2[/texte]
    [/invisible]';
    //first select invisible tag(s)
    preg_match_all('/\[invisible\](.*?)\[\/invisible\]/s',$test,$out);
    if(count($out[1]) > 0){
    $out = implode('', $out[1]); // put all invisible tags together 
    preg_match('/\[titre\](.*?)\[\/titre\]/s', $out, $out1); // extract var 1
    $var1 = $out1[1];
    preg_match('/\[texte\](.*?)\[\/texte\]/s', $out, $out1);
    $var2 = $out1[1];
    }
    echo $var1, ' - ', $var2;
    ?>

  6. look comments

    <?php
    if($nbrows>0){
        while($rec = mysql_fetch_array($result)){
                // concatenate info_title and info fields, eg  Mobile: 07777 777 777
          $rec['info']=($rec['info_title'].': '.$rec['info']); //your code
          $arr[$rec['person_id']][] = $rec['info']; // make 2-dim array, 1st key is primary key for table
          $names[$rec['person_id']] = $rec['firstname'] . ' | ' . $rec['lastname'] ; //build 1-dim array key is same as in  $arr array
        }
    foreach ($arr as $key => $value){ //combine two arrays, in $key is 'person_id' (1st key of array), and in $value is array of 'info'
                    // convert array $value to string and concat it with $names with same key
    	$arr[$key] = $names[$key] . ' | ' . implode(' | ', $value);
    }
    // your code	
        $jsonresult = JEncode($arr);
        echo '({"total":"'.$nbrows.'","results":'.$jsonresult.'})';
      } else {
        echo '({"total":"0", "results":""})';
      }
                 // function getList
    
    ?>

  7. try

    <?xml version="1.0" encoding="UTF-8"?><response gd:kind="buzz#peopleFeed" xmlns="http://portablecontacts.net/ns/1.0" xmlns:gd="http://schemas.google.com/g/2005"><startIndex>0</startIndex><itemsPerPage>0</itemsPerPage><totalResults>20</totalResults></response>

  8. try

    <?php
    $sql = "SELECT DISTINCT zip,city,state FROM `residential` WHERE `zip` LIKE '$input%' OR `city` LIKE '$input%' OR `state` LIKE '$input%'";
    
    $result = mysql_query($sql);
    
    if (!$result || !mysql_num_rows($result))
    exit;
    
    include_once "headers.php";
    
    echo "<response>";
    
    while ($row = mysql_fetch_array($result))
    {
       $keywords = "$row[city], $row[state] $row[zip]";
       echo "<keywords>". $keywords ."</keywords>";       
    }
    mysql_data_seek($result, 0);
    while ($row = mysql_fetch_array($result))
    {
       $keywords = "$row[city], $row[state]";
       echo "<keywords>". $keywords ."</keywords>";       
    }
    echo "</response>";
    ?>

  9. use this 3 queries

    INSERT INTO categories SELECT DISTINCT '', Category1, 0 FROM product
    
    INSERT INTO categories SELECT '', Category2, id FROM
    (SELECT DISTINCT category1, Category2, categories.ID AS id FROM product, categories
    WHERE product.Category1=categories.Name AND categories.Parent_ID=0) AS tbl1
    
    
    INSERT INTO categories SELECT '', Category3, id FROM
    (SELECT DISTINCT category1, Category2, Category3, c1.ID AS id FROM product, categories AS c, categories AS c1
    WHERE product.Category1=c.Name AND c.Parent_ID=0 AND product.Category2=c1.Name AND c1.Parent_ID=c.ID) AS tbl1

  10. change page 1 to

    <?php
      session_start();
    
      // session timing
      // set timeout period in seconds
      $inactive = 120;
    
      // check to see if $_SESSION['timeout'] is set
        if(isset($_SESSION['timeout']) ) {
          $session_life = time() - $_SESSION['timeout'];
            if($session_life > $inactive)  {
              session_destroy(); }
        }
    
        $_SESSION['timeout'] = time();
    
      // END session timing
    
      include('library/login.php');
      login();
      mysql_select_db('test');
       
    
      // sets the sessions for all values
      $_SESSION=array_merge($_SESSION,$_POST);
      
        // echoing to verify
      $gender=$_SESSION[gender];
      $genderPref=$_SESSION[genderPref];
        echo "Chossen Gender".$_SESSION['gender'];
        echo "<br><Br>";
        echo "GenderPref".$_SESSION['genderPref'];
        echo "<br><Br>";
        
        
    
      // if the user has been timed out or not logged in
      if (!isset($_SESSION['clientID'])){
        echo "You are not a register user - set this to a simple search form";
        echo "<br><a href='form.php'>Form</a>";
      }
    
      // user is logged in
      else {
        $clientID = $_SESSION['clientID'];
    
        $sql="SELECT * FROM user WHERE userID='$clientID'";
        $result=mysql_query($sql);
    
        while ($r=mysql_fetch_array($result)) {
          $exp_date=$r["exp_date"];
          $todays_date=date("Y-m-d");
        }
    
      // verifies billing
      if ($exp_date >= $todays_date) {
    
        // billing is up to date
        $result = mysql_query("SELECT * FROM user WHERE gender='$gender'") or die(mysql_error());
        
        //add this line
              while ($r=mysql_fetch_array($result)) $aUserIDs[] = $r['userID'];
    
    // ------ Sets the display of data ------
          $num_rows = mysql_num_rows($result);
    
          // number of rows to show per page
          $rowsperpage = 8;
    
          // find out total pages
          $totalpages = ceil($num_rows / $rowsperpage);
    
          // get the current page or set a default
          if (isset($_GET['currentpage']) && is_numeric($_GET['currentpage'])) {
            // cast var as int
            $currentpage = (int) $_GET['currentpage'];  }
          else {
            // default page num
            $currentpage = 1; } // end if
    
          // if current page is greater than total pages...
          if ($currentpage > $totalpages) {
            // set current page to last page
            $currentpage = $totalpages; } // end if
    
          // if current page is less than first page...
            if ($currentpage < 1) {
              // set current page to first page
              $currentpage = 1; } // end if
    
              // the offset of the list, based on current page
              $offset = ($currentpage - 1) * $rowsperpage;
    
    
    
      $result = mysql_query("SELECT * FROM user WHERE gender='$gender' LIMIT $offset, $rowsperpage")or  die(mysql_error());
        $num_rows = mysql_num_rows($result);
        if ($num_rows == 0){
          echo "<div id='noResults'><span class='sorry'>Sorry</span>, no results found. <br> Please try again with broader search options.</div>"; }
        else {
          // format for search results
          $cells_wide = 2;
          echo " <table cellspacing='0' cellpadding='3' border='0' width='700'><tr> ";
          $c = 0;
    
          while ($r=mysql_fetch_array($result)) {
            $userID=$r["userID"];
            $gender=$r["gender"];
            //$aUserIDs[] = $userID;
    
              if (0 < $c && 0 == $c % $cells_wide){
                echo " </tr><tr> "; }
                echo " <td width=175> ";
                echo "<a href='profileSession.php?userID=$r[userID]'>$userID</a>, $gender</td>";
                $c++;
              } // end of while
              echo " </tr>";
              echo " </table> ";
        }
    // -------- BUILD THE PAGINATION LINKS --------------------------------
    
        $_SESSION['userID']=$aUserIDs;
            /* @var $aUserIDs2 <type> */
        $_SESSION['userID2']=$aUserIDs2;
        echo "<div id='navigation'>";
    
        // range of num links to show
        $range = 3;
    
        // if not on page 1, show back links
        if ($currentpage > 1) {
          // show << link to go back to page 1
          echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=1&gender=$genderPref&genderPref=$gender&ageMin=$ageMin&ageMax=$ageMax&year1=$year1&year2=$year2'>‹‹ </a> ";
    
          // get previous page num
          $prevpage = $currentpage - 1;
    
          // show < link to go back to 1 page
          echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$prevpage&gender=$genderPref&genderPref=$gender&ageMin=$ageMin&ageMax=$ageMax&year1=$year1&year2=$year2'> ‹ </a> ";
        } // END if ($currentpage > 1)
    
        // loop to show links to range of pages around current page
        for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) {
          // if it's a valid page number...
          if (($x > 0) && ($x <= $totalpages)) {
            // if we're on current page...
            if ($totalpages == 1) {
              echo "";  }
            else{
              if ($x == $currentpage) {
                // 'highlight' it but don't make a link
                echo " [<b>$x</b>] ";
                // if not current page...
              } // END if ($x == $currentpage)
              else {
                // make it a link
                echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$x&gender=$genderPref&genderPref=$gender&ageMin=$ageMin&ageMax=$ageMax&year1=$year1&year2=$year2'>$x</a> ";
              } // END else
            } // END else
          } // END if (($x > 0) && ($x <= $totalpages))
        } // END for loop
    
        // if not on last page, show forward and last page links
        if ($totalpages == 0) {
          echo "";  }
        else{
          if ($currentpage != $totalpages) {
            // get next page
            $nextpage = $currentpage + 1;
    
            // echo forward link for next page
            echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$nextpage&gender=$genderPref&genderPref=$gender&ageMin=$ageMin&ageMax=$ageMax&year1=$year1&year2=$year2'> › </a> ";
    
            // echo forward link for lastpage
            echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$totalpages&gender=$genderPref&genderPref=$gender&ageMin=$ageMin&ageMax=$ageMax&year1=$year1&year2=$year2'>›› </a> ";
          } // END if ($currentpage != $totalpages)
        }// END else
    echo "<br>currentpage=$currentpage&gender=$genderPref&genderPref=$gender&ageMin=$ageMin&ageMax=$ageMax&year1=$year1&year2=$year2";
    
    $link='currentpage=';
    $link1='&gender=';
    $link2='&genderPref=';
    $link3='&ageMin=';
    $link4='&ageMax=';
    $link5='&year1=';
    $link6='&year2=';
    $total=$link.$currentpage.$link1.$genderPref.$link2.$gender.$link3.$ageMin.$link4.$ageMax.$link5.$year1.$link6.$year2;
    $_SESSION['pages']=$total;
    echo "<br>$total";
    
    // -------- END PAGINATION --------------------------------------------
        
      } // END if ($exp_date >= $todays_date)
      else  {
        // billing has expired
        echo "Billing has expired<br>";
        echo $_SESSION['clientID'];
    
        echo "<br><a href='session2.php'>Sesssion2</a>";
        echo "<br><a href='form.php'>Form</a>";
      }
    
    
      } // END valid session
    
    ?>

    not tested

  11. <?php
    if($nbrows>0){
        while($rec = mysql_fetch_array($result)){
                // concatenate info_title and info fields, eg  Mobile: 07777 777 777
          $rec['info']=($rec['info_title'].': '.$rec['info']);
          $arr[$rec['person_id']][] = $rec['info'];	
          $names[$rec['person_id']] = $rec['firstname'] . ' | ' . $rec['lastname'] ;
        }
    foreach ($arr as $key => $value){
    	$arr[$key] = $names[$key] . ' | ' . implode(' | ', $value);
    }
    
        $jsonresult = JEncode($arr);
        echo '({"total":"'.$nbrows.'","results":'.$jsonresult.'})';
      } else {
        echo '({"total":"0", "results":""})';
      }
                 // function getList
    
    ?>

  12. try

    <?php
    if($nbrows>0){
        while($rec = mysql_fetch_array($result)){
                // concatenate info_title and info fields, eg  Mobile: 07777 777 777
          $rec['info']=($rec['info_title'].': '.$rec['info']);
          $arr[$rec['person_id']][] = $rec['info'];	  
        }
    foreach ($arr as $key => $value){
    	$arr[$key] = implode(' | ', $value);
    }
    
        $jsonresult = JEncode($arr);
        echo '({"total":"'.$nbrows.'","results":'.$jsonresult.'})';
      } else {
        echo '({"total":"0", "results":""})';
      }
                 // function getList
    
    ?>

  13. i forget to add this

                  if(count($tmp)>0){
                         echo implode(', ', $tmp), " likes this.<br>";
                         $tmp = array();
                  }

    afterr while loop

  14. some code
    $description='':
    $tmp = array();
    while loop for output
    if($description != $list['description']){
                  if(count($tmp)>0){
                         echo implode(', ', $tmp), " likes this.<br>";
                         $tmp = array();
                  }
    $description = $list['description'];
    //echo description 
    }
    if($list['username']){
    $tmp[] = "<a href=\"profile.php?user=" . $list['username'] . "\">" . $list['username'] . "</a>";
    }
    //end while loop 

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