Jump to content

sasa

Staff Alumni
  • Posts

    2,804
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by sasa

  1. if you want to mach just start of last name try

    $countPlayers=mysql_query("SELECT players.Player_number, 
    	players.Player_name 
    FROM players
    WHERE ((NOT Inactive_player)
    AND (players.Player_Last_Name LIKE '$player_find%'))
    ORDER BY Player_name");

    or if you want to mach hole last name

    $countPlayers=mysql_query("SELECT players.Player_number, 
    	players.Player_name 
    FROM players
    WHERE ((NOT Inactive_player)
    AND ((players.Player_Last_Name = '$player_find')))
    ORDER BY Player_name");
    
    $row = mysql_fetch_assoc($countPlayers) or die("No rows returned by query"); 
    echo $row['Player_number'];

     

    $row = mysql_fetch_assoc($countPlayers) or die("No rows returned by query");

    echo $row['Player_number'];[/code]

  2. try

    echo "<form method=\"post\" action=".$PHP_SELF.">
      <label>aantal
      <input name=\"textfield[s]\" type=\"text\" size=\"4\" maxlength=\"3\">
      <input name=\"textfield[M]\" type=\"text\" size=\"4\" maxlength=\"3\">
      <input name=\"textfield[L]\" type=\"text\" size=\"4\" maxlength=\"3\">
      <input name=\"textfield[XL]\" type=\"text\" size=\"4\" maxlength=\"3\">
      <input name=\"textfield[XXL]\" type=\"text\" size=\"4\" maxlength=\"3\">
      <</label>
    <input type=submit value=Select></form>"; 

    and on submit page print_r($_POST['textfield']);

  3. try

    <?php
    $multi_array = array(
                     array("cats", "dogs", "sheep", "walruses"),
                     array("jazz", "larva", "pencils", "derp"),
                     array("to", "much")
                );
    $string = array("the", "cats", "ate", "too", "many", "pencils");
    $count = count($string);
    foreach($string as $i => $word) {
        foreach ($multi_array as $ar){
            if(in_array($word, $ar)){
                $string[$i] = $ar[array_rand($ar)];
                break;
            }
        }
    }
    print_r($string);
    ?>

  4. try

    $code = $_GET['postcode'];
    $shortcode = substr($code,0,2);
    $query =mysql_query ("SELECT email FROM treesurgeons WHERE postcode like '%" . $shortcode . "%' ORDER BY companyName LIMIT 3");
    echo mysql_error();
    echo "<p>The email addresses you have requested are;</p>";
    while($ntx=mysql_fetch_row($query)) $nt[] = $ntx[0];
    
    echo "$nt[0],$nt[1],$nt[2]<br>";
    echo "<p>please use $nt[2] if you ever want to contact me</p>"; //this line doesnt work for me
    ?></body></html>

  5. try

    <?php
    function gCodes($array) {
        $code = $array[1];
        $var = $array[2];
       switch($code) {
        case "IMG":
          $img = getImage($var);
          $return = "<a href=\"$img[location]\"><img src=\"$img[location]\" alt=\"$img[title]\"/></a>";
          break;
        default:
          $return = "$code=>$var<br>Not Working<br>";
      break;
      }          
    return $return;
    }
      $text = "[img:1]";
      $content = preg_replace_CALLBACK("/\[([A-Z]{3})[a-zA-Z0-9]+)\]/",'gCodes',$text);
       echo $content;
    ?>

  6. add delimiter to your regex pattern

    <?php
    $link = 'http://bs.something.com/gghs-hc/09889/1442/importantparthere      i want it to look like';
    $link = preg_replace( "#http://bs.something.com/([^/\.]+)/([^/\.]+)/([^/\.]+)/#", "http://www.something.com/v/", $link);
    echo $link;
    ?>

  7. try

    <?php
    Function OZCode($output){
        static $i = 0;
        $i++;
        $output=$output[0];
        echo $output, ' - ', $i, "<br />\n";
        return $output;
    }
    
    $test = 'I need to get the data between [ozcode] and [/ozcode]I need to get the data between [ozcode] and bla[/ozcode]';
    preg_replace_callback('~(?<=\[ozcode\]).*?(?=\[\/ozcode\])~', 'OZCode', $test);
    ?>

  8. update code to

    if($_POST['Submit']){
    $marketPrice = $_POST['marketPrice'];
    $auction = $_POST['auction'];
    $count = count($auction);
    for($i=0;$i<$count;$i++){
    $sql1="UPDATE ships SET marketPrice='$marketPrice[$i]' AND auction='$auction[$i]' WHERE typeID='$typeID[$i]'";
    $result1=mysql_query($sql1) or die(mysql_error());
    }

  9. are you use moditer s for multi-line contest

    <?php
    $test = ' <div class="agent_display">
                                            <dl>
                                                <dt>INSZONE INS. SERVICES INC.</dt>
                                                <dd>7200 Fair Oaks Blvd.</dd>
                                                <dd>Suite 210</dd>
                                                <dd>Carmichael, CA 95608</dd>
    
                                                <dd>Phone: (888) 988-9948</dd>
                                                <dd>Fax: (916) 486-4335</dd>
                                                <dd>Hours: </dd>
                                                <dd>M - F 8:00 a.m. to 7:00 p.m.</dd>
    
                                                <dd>License: OF82764</dd>
    
                                                <dd><a href="http://agents.mercuryinsurance.com/agentlocator/DisplayQuote.do?AgentCode=045238"><img src="images/faa_agents_button_contact.gif" alt="Contact this agent" /></a> 
    
    										</dd>
                                            </dl><br class="clear" />
                                        </div><!-- close agent_display -->
    ';
    preg_match('/<div class=("|\')agent_display("|\')>(.*?)<\/div>/s', $test, $out);
    print_r($out);
    ?>

  10. try

    <?php
    $test = 'function x1($p1,$p2)
    {
    echo \'test\';
    echo \'test\';
    }
    
    function x2($a)
    {
        if(1> 0){
            echo \'hi\';
        }
    }';
    $test = ' '.$test;
    $fun = array();
    $of = 0;
    while($sta = stripos($test, 'function', $of)){ 
        $ob = stripos($test, '(', $sta+=7);
        $name = substr($test, $sta+1, $ob-$sta-1);
        $cb = stripos($test, ')',$ob);
        $param = substr($test, $ob+1, $cb-$ob-1);
        $cnt = 1;
        $start = strpos($test, '{', $cb);
        $ss = $start;
        while ($cnt){
            $s = strpos($test, '{', $ss+1);
            $e = strpos($test, '}', $ss+1);
            if($s < $e  and $s > 0){$cnt++; $ss = $s;} else {$cnt--; $ss = $e;}
        }
        $end = $ss;
        $body = substr($test, $start+1, $end - $start-1);
        $of = $ob;
        $fun[]= array(trim($name), trim($param), trim($body));
    }
    print_r($fun);
    ?>

  11. are you try it

    <?php
    $message = 'Step:111.Description:this is testing of &.Link:http://localhost/view.php?s=2&a=4.Endbla b la Step:2211.Description:this is testing of iiii&.Link:http://localhost/view.php?s=2&a=994.End
        xxxx Step:113.Description:this is testing of &2.Link:http://localhost/view.php?s=992&a=4.End';
    $message = preg_replace('/Step:(\d+)\.Description:(.+?)\.Link:(.+?)\.End/', '\1 - <a href="\3">\2</a>', $message);
    echo $message;
    ?>

    as you see it works for multiple replaces

     

    Explain regex

    /              - start of regex

    Step:      - literaly

    (\d+)      - one or more digits () means grab subparten, used in replace part as \1

    \.Description: - literaly

    (.+?) - one or more caracther (? means shorten posible string) subparten \2

    \.Link: literaly

    (.+?) - one or more characters

    \.End literaly

    /

  12. try

    <?php
    $message = 'Step:111.Description:this is testing of &.Link:http://localhost/view.php?s=2&a=4.End';
    $message = preg_replace('/Step:(\d+)\.Description:(.+?)\.Link:(.+?)\.End/', '\1 - <a href="\3">\2</a>', $message);
    echo $message;
    ?>

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