Jump to content

sasa

Staff Alumni
  • Posts

    2,804
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by sasa

  1. pseudo code

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

     

  2. try

    <?php
    mysql_connect('localhost', 'username', 'password'); //change to your username and password
    mysql_select_db('peterodc_selfbuild');
    
    foreach ($_POST['materials'] as $mater){
        $name = $mater['name']; //or is it $id  (not sure... anyone more help)
        $material = $mater['material'];
        $stage = $mater['stage'];
        $unit = $mater ['unit'];
        // satanize inputs
    $sql = mysql_query("UPDATE materials SET material='$material', stage='$stage', quantity='$quantity',unit='$unit' WHERE id='$name'");
    }
    ?>

  3. <?php
    foreach ($_POST['materials'] as $mater){
        $name = $mater['name']; //or is it $id
        $material = $mater['material'];
        $stage = $mater['stage'];
        //and so on
        // satanize inputs
        mysql_query("UPDATE table_name SET material='$material', stage='stage' etc. WHERE id='$name'");
    }
    ?>

    and add disabled="disabled" atribute to your input tag for id_number

  4. change form to

    <input id="<?php print $row['id'];?>" name="attendance[<?php print $row['id'];?>]" type="radio" value="1" checked="checked" />
    <input id="<?php print $row['id'];?>" name="attendance[<?php print $row['id'];?>]" type="radio" value="2" />
    <input id="<?php print $row['id'];?>" name="attendance[<?php print $row['id'];?>]" type="radio" value="3" />

    all in one forrm

  5. change

    $thequery[] = mysql_query("UPDATE anime SET description = '".mysql_real_escape_string($new_description[$i])."', history='".mysql_real_escape_string($new_history[$i])."' WHERE anime_id='".$anime_id[$i]."'");

    to

    $thequery[] = "UPDATE anime SET description = '".mysql_real_escape_string($new_description[$i])."', history='".mysql_real_escape_string($new_history[$i])."' WHERE anime_id='".$anime_id[$i]."'";

  6. try[code[<?php
    function my_replace($srch, $replace, $subject, $skip=1){
        $subject = explode($srch, $subject.' ', $skip+1);
        $subject[$skip] = str_replace($srch, $replace, $subject[$skip]);
        while (($tmp = array_pop($subject)) == '');
        $subject[]=$tmp;
        return implode($srch, $subject);
    }
    $test ='bla bla sasa bla bla sasa bla bla sasa';
    echo my_replace('sasa', 'xxx', $test);
    echo "<br />\n";
    echo my_replace('sasa', 'xxx', $test, 2);
    ?>

  7. <?php
    function test_handleDropDowns($menuname, $userselectedoption) {
        if ($menuname == "ostype") {
            //start echoing the html code to create the dropdown menu
    echo "Operating System: <select name='ostype'>";
    // Create drop down boxes.
            if ($userselectedoption == NULL) $userselectedoption = 'all';
            $options = array('all' => 'All Types', 'windows' => 'Windows', 'linux' =>'Linux');
            foreach ($options as $v => $option) echo "<option value='$v'", ($v == $userselectedoption) ? " selectede='selected'" : "",">$option</option>";
            echo "</select>";
            }
    }
    ?>

  8. are you try this

    <?php
    $hostSignIn0001="server1";
    $userSignIn0001="xxx1";
    $passwordSignIn0001="yyy1";
    $dbnameSignIn0001="zzz1";
    
    
    $hostSignIn0002="server2";
    $userSignIn0002="xxx2";
    $passwordSignIn0002="yyy2";
    $dbnameSignIn0002="zzz2";
    
    $site = 2;
    $site = str_pad($site, 4, '0', STR_PAD_LEFT);
    $host = ${'hostSignIn'.$site};
    $user = ${'userSignIn'.$site};
    echo "$host, $user";
    ?>

  9. $team_select  = "SELECT *, @rank := IF(@points=points, @rank, @rank+1), @points:=points FROM
                    (SELECT         t.team_id,
                            t.team_name, 
                            COUNT(r.league_match_result_id) AS 'matches_played',
                            SUM(IF(r.result='Win',1,0)) AS `wins`, 
                            	SUM(IF(r.result='Loss',1,0)) AS `losses`,
                           	    SUM(IF(r.result='Draw',1,0)) AS `draws`,
                                SUM(IF(r.result='Win',3,IF(r.result='Draw',1, IF(r.result='Loss',0,0)))) AS `points`
                     FROM teams t
                     LEFT JOIN league_match_results r ON r.team_id = t.team_id
                     LEFT JOIN team_leagues tl ON tl.team_id = t.team_id
                     RIGHT JOIN league_matches m ON r.league_match_id = m.league_match_id
                     WHERE tl.league_id = :1
                     GROUP BY t.team_id
                     ORDER BY points, team_name) AS x";

  10. try

    <?php
    // Connects to your Database 
    mysql_connect("**", "**", "**") or die(mysql_error()); 
    mysql_select_db("loginwatsonn") or die(mysql_error());
    echo "Start";
    echo "<br>";
    $result = mysql_query(sprintf("SELECT * FROM Logins WHERE UID = %d", $_COOKIE['UID_WatsonN']));
    //check login table against cookie
    if(($num = mysql_num_rows($result)) > 0){
    mysql_close();
    ?>
    <table border="0" cellspacing="2" cellpadding="2">
    <tr>
    <th>ID</th>
    <th>UID</th>
    <th>Site</th>
    <th>Uname</th>
    <th>Pass</th>
    </tr>
    
    <?php
    $i=0;
    while ($i < $num) {
    
    $f1=mysql_result($result,$i,"ID");
    $f2=mysql_result($result,$i,"UID");
    $f3=mysql_result($result,$i,"Site");
    $f4=mysql_result($result,$i,"Uname");
    $f5=mysql_result($result,$i,"Pass");
    ?>
    
    <tr>
    <td><?php echo $f1; ?></td>
    <td><?php echo $f2; ?></td>
    <td><?php echo $f3; ?></td>
    <td><?php echo $f4; ?></td>
    <td><?php echo $f5; ?></td>
    </tr>
    
    <?php
    $i++;
    }
    }
    ?>

  11. are you try this query

    i'm just copy your query and i don't see tha you use ' instead ` change this

    
    $team_select  = "SELECT @rank := @rank + 1 AS `rank`,
                            t.team_id,
                            t.team_name, 
                            COUNT(r.league_match_result_id) AS `matches_played`,
                            SUM(IF(r.result='Win',1,0)) AS `wins`, 
                            SUM(IF(r.result='Loss',1,0)) AS `losses`,
                            SUM(IF(r.result='Draw',1,0)) AS `draws`,
                                          SUM(IF(r.result='Win',3,IF(r.result='DRAW',2,0))) AS `points`
                     FROM teams t
                     LEFT JOIN league_match_results r ON r.team_id = t.team_id
                     LEFT JOIN team_leagues tl ON tl.team_id = t.team_id
                     RIGHT JOIN league_matches m ON r.league_match_id = m.league_match_id
                     WHERE tl.league_id = 1
                     GROUP BY t.team_id
                     ORDER BY team_name";

    this line 'SUM(IF(r.result='Win',3,IF(r.result='Draw',2,0))) AS `points`' means

    if result is Win use 3 else if result is Draw use 2 else use 0 and sum this number

     

    btw. DRAW != Draw

  12. <?php$test = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.<img alt="something" src="http://www.somesite.com/images/image1.jpg" style="width: 400px; height: 300px;" />Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco<img alt="something" src="http://www.somesite.com/images/image2.jpg" style="width: 400px; height: 300px;" />Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco';$out = preg_replace('~<img [^>]*src="(http://([^"/]+)[^"]+)"[^>]*>~', '<img alt="$2" src="http://www.site.com/phpthumb.php?$1?w=400" />', $test);echo $out;?>

     

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