Jump to content

craygo

Staff Alumni
  • Posts

    1,972
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by craygo

  1. Sorry forgot you were using access and odbc

     

    replace with this

    $time = array();
    $sql = "SELECT Date, Extension, Duration
    FROM AllInfo 
    WHERE Extension = '$ex' AND Date=#$id#
    GROUP BY Date, Extension";
    $result = odbc_exec($odbc, $sql) or die(odbc_error());
    while($r = odbc_fetch_array($result)){
    $time[] = $r['Duration'];
    }

     

    Ray

  2. you would query the database first to get the number of clicks then just use a simple if statement.

     

    <?php
    $disabled = $r['tablefield'] > 1 ? "disabled=\"disabled\"" : "";
    echo "<input type=\"submi\"t name=\"submit\" value=\"submit\" $disabled />\n";
    ?>

     

    Ray

  3. format is like this

     

    $query = "SELECT player_id, type, price, username, crew, crewname
              FROM dom_london
              INNER JOIN user_info ON user_info.id = dom_london.player_id
              INNER JOIN crews ON user_info.crew = crews.id
              WHERE dom_london.id = '$section'";

     

    Ray

  4. look at your db class and make sure your variables are in the right locations.

     

    $db = new Database('localhost','database name','password','database name');

     

    It is probably a mistype but you have database name in there twice. want to make sure your values are in the right place

     

    Ray

     

     

  5. It can also be a script which seperates the url into parts then includes a certain part of the url as a page.

     

    example

    You start of in www.acme.com/index.php. on that page you have a link which goes to www.acme.com/about. At the top of index.php you have something like this

    <?php
    $uri_split = explode("/", $_SERVER['REQUEST_URI']);
    $tmp = array();
    foreach($uri_split as $key => $val)
    {
    	if(!empty($val) || $val != "")
    	{
    		$tmp[count($tmp)] = $val;
    	}
    }
    $uri_split = $tmp;
    if(!isset($uri_split[0]))
    {
    	$uri_split[0] = "about_us";
    }?>

     

    Now you just include the page in index.php

    include($uri_split[0]);

     

    hope I got that right. Just grabs bits from one of my scirpt. :)

     

    Ray

     

  6. What type of column is the Duration field. If it is just a text or varchar field, you will get the error. problem is the duration column can't be summed because it has those special characters in it. so a function will have to be made to add them up. try this out

     

    <?php
    function get_seconds($t){
    $seconds = 0;
      if(is_array($t)){
        foreach($t as $v){
        $array = array();
        $pt1 = array();
        $pt2 = array();
        $array = explode(':', $v);
        $pt1[] = $array[0];
        $pt2 = explode("'", $array[1]);
        $time = array_merge($pt1, $pt2);
        $sec = $time[2];
        $min = $time[1]*60;
        $hour = $time[0]*60*60;
        $seconds += ($sec+$min+$hour);
        }
      } else {
      $array = explode(':', $t);
      $pt1[] = $array[0];
      $pt2 = explode("'", $array[1]);
      $time = array_merge($pt1, $pt2);
      $sec = $time[2];
      $min = $time[1]*60;
      $hour = $time[0]*60*60;
      $seconds += ($sec+$min+$hour);
      }
    return $seconds;
    }
    $time = array();
    $sql = "SELECT Date, Extension, Duration 
    	FROM AllInfo 
    	WHERE Extension = '$ex' AND Date=#$id#				
    	GROUP BY Date, Extension";
    $result = mysql_query($sql) or die(mysql_error());
    while($r = mysql_fetch_assoc($result)){
    $time[] = $r['Duration'];
    }
    
    $seconds = get_seconds($time);
    echo "<td class=\"borderTable\"><center>".date("H:i:s", mktime(0, 0, $seconds))."</center></td class=\"borderTable\"></table><p></p>";
    ?>

     

    Ray

  7. There is no need to count rows to get the loop to end. The while statement will only run as long as rows are being returned. It will stop on it's own when the end is reached.

     

    Also remember that field names and table names should be in backticks (`) and field values should be in single quotes (').

     

    <?php
    $totalweight = 0;
    $query = "SELECT `weight` FROM `sites` WHERE `user` = '$user'";
    $result = mysql_query($query) or die(mysql_error());
    while ($sites = mysql_fetch_assoc($result)){
    $totalweight += $sites['weight'];
    }
    $query = "UPDATE `user` SET `weight` = '$totalweight' WHERE `user` = '$user'";
    $result = mysql_query($query) or die(mysql_error());
    
    ?>

     

    Ray

  8. Thing with checkboxes is they are not passed if they are not checked. so you will have to put a check before you insert into the database

     

    $SubscribeToNewsletter = isset($_POST['SubscribeToNewsletter']) ? "1" : "0";

     

    Now if it is set $subscribeToNewletter will equal 1 if not is will be equal to 0;

     

    Ray

     

  9. First thing you should know is this.

    you can get the minutes from using the date and mktime function

     

    echo "<td class=\"borderTable\"><center>".date("g:i", mktime(0, $row["CountOfDuration"]))."</center></td class=\"borderTable\"></table><p></p>";	}

     

    does this return just one row??

    Duration contain seconds or minute??

    DurationS holds ??

    Do you want to show a running total or something like that??

     

    Ray

     

     

     

     

  10. Probably your best bet. Not sure how often the API information changes. You could set up a script to run from a cron job to update the database once a day or something. Then querying the database would take milliseconds.

     

    Ray

  11. try this

    <?php
    function get_seconds($time){
    $array = explode(':', $time);
    $pt1[] = $array[0];
    $pt2 = explode("'", $array[1]);
    $time = array_merge($pt1, $pt2);
    $sec = $time[2];
    $min = $time[1]*60;
    $hour = $time[0]*60*60;
    $seconds = $sec+$min+$hour;
    return $seconds;
    }
    
    $time = "2:20'13";
    echo get_seconds($time);
    ?>

     

    Ray

  12. Try this out

     

    <?php
    $query = "SELECT `impressions`, `url` FROM `sites`";
    $result = mysql_query($query) or die(mysql_error());
    while ($sites = mysql_fetch_assoc($result)){
    $url = $sites['url'];
    $impessions = $sites['impressions'];
    $weight = ceil($dmozbonus*$indexed*($impressions*$siteprbonus*5996)/(750000 - $impressions));
    $update = "UPDATE `sites` SET `weight` = '$weight' WHERE `url` = '$url'";
    mysql_query($update) or die(mysql_error());
    }
    ?>

     

    Ray

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