Jump to content

d22552000

Members
  • Posts

    535
  • Joined

  • Last visited

    Never

Posts posted by d22552000

  1.  
    $link = mysql_connect('localhost', 'root', ''); $db = mysql_select_db('test',$link);
    
      $arr = array('Buildings','Research','fleets');
    
      foreach($arr as $v) {
        $sql = "UPDATE `$v` SET `Action Name` = `Action Name`+1 WHERE `Action Time` >= 1";
        if (mysql_query($sql)) {
          echo "$v updated";
        }
      }
    
      $sql = "UPDATE `jobs` SET `Action Time`=`Action Time`-1 WHERE `Action Time` >= 1";
      if (mysql_query($sql)) {
        echo "jobs updated";
      }
    

     

    updates the jobs correctly and leaves them at 0 (good thing.)

    but DOES NOT update the metal mine or others in "buildings" "research" or "ship"

     

    I never get "$v updated"..

     

    can you please help me incorperate (echo *mysql_error* ?

     

    =========edit

    how can I put:

     

    DELETE FROM `jobs` WHERE `jobs`.`Action Time` = 0;
    DELETE FROM `jobs` WHERE `jobs`.`Action Time` = 1;
    

    into the source AFTER the updating times and buidlings step?

  2. You can replace all that code with this:

     

    <?php
    
    $sql = "UPDATE 'Buildings' SET '" . $row['Action Name'] . "'='" . $row['Action Name'] . "'+1 WHERE 'Owner' = " . $row['Owner']." AND `Action Type`='Build'";
    $result = mysql_query($sql)or die(mysql_error());
    
    
    $sql = "UPDATE 'Research' SET '" . $row['Action Name'] . "'='" . $row['Action Name'] . "'+1 WHERE 'Owner' = " . $row['Owner']." AND `Action Type`='Research'";
    $result = mysql_
    query($sql)or die(mysql_error());
    
    
    $sql = "UPDATE 'fleets' SET '" . $row['Action Name'] . "'='" . $row['Action Name'] . "'+1 
    WHERE 'Owner' = " . $row['Owner']." AND `Action Type`='Ship'";
    $result = mysql_query($sql)or die(mysql_error());	
    
    
    $query = "UPDATE `jobs` SET `Action Time`=`Action Time`-1 WHERE `Action Time` >= 1";
    $result = mysql_query($query)or die(mysql_error());
    
    ?>
    

     

    Will this do the update for type for EVERY column in the database, or just the first one of each typpe?

     

    I am only  using the foreach and while loops because that Is the only way that I know how to retrieve multiple rows form a database in an array.

  3. I have programmed the foloowing:

     

    (do you think it will do what I want?)

     

    
    <?PHP
    
    $link = mysql_connect('localhost', 'root', ''); $db = mysql_select_db('test',$link);
    
    $sql = "SELECT *  FROM `jobs` WHERE `Action Time` >= 1"
    $result = mysql_query($sql);
    
    	while($row = mysql_fetch_array($result, MYSQL_ASSOC))
    	{
    		foreach ($row['Action Time'] as $Time) {
    			if ($row['Action Type'] == "Build") {
    				$sql = "UPDATE 'Buildings' SET '" . $row['Action Name'] . "'='" . $row['Action Name'] . "'+1 WHERE 'Owner' = " . $row['Owner'];
    			}
    			if ($row['Action Type'] == "Research") {
    				$sql = "UPDATE 'Research' SET '" . $row['Action Name'] . "'='" . $row['Action Name'] . "'+1 WHERE 'Owner' = " . $row['Owner'];
    			}
    			if ($row['Action Type'] == "Ship") {
    				$sql = "UPDATE 'fleets' SET '" . $row['Action Name'] . "'='" . $row['Action Name'] . "'+1 WHERE 'Owner' = " . $row['Owner'];
    			}
    		mysql_querry($sql)or die(mysql_error());
    		}
    	} 
    
    
    $query = "UPDATE `jobs` SET `Action Time`=`Action Time`-1 WHERE `Action Time` >= 1";
    $result = mysql_query($query)or die(mysql_error());
    
    ?>
    
    

  4. again, how would I act upon it..?

     

    I am making a game LIKE oGame.  (http://www.ogame.org).

     

    I am making this one tick based instead of real-time.  This file I am editing... is the DOTICK page.

     

     

    would I sitll need to do:

     

    foreach  if ($row['action time']<=1) {

    if ($row['action type'] == "build") {

    update 'BUIDLINGS' where 'USERNAME' = $row['Owner']

    }

     

     

    I know that that syntax sucks, bt you get my point.

  5. I am creating a script to read a table called "jobs" and reading columb "Action TIme".

    This program will read "Action Time" and subtract 1, then write the changes to the db.

     

    $sql = "SELECT *  FROM `jobs` WHERE `Action Time` >= 1"
    $result = mysql_query($sql);
    
    while($row = mysql_fetch_array($result, MYSQL_ASSOC))
    {
       		foreach ($row['Action Time'] as $Time) {
    	$Time = $Time - 1;
    	}
    } 
    

     

    now that I have subtracted from the values... how do I update the rows in the same order?

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