Jump to content

Barand

Moderators
  • Content Count

    21,010
  • Joined

  • Last visited

  • Days Won

    512

Barand last won the day on September 22

Barand had the most liked content!

Community Reputation

1,569 Excellent

About Barand

  • Rank
    Sen . ( ile || sei )

Profile Information

Recent Profile Visitors

64,558 profile views
  1. Yes, there will be some variables to output that were prepared in the php section, but any validation conditions requiring you to send a location header to another page will have occured before anything is sent to the browser in the html section.
  2. Simples! Do your php processing before the html section. <?php ?> <html> </html>
  3. Perhaps ## ## create a test table ## $db->exec("CREATE TABLE IF NOT EXISTS production_status ( id int not null auto_increment primary key, submit_time datetime ) "); ## ## randomly add 1,000 records for last 2 months ## $data = []; for ($i=0; $i < 1000; $i++) { $r = rand(1, 60); $dt = date('Y-m-d H:i:s', strtotime("-$r days")); $data[] = "('$dt')"; } $db->exec("INSERT INTO production_status (submit_time) VALUES " . join(',', $data)); ## ## Now the bit you need ## $start_date = date('Y-m-d', strtotime('first day of this month')); $res = $db->prepare("SELECT date_format(submit_time, '%a %d-%b-%y') as date , COUNT(*) as total FROM production_status WHERE date(submit_time) >= ? GROUP BY date ORDER BY submit_time "); $res->execute([ $start_date ]); RESULTS +---------------+-------+ | date | total | +---------------+-------+ | Tue 01-Sep-20 | 14 | | Wed 02-Sep-20 | 24 | | Thu 03-Sep-20 | 15 | | Fri 04-Sep-20 | 21 | | Sat 05-Sep-20 | 15 | | Sun 06-Sep-20 | 24 | | Mon 07-Sep-20 | 17 | | Tue 08-Sep-20 | 17 | | Wed 09-Sep-20 | 15 | | Thu 10-Sep-20 | 11 | | Fri 11-Sep-20 | 15 | | Sat 12-Sep-20 | 16 | | Sun 13-Sep-20 | 13 | | Mon 14-Sep-20 | 11 | | Tue 15-Sep-20 | 21 | | Wed 16-Sep-20 | 21 | | Thu 17-Sep-20 | 15 | | Fri 18-Sep-20 | 17 | | Sat 19-Sep-20 | 17 | | Sun 20-Sep-20 | 14 | +---------------+-------+
  4. If you are starting with this (which could be the result from a table subquery) ... +----+----------------------+------------+-----------------+----------+ | id | disciplina | moduloUfcd | idcpDisciplinas | anoTurma | +----+----------------------+------------+-----------------+----------+ | 58 | Comunicação Visual | 8599 | 49 | 11 | | 59 | Comunicação Visual | 133 | 49 | 11 | | 60 | Comunicação Visual | 134 | 49 | 10 | +----+----------------------+------------+-----------------+----------+ then this query ... SELECT group_concat(id separator ', ') as ids , disciplina , group_concat(moduloUfcd separator ', ') as mods , idcpDisciplinas , anoTurma FROM gmc GROUP BY idcpDisciplinas, anoTurma; gives ... +--------+----------------------+-----------+-----------------+----------+ | ids | disciplina | mods | idcpDisciplinas | anoTurma | +--------+----------------------+-----------+-----------------+----------+ | 60 | Comunicação Visual | 134 | 49 | 10 | | 58, 59 | Comunicação Visual | 8599, 133 | 49 | 11 | +--------+----------------------+-----------+-----------------+----------+
  5. Also note that the above code does not put the lastname into the $result variable.
  6. Seems to me that the best approach would be to fix the problem instead of disabling the warning.
  7. 1 ) You don't need the mysql_real_escape_string. That is for strings (the clue is in the name). $cat_id is an int. 2 ) The mysql_xxxx functions are obsolete. If you ever get around to upgrading you version of PHP to someting less than 5 years old, they won't work. Switch to using PDO class.
  8. Not knowing what data you have, I'm going to guess that is correct. Now do the same in your php code.
  9. If $cat_id contains "" then the query will fail with a syntax error. But we don't know what's in it, nor do we know what's in your table - and we certainly have no idea what "don't work" means unless you tell us. Check if your query gave an error message.
  10. You do it in the same way you have in your get_post($pid) function, only this time pass the category id get_posts($cat_id)
  11. You can't put functions inside strings like variables. <?php $x = date('Y'); $y = 1989; $description = "In this classic lecture which was delivered over " . ($x - $y) . " years ago, etc etc....."; echo $description; // ==> In this classic lecture which was delivered over 31 years ago, etc etc..... ?>
  12. Have you tried putting a WHERE clause in your query, for example WHERE blog.cat_id = 4
×
×
  • 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.