Jump to content

Barand

Moderators
  • Posts

    24,566
  • Joined

  • Last visited

  • Days Won

    822

Everything posted by Barand

  1. Then your query failed and mysql_query is returning "false" echo mysql_error() after calling mysql_query() to see why
  2. Take a look at the glob function
  3. try this SELECT sc.StringyChat_name , sc.StringyChat_ip , sc.StringyChat_time FROM StringyChat sc INNER JOIN ( SELECT StringyChat_name , MAX(StringyChat_time) as StringyChat_time FROM StringyChat GROUP BY StringyChat_name ) latest USING (StringyChat_name, StringyChat_time) WHERE sc.StringyChat_time >= (UNIX_TIMESTAMP() - 3600) AND StringyChat_name NOT IN ( '" . implode($galleries, "', '") . "' ) ORDER BY StringyChat_time DESC LIMIT $offset, $rowsperpage If that gets what you want then you need to JOIN to user2 to get the id's in the same query. (Don't run queries inside loops)
  4. Because you use SELECT * there is no way I can know what you really want from the table. You could SELECT name, MAX(date) FROM table GROUP BY name but, as I said, I don't know what else you want
  5. When you GROUP BY (in this case) name you get ONE row for each name. If a particular name has 100 records with different times it can only display the time from one of the records. The manuals states the choice will be arbitrary but it usually takes the first value from the group - hence the oldest.
  6. And as you are using a prepared statement anyway, you should be using a placeholder and binding the parameter value. That's the reason for prepared statements.
  7. You need quotes around string values WHERE username = '{$_GET['username']}'
  8. Sorry, I didn't realize that was teaching, it sure confused me.
  9. try this to correct the dates in the table UPDATE date_sample SET date = CASE WHEN dayofweek(date)=1 THEN date + INTERVAL 1 DAY -- change Sun to Mon WHEN dayofweek(date)=7 THEN date - INTERVAL 1 DAY -- change Sat to Fri ELSE date -- leave weekdays alone END If you want to leave them alone in the table but modify on selection then you can use the same CASE statement SELECT CASE WHEN dayofweek(date)=1 THEN date + INTERVAL 1 DAY -- change Sun to Mon WHEN dayofweek(date)=7 THEN date - INTERVAL 1 DAY -- change Sat to Fri ELSE date -- leave weekdays alone END as date FROM table
  10. You could ... ORDER BY date='$XXX' DESC LIMIT 1
  11. If you want historical pricing then you want a price table like price DECIMAL(10,3), valid_from DATE, valid_to DATE The current price would have valid_to date of 9999-12-31. When you add a new price from, say, tomorrow, then the current price valid_to is set to today and the new price becomes the current_price (from tomorrow until 9999-12-31) You then match your (old) items like this SELECT item_desc , qty , price FROM item INNER JOIN prices ON item.date BETWEEN prices valid_from AND prices.valid_to
  12. Do you mean something like this? SELECT * FROM ( SELECT date , price , @seq:=@seq+1 as seq FROM tablename JOIN (SELECT @seq:=0) as init ORDER BY date DESC ) sequence WHERE seq = 2 OR date = '$XXX' [edit] This does seem an odd solution to a problem. What is the actual situation and the problem you are trying to solve?
  13. It is a keyword but it is not reserved, therefore permitted as an identifier http://dev.mysql.com/doc/refman/5.5/en/keywords.html
  14. BTW, there is no "active_specialty" column Does this do it? SELECT C.yrwk , sum(slab) as slab , sum(dried_in) as dried_in , sum(drywall) as drywall , sum(frame) as frame FROM ( (SELECT DATE_FORMAT(l.frame_date, '%X-%V') as yrwk, null as slab, null as drywall, COUNT(IF(l.frame_date is not null, 1, 0)) AS frame, null AS dried_in FROM lot as l INNER JOIN lot_type AS lt ON l.lot_type_id = lt.lot_type_id INNER JOIN block as b ON b.block_id=l.block_id INNER JOIN community as c ON c.community_id=b.community_id WHERE ( c.contract_type_id = 1 OR c.contract_type_id = 2 ) AND l.active=1 AND l.lot_type_id <> 1 and l.frame_date is not null and (frame_date <= CURDATE() and frame_date >= DATE_ADD(DATE_ADD(CURDATE(),INTERVAL -11 month), interval -(day(DATE_ADD(CURDATE(),INTERVAL -11 month)) - 1) day)) GROUP by yrwk ) UNION ALL (SELECT DATE_FORMAT(l.drywall_date, '%X-%V') as yrwk, null as slab, COUNT(IF(l.drywall_date is not null, 1, 0)) AS drywall, null as frame, null AS dried_in FROM lot as l INNER JOIN lot_type AS lt ON l.lot_type_id = lt.lot_type_id INNER JOIN block as b ON b.block_id=l.block_id INNER JOIN community as c ON c.community_id=b.community_id WHERE ( c.contract_type_id = 1 OR c.contract_type_id = 2 ) AND l.active=1 AND l.lot_type_id <> 1 and l.drywall_date is not null and (drywall_date <= CURDATE() and drywall_date >= DATE_ADD(DATE_ADD(CURDATE(),INTERVAL -11 month), interval -(day(DATE_ADD(CURDATE(),INTERVAL -11 month)) - 1) day)) GROUP by yrwk ) UNION ALL (SELECT DATE_FORMAT(l.slab_date, '%X-%V') as yrwk, COUNT(IF(l.slab_date is not null, 1, 0)) AS slab, null as drywall, null as frame, null AS dried_in FROM lot as l INNER JOIN lot_type AS lt ON l.lot_type_id = lt.lot_type_id INNER JOIN block as b ON b.block_id=l.block_id INNER JOIN community as c ON c.community_id=b.community_id WHERE ( c.contract_type_id = 1 OR c.contract_type_id = 2 ) AND l.active=1 AND l.lot_type_id <> 1 and l.slab_date is not null and (slab_date <= CURDATE() and slab_date >= DATE_ADD(DATE_ADD(CURDATE(),INTERVAL -11 month), interval -(day(DATE_ADD(CURDATE(),INTERVAL -11 month)) - 1) day)) GROUP by yrwk ) UNION ALL (SELECT DATE_FORMAT(l.dried_in_date, '%X-%V') as yrwk, null AS slab, null as drywall, null as frame, Count(IF(l.dried_in_date is not null, 1 , 0)) AS dried_in FROM lot as l INNER JOIN lot_type AS lt ON l.lot_type_id = lt.lot_type_id INNER JOIN block as b ON b.block_id=l.block_id INNER JOIN community as c ON c.community_id=b.community_id WHERE ( c.contract_type_id = 1 OR c.contract_type_id = 2 ) AND l.active=1 AND l.lot_type_id <> 1 and dried_in_date is not null and (dried_in_date <= CURDATE() and dried_in_date >= DATE_ADD(DATE_ADD(CURDATE(),INTERVAL -11 month), interval -(day(DATE_ADD(CURDATE(),INTERVAL -11 month)) - 1) day)) GROUP by yrwk ) ) as C GROUP BY C.yrwk;
  15. "lot_type" table?
  16. Does this help? SELECT DATE_FORMAT(frame_date, '%X-%V') as yr_wk WHERE frame_date > CURDATE() - INTERVAL 6 MONTH will give you the YYYY-WW year and week number (weeks beginning Sunday) for the last six months. Much easier than all those case statements.
  17. Also, $retvalran['sstud_id'] does not exist - the column name is 'stud_id' and not 'sstud_id'. If you are just transferring data from students table to newstudent table then all you need is a single query INSERT INTO newstudent (stud_id, name) SELECT stud_id, namestud FROM students
  18. Moving to Application Design forum. I would use a 36 hour day instead of a 24 hr day. If the end time < start time, add 24hr to end time (so 20:00 - 04:00 becomes 20:00 - 28:00) Now you can have a shift/booking as a single div as before | | 00 04 08 12 16 20 00 04 08 12 | | | | | +-----------+ | |20:00-28:00| | +-----------+ | | | +-----------+ | | |09:00-16:00| | | +-----------+ | | | | |
  19. If you still want the records but not show the date when it is 0000-00-00 then SELECT t1.`id_plano` , t1.`atividade` , NULLIF(t1.`data_prevista`, 0) as `data_prevista FROM `new_pae` AS t1 WHERE t1.`id_user` = '$idUser' AND t1.`data_prevista` <= CURDATE() AND (t1.`realizado` IS NULL OR LENGTH(t1.`realizado` ) =0) or just insert null dates instead of 0000-00-00 from the outset
  20. if you run this query SELECT * FROM zamjene_brojeva WHERE glavni_broj='966 45 19-68' does it list those four records?
  21. Firstly, given that this is an example of the html code generated by your script <select name="choosecost1" size="1" value=""> <option value=""></option> <option value="200" selected="selected" ='selected="selected" '="">Cost:$200.00</option> <option value="100" =''="">Cost to Members:$100.00</option> </select> I am surprised it worked at all. Secondly, php scripts each have their own individual scope. Defining a variable on page 2 does not define it for you on page 1. The only thing I can think of, off the top of my head, is that it relied on register_globals being set (which was already obsolete 10 years ago)
  22. Just swap the $a and $b round uasort($data, function($a, $b) { $total = $b['total'] - $a['total']; //SORT BY DESC if($total === 0) { return strcmp($a['emp'], $b['emp']); // THIS line now sorts by ASC } return $total; });
  23. Do you have more than one record for each employee in the EmployeeDetails table. You probably need to join on empid and formid
  24. Don't post the same question in different forums. Closing this one.
×
×
  • 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.