Jump to content

joel24

Members
  • Posts

    760
  • Joined

  • Last visited

Posts posted by joel24

  1. mysql_fetch_object creates the mysql results as an object, where as mysql_fetch_array puts the results into an array...

     

    $row = mysql_fetch_object($rs_forms);

    $row->forms; will retrieve forms

     

    or, a much more practical solution in this case

    $row = mysql_fetch_array($rs_forms);

    $row['forms'];

     

    ... in the code

    <?
              $sql_forms = "SELECT forms FROM target_word";
      $rs_forms = mysql_query($sql_forms,$db);
      $row = mysql_fetch_array($rs_forms);
    
      $forms = $row['forms'];
      $count = substr_count($forms, ',') + 1;
    ?>            
    Total Word Forms = <span class="digit"><?=$count?></span>
    

  2. you're not fetching the array returned from the database,

    
    <?php
    
    $id = (int) $_GET['team'];
    
    $max_col = 100;
    
    $query = "SELECT * FROM teams WHERE id=$id";
    
    $result = mysql_query($query) or die(mysql_error());
    
    $teamRow = mysql_fetch_array($result);
    
    //now all your database information is stored in the array $teamRow
    // i.e $teamRow['wins']; will be the value stored in a field named "wins"	
    
    $wpct = @($teamRow['wins']/$teamRow['games']);
    
    echo "Team Name: {$teamRow['teamname']}<br>
    
    Sport: {$teamRow['sport']}<br>
    
    Games: $games<br>
    
    Wins: $wins<br>
    
    Losses: $losses<br>
    
    Winning Percentage: "; echo number_format("$wpct",3);
    ?>
    

  3. I'm sure you could do it easily with preg_replace or using strpos() and str_replace() and substr().

     

     

    something like this would work, but i wouldn't rely on it. i'd go for preg_replace if someone experienced with regular expressions is kind enough to share their knowledge?

    $string = '<a href="users.php?id=3">Username</a>';
    
    //get rid of closing </a>
    $string = str_replace("</a>", "", $string);
    
    //get position of end of anchor tag. add 2 to str pos because it returns start of ">
    $closePos = strpos($string, '">') + 2;
    $string = substr($string, $closePos, 100);
    

  4. chud37, you'd use regular expressions in preg_replace() function to perform that task. I'm not all too good with regular expressions but this will work to find all instances of "man" with a space either side. '\s' denotes a space while '/' signifies the search string

    i'm sure someone else could help to change the search expression so it searched for "man" with no alphabetic character next to it.

    $myVar = "I like to read the manual, man";
    
    $search = array("/\sman\s/");
    $replace = array("dude");
    
    $myVar = preg_replace($search, $replace, $myVar);
    
    

     

    and markcunningham07,

    you want to change $myVar to $_GET['fullname'] and remove spaces in it?!

    i.e. $x = str_replace(" ","",$_GET['fullname']);

     

  5. How are you selecting those two rows from the table, what denotes that those two rows are matched to one another and should be listed in the different table.

    i.e. is there a field in the table say LinkID which contains the ID of the linked row?!

  6. you can join the same table to itself, although this is only needed in certain situations and I'm not entirely sure if you need it. You need to describe your mysql table layout/schema and exactly what you're trying to achieve. i.e. user inserts row then row updates xxxx table to have xy field = valueX.

    i.e.

    $sql = @mysql_query("SELECT t1.*, t2.* FROM table1 t1 JOIN table1 t2 ON t1.columnLink = t2.columnLink");

     

     

  7. you've got a update query not assigned to any variable.

     

       if($timenow1 == $timenow5 && $timenow2 >= $timenow6){
                mysql_query("UPDATE leagues SET status='0' WHERE id='$id'"); //assign this to a variable?
    //where is $id coming from?
              $update = mysql_query("SELECT * FROM leagueplayers WHERE league='$id'");
    
                while ($player1 = mysql_fetch_array($update) && $player2 = mysql_fetch_array($update)) //these are running the same query, so both variables in the loop will return the same result. 
                {
                echo $player1[id];
                echo"-";
                echo $player2[id];
             }
            }
    

     

    you need something like

       if($timenow1 == $timenow5 && $timenow2 >= $timenow6){
                $update = mysql_query("UPDATE leagues SET status='0' WHERE id='$id'");
              $select1 = mysql_query("SELECT * FROM leagueplayers WHERE league='$id'");
    $select2 = mysql_query("SELECT * FROM leagueplayers WHERE league='$id'");
    
    
                while ($player1 = mysql_fetch_array($select1) && $player2 = mysql_fetch_array($select2)) //these can't run the same query.
                {
                echo $player1[id];
                echo"-";
                echo $player2[id];
             }
            }
    

     

    i'm still a bit baffled as to what you're trying to achieve. you want to run a loop and update player IDs within the loop? and somewhere in there you want to have it look at 2 players simultaneously?

  8. do something like this, it will echo a new section name as a row/header if it differs from the last article.

    and it will echo a blank row to separate them. you can play around with the HTML to style it how you like.

     

    
    public function listArticle() {
        require_once('../includes/DbConnector.php');
        $connector = new DbConnector();
        $result = $connector->query('SELECT * FROM article ORDER BY section, title');
        echo '<h2>Articles:</h2>';
        if ( $result !== false && mysql_num_rows($result) > 0 ) {
        echo '<table id="table">
             <thead>
            
    
    
    
    <tr>
            
    
    
    
      <th scope="col">Title</th>
            
    
    
    
      <th scope="col">Section</th>
                <th scope="col" style="text-align:center;">Edit?</th>
                <th scope="col" style="text-align:center;">Delete?</th>
              </tr>
            </thead>
        <tbody>';
    
    $lastSection = '';
    
        while ($row = $connector->fetchArray($result)){
             if ($lastSection != $row['section'])
    {
    echo "<tr><td colspan='4'> </td></tr>
    <tr><td colspan ='4'>{$row['section']}</td></tr>";
    }
    
    echo '<tr><td>'.$row['title'].'</td>';
             echo '<td>'.$row['section'].'</td>';
    
      }
      }
      echo '</tbody>
    </table>';
    return;
      }
    

  9. i'm not entirely sure what you're after either,

    however you can update/delete more than one row at a time?

    i.e.

    mysql_query("UPDATE leagues SET status='1' WHERE id='$id1' OR id='$id2'");

     

    but i suspect you want to select two affiliated rows and then do something with them.

  10. you should have if(isset($_POST['submit'])) not if ($submit) where $submit = $_POST['submit'].

    also, you should store all the information you're echoing in the header into a variable and echo it in the HTML body.

    <?php
    session_start();
    
    include_once('../inc/nav.php');
    
    if(isset($_SESSION['username'])){  
    
    include_once('../inc/connect.php');
    
    if (isset($_POST['submit'])){
    
    $answer = $_POST['answer'];
    
    $signature = "If you have anymore questions, feel free to ask! \nThank You,\n<html><a href='http://www.daobux.com'>Daobux Team</a></html>";
    $usermail = ucfirst($username);
    mail("$email", "Reply: $message", "
    Hello $usermail,\n
    $answer\n
    $signature
    ");
    
    $answeredsql = "UPDATE `support` SET `answered`='yes' WHERE number='$number'";
    mysql_query($answeredsql);
    
    
    
    }
    
    $supportsql = "SELECT * FROM `support` WHERE `answered`='no' ORDER BY `date` DESC"; 
    
    $result = mysql_query($supportsql);
    $row = mysql_fetch_assoc($result);
    $num = mysql_num_rows($result); 
    
    $username = $row['username'];
    
    
    
    $i = 0;
    while ($i < $num) {
    
    $user = mysql_result($result,$i,"username");
    $message = mysql_result($result,$i,"message");
    $number = mysql_result($result,$i,"number");
    // echo "<br /><div align='center' id='question'><strong>".ucfirst($user)."<br /></strong>".$message."<br /></div>";
    
    $i++;
    }
    echo "<br /><center>Number of Tickets: ".$num."</center>";
    echo "<br /><div align='center' id='question'><strong>".ucfirst($user)."<br /></strong>".$message."<br /></div>";
    // Find Their Email Address
    
    $emailsql = "SELECT email FROM users WHERE username='$username'";
    $emailresult = mysql_query($emailsql);
    $erow = mysql_fetch_assoc($emailresult);
    
    $email = $erow['email'];
    
    }
    
    ?>
    
    <html>
    <head>
    <title>Support Tickets</title>
    <style>
    #question{
    
    
    
    width: 500px;
    
    
    
    background-color: #cccccc;
    
    
    
    border-style: solid;
    
    
    
    border-width: 2px;
    
    
    
    margin-left: auto;
    
    
    
    margin-right: auto;
    
    
    
    }
    </style>
    </head>
    <body OnLoad="document.supportticket.answer.focus();">
    
    <center>
    <h1>Answer Queries:</h1>
    <form name="supportticket" action="supportticket.php" method="POST">
    <textarea rows="8" cols="50" name="answer"></textarea><br />
    <input type="submit" name="submit" value="Submit">
    </form>
    <br />
    <?php echo $error; ?>
    </center>
    
    </body>
    </html>
    

  11. have you set PHP and mysql timezones on your server?

    [php

    //timezone php

    putenv('TZ=Australia/Sydney');

     

    //get offset, including daylight savings because mysql won't!

    $currentOffset = "+".(date("Z") / 60 / 60).":00";

     

    //timezone mysql

    $update_tz = @mysql_query("SET time_zone = '$currentOffset'") or die(mysql_error());

    [/code]

  12. Where are the <form> tags for the first "Soldier Recruit" form?

    And I only see an opening <form> tag for the "Buy/Sell Soldiers" form.

     

    What do you mean it's not working correctly when you enter a negative integer into the form.

    What happens? Does it treat the negative integer as a positive integer?

  13. either that or you can pass the variable in the URL,

    i.e.

    //define file name
    $filename = 'temp/' .time() . '.png';
    
    $urlFile = urlencode($filename);
    header("index.php?img=$urlFile");
    
    

     

    then on index.php, to display image (providing all

    if (isset($_GET['img']))
    {
    $imagePath = urldecode($_GET['img']);
    echo "<img src='$imagePath' />";
    }
    

     

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