[Solved] How to SUM Datetime per column

AS some of your logstep_* columns value is NULL so try like this with ifnull, I’ve added only three columns you can try with all of your columns. Hope this will help you. select SEC_TO_TIME( UNIX_TIMESTAMP(ifnull(logstep_1, 0)) + UNIX_TIMESTAMP(ifnull(logstep_2, 0)) + UNIX_TIMESTAMP(ifnull(logstep_3, 0)) ) as logstep_sum_in_time from log_step 2 solved How to SUM Datetime per … Read more

[Solved] Gather column name of a table from database [closed]

http://php.net/manual/en/function.mysql-num-fields.php $result = mysql_query(“select * from table”); echo ‘<tr>’; for ($i = 0; $i < mysql_num_fields($result); $i++) { echo “<th>”.mysql_field_name($result, $i).”</th>”; } echo ‘</tr>’; 1 solved Gather column name of a table from database [closed]

[Solved] SQL Data models

for 1.2 you will need one more table which will hold task and items relation ship for example Table : Task_Item_Rel {TaskID,ItemID} whenver you want item related to a particular task simply have a query with joins between task,item and Task_Item_Rel solved SQL Data models

[Solved] Preventing duplicates in the database [closed]

I update your code. <?php mysql_connect(“localhost”, “root”, “”) or die(mysql_error()); mysql_select_db(“database”) or die(mysql_error()); ?> <html> <head> <title>Student list</title> <link href=”https://stackoverflow.com/questions/11200978/stylesheets/public.css” media=”all” rel=”stylesheet” type=”text/css”/> </head> <body id=”background”> <table > <tr> <td><img src=” images/Picture3.png” width=”1300″ height=”150″/></td> </tr> </table> <table> <tr> <td id=”structure”> <? // check for post data if( isset($_POST[‘name’]) && isset($_POST[’email’]) && isset($_POST[‘shift’]) && isset($_POST[‘class’]) && … Read more

[Solved] Creating a database to query

well, as stated in the comments, your question is very unspecific, but i – as a fan of php and mysql – would say that those are ONE good answer to create a website like that. you can get free software suites to help you with this endeavour, start experimenting on your home computer, learn … Read more

[Solved] Avoid data redundancy in a friends table

Add field friendship_key: ALTER TABLE t_friend ADD friendship_key decimal(22,11); CREATE UNIQUE INDEX friendship_key_unique ON t_friend (friendship_key); And php part: $friends = [$userId, $friendId]; $key = min($friends).’.’.max($friends); $q = “SELECT * FROM t_friend WHERE friendship_key = “.$key; insert: $friends = [$userId, $friendId]; $key = min($friends).’.’.max($friends); $q = “INSERT INTO t_friend (friendship_key, userId, friendId) VALUES (“.implode(‘,’, [$key, … Read more

[Solved] What can I do with the $db variable in mysql_select_db(“database”, $db); [closed]

$db is usually for database connection. It provides connection link to database, identifies the connection and provides database object. When you use mysql_* functions, you can define last parameter as connection variable. You use it to indentify connection, so multiple mysql connections don’t mix up. solved What can I do with the $db variable in … Read more

[Solved] Database Connection not working after migrating from PHP7.4 to PHP8.0

Looks like you’ve been relying on the ancient, long-deprecated behaviour that methods named the same as the class act as the constructor. This behaviour has finally been thrown out in PHP 8: Methods with the same name as the class are no longer interpreted as constructors. The __construct() method should be used instead. 0 solved … Read more

[Solved] Selecting distinct values from multiple column of a table with their count

Get all column values to one row and find the count SQL SERVER ;WITH CTE AS ( SELECT COL1 Name FROM YOURTABLE UNION ALL SELECT COL2 FROM YOURTABLE UNION ALL SELECT COL3 FROM YOURTABLE UNION ALL SELECT COL4 FROM YOURTABLE UNION ALL SELECT COL6 FROM YOURTABLE UNION ALL SELECT COL7 FROM YOURTABLE ) SELECT DISTINCT … Read more