Jump to content

The Little Guy

Members
  • Posts

    6,675
  • Joined

  • Last visited

Posts posted by The Little Guy

  1. mysql_query only returns a data set. you need to use mysql_fetch_array or mysql_fetch_assoc like this:

     

     

    $sql = mysql_query("SELECT dayname((date(FROM_UNIXTIME(dateline)))) as 'Day Of Week', date((date(FROM_UNIXTIME(dateline)))) as 'Date', count(*) as 'Number of Opened Tickets', ( select count(ticketmaskid) from swtickets where date(FROM_UNIXTIME(swtickets.lastactivity)) = Date and isresolved=1 ) as 'Number of Closed Tickets' from swtickets where ((date(FROM_UNIXTIME(dateline)) between (DATE_SUB(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())=1, 9, DAYOFWEEK(CURDATE()))) DAY)) and (DATE_ADD(CURDATE(), INTERVAL (6 - IF(DAYOFWEEK(CURDATE())=1, 8, DAYOFWEEK(CURDATE()))) DAY)) )) group by date(FROM_UNIXTIME(dateline))");
    
    while($row = mysql_fetch_assoc($sql)){
    echo "<p>{$row['Day Of Week']}</p>";
    }
    

  2. I would like to get a count, even if there is a count of zero.

     

    example: I have 2 domains in the database, each domain has zero searches on them, I would still like to get them, but display 0 for the count. Any suggestions on what I should do? I can't seem to think how.

     

    select d.domain, count(*) total from domains d left join searches s on(d.domain_id = s.domain_id and d.member_id = 1) group by d.domain_id

     

    Thanks for the help!

    Are you saying that you don't get back 2 records?

     

    Correct. I should get back 2 records, and count should contain 0 for both.

     

    @joel24 that doesn't work, as it comes back with a count of 1.

     

    I should note that the searches table has 0 records in it.

  3. I would like to get a count, even if there is a count of zero.

     

    example: I have 2 domains in the database, each domain has zero searches on them, I would still like to get them, but display 0 for the count. Any suggestions on what I should do? I can't seem to think how.

     

    select d.domain, count(*) total from domains d left join searches s on(d.domain_id = s.domain_id and d.member_id = 1) group by d.domain_id

     

    Thanks for the help!

  4. I don't know if you need to be logged in to download, or not, but here is a simple solution (IMO).

     

    - When the user clicks on the link, insert into the database either their user_id, or their ip address

    - When you load the page, check to see if the value is in the database, if it is don't show it.

            - If you base it on IP address, you will probably only want to limit the last download to a certain period, due to dynamic IP addresses.

  5. Wouldn't that be a lot of work?

     

    Programming isn't a walk in the park. If you wan't valid reliable data you need to put work into it. If you don't validate the data, what would you do if I decide I want to use the date "Monkey Pants"?

  6. convert it to a time:

     

    $starttime = date("Y-m-d H:i:s", strtotime($_POST['date']));

     

    This isn't the best solution, because not everything will be converted properly. I would recommend having pre-define values that users can select, such as a drop down, or separate input fields that each get validated as a month, day or year.

  7. By using my method, (Which will save your from writing lots of php/mysql, at least more than needed), Go into phpMyAdmin and look a the structure of the table jupiter.

     

    Check the boxes  for the fields "code" and "ip". Next go to the bottom of the table and click the button "Unique" this will make it so that BOTH code and ip are unique columns.

     

    Code, ip

    3werwf, 1.1.1.1

    3werwf, 1.1.1.1                        <- This insert will fail

    3werwf, 1.1.1.2                        <- This insert will succeed

    3w, 1.1.1.1                              <- This insert will succeed

    asdfsadfas,12.234.45.544      <- This insert will succeed

    asdfsadfas, 1.1.1.1                  <- This insert will succeed

     

    Make sense?

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