Jump to content

artacus

Members
  • Posts

    737
  • Joined

  • Last visited

    Never

Posts posted by artacus

  1. LOL. I wasn't serious. That's funny though.

     

    So how come you can't edit the db structure?

    If its not YOUR database, then I would create another mysql database and import the data into that one. When you do that, change is so you have both the start_time and end_time for each stop. That way you will only have 1 row for each stop. It will make your life easier.

  2. I dont know what you mean by "once you get it workin". As I say before, I am still a newbie.

    I have to do something with that code? Is not functional as it is?

     

    We don't know every detail about your environment and such. We'll give you the big picture "fix" and some details but its up to you to meld that knowledge into your particular situation.

  3. I can't change the DB structure.

    Then tell your drivers not to park in the same spot.

     

    I don't know then. You may have to pull it back into PHP and calc it there. But I really hate doing that. Let me think about this some more.

  4. Ok, I found a resource for you.

    http://dev.mysql.com/tech-resources/articles/hierarchical-data.html

     

    The top 1/3 of the page describes the adjacent model, which is what you are doing right now. But take a look at the bottom 2/3 of the page, The Nested Set Model. That's really what you should be using in your situation. And since the page is mysql specific, all your queries are practically written for you if that's what you're using.

     

  5. Ok, first you should use parent_id instead of parent_name. Its much easier to join that way. (Oops, I see that Barand already mentioned that.)

     

    His recursive function will work pretty well for the display page... once you get it working.

     

    But for heavier lifting you might need a better data structure. I don't know what your categories are about, but consider a query that might be like "Show all items on the same trunk as the leaf 'fur parka'" So you'd have to find the ultimate parent of 'fur parka' which might be 'coats' and then proceed back down that branch. Its really hard to do w/ a single db query when you don't know how many levels you are going to be nested.

     

    There used to be a great tutorial over a phpriot but I don't think they are around any more. You can read more about how to handle nested trees on wikipedia.

     

    http://en.wikipedia.org/wiki/Tree_data_structure

  6. Yeah, were you the same one that asked about this last week? If so I told  you it would be a problem then.

     

    I'm just shooting from the hip here, but the first thing that comes to mind is to add a stop_number field. So for each vehicle, each day the first stop would be #1. If it is stopped in the same position the next time it is checked then it would be recorded still at stop #1, if it had moved that would be stop #2.

  7. Heh, you think its godforsaken now, just wait 'till you start running queries against it. Its SLOWWWW.  Especially if you are used to counting  your query time in milliseconds in mysql.

  8. Sure, you're just going to have to figure out if you need to crop from top and bottom or from left and right.

    $lg_x = 200;
    $lg_y = 150;
    $src_img = imagecreatefromjpeg($ph_link);
    $s_x = imagesx($src_img);
    $s_y = imagesy($src_img);
    
    $temp = imagecreatetruecolor($lg_x, $lg_y);
    
    if($s_x / $s_y > $lg_x / $lg_y) {
    //trim x
    $x = round(($s_x - ($lg_x * $s_y / $lg_y)) / 2);
    $y = 0;
    } else if ($s_x / $s_y > $lg_x / $lg_y) {
    //trim y
    $x = 0;
    $y = round(($s_y - ($lg_y * $s_x / $lg_x)) / 2);
    } else {
    $x = 0;
    $y = 0;
    }
    //create large image
    imagecopyresampled($temp, $src_img, 0, 0, $x, $y, $lg_x, $lg_y, $s_x, $s_y);
    imagejpeg($temp, $filename);
    

  9. Are you using the Merant ODBC driver? Its quirky at best. I don't think I ever found a PROGRESS ODBC driver for *nix. Mine is set up on a Windows box, but it works.

     

    1) Set up a system DSN. Set the isolation level to "READ UNCOMMITED" or it will lock other users out when  you are querying tables.

    2)  In php try something like this

    $dsn = 'PROGRESS';

    $user = 'odbcuser';

    $pw = 'password';

    $odbc_con  = odbc_connect($dsn,$user,$pw,SQL_CUR_USE_ODBC) or die(odbc_error());

  10. yep, you need help alright. More than we can give you. I'd suggest trying to use an already developed CMS. Check out Drupal and see if that will work for you.

  11. So lets see if I understand... a single voter is going to vote for (up to) 25 teams? It looks like shoz has a pretty good handle on it. But I'd recommend you fill table two with your teams, 0 points and 0 first place votes and then after every vote, run what shoz gave you as an update query.

  12. Yet another brilliantly asked vague question.

     

    I think what you are trying to ask is, "when a user selects an option from a list, I want a second option list to be populated based on what was selected in the first."

     

    If that's the question you just asked, then the answer is, "you do it with AJAX." If that's not the question you asked, then restate it.

  13. I'm a little late for the party, but I use a custom function I wrote for this purpose. Someone may find it useful.

    [code]
    function walk($table,$location,$where,$dir=1) {
    //Walks through a table and returns either the next item or the previous one
    //$dir 1 = walk forward / $dir -1 = walk backwards

    //set where_clause
    for ($i=0; $i < count($where); $i++) {
    if (current($where) == 'IS NOT NULL' || current($where) == 'IS NULL') {
        $where_clause .= " AND ".key($where).' '.current($where);
    } else {
        $where_clause .= " AND ".key($where)."='".current($where)."'";
    }
    next($where);
    }

    //set direction
    if ($dir > 0) {
        $gtlt = '>';
    $order = '';
    } else {
    $gtlt = '<';
    $order = 'DESC';
    }
    $column = key($location);
    $position = current($location);
    if (!$position) {
        $position = 0;
    }

    $query = "SELECT $column FROM $table WHERE $column $gtlt $position $where_clause
      ORDER BY $column $order LIMIT 1";

    $result = mysql_query($query);
    if (mysql_num_rows($result)) {
        return mysql_result($result, 0);
    } else {
    return 0;
    }
    }
    [/code]
×
×
  • 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.