Sponsored Content
Top Forums Web Development Notes with Ravinder on Badging System Development Part II Post 303028189 by Neo on Tuesday 1st of January 2019 12:42:18 PM
Old 01-01-2019
Hey Ravinder,

Your fancy query is broken... even I I put xxxxx as the field in the query, I get the same wrong answer:

Code:
mysql> SELECT TIME_TO_SEC(TIMEDIFF(NOW(), FROM_UNIXTIME('xxxxx')))/(3600*24) AS 'join_time' FROM user WHERE userid =1;
+-----------+
| join_time |
+-----------+
|   34.9583 |
+-----------+
1 row in set, 2 warnings (0.00 sec)

Code:
mysql> SELECT TIME_TO_SEC(TIMEDIFF(NOW(), FROM_UNIXTIME('WHAT_THE_F')))/(3600*24) AS 'join_time' FROM user WHERE userid =1;
+-----------+
| join_time |
+-----------+
|   34.9583 |
+-----------+
1 row in set, 2 warnings (0.00 sec)

This is why I write SQL queries that a 12 year old can understand. LOL

Yours looks really clever, but is broken.

I kindly suggest you rewrite your query to perform the logic outside of the SQL query; but it is up to you. I will wait for your next attempt.

Thanks and good try!

PS: You might earn your Dev Ops Team Badge sooner than I thought .. Haha
 

3 More Discussions You Might Find Interesting

1. What is on Your Mind?

New Badging System - Badges Prototype Beta 1 (Badges Only)

Today I mapped out the new badging system using FA icons, Beta 1 in no particular order except a 6 x 8 grid: https://www.unix.com/members/1-albums215-picture991.png The prototype HTML code for this layout: <style> .fa-badge-grid { font-size: 1.5em; } .row { ... (38 Replies)
Discussion started by: Neo
38 Replies

2. What is on Your Mind?

Status of Badging System - Beta 1

Dear All, Here is the current status of the badging system: The Beta 1 phase of the new badging system is close to completion. 42 prototype badges have been "allocated" 6 prototype badge slots are held in reserve The "alert you have new badges" prototype is running and is currently... (4 Replies)
Discussion started by: Neo
4 Replies

3. What is on Your Mind?

Badging System: UNIX.COM Bug Hunter Badge (New)

I have moved the bug badge out of reserve and into the main stream. Basically, I will assign a color level like the others, based on who has made a good actionable bug report for UNIX.COM. "Good" means screenshots, links, and even details from web dev tools our the HTML source code. So far,... (0 Replies)
Discussion started by: Neo
0 Replies
MSSQL_RESULT(3) 														   MSSQL_RESULT(3)

mssql_result - Get result data

SYNOPSIS
string mssql_result (resource $result, int $row, mixed $field) DESCRIPTION
mssql_result(3) returns the contents of one cell from a MS SQL result set. PARAMETERS
o $result - The result resource that is being evaluated. This result comes from a call to mssql_query(3). o $row - The row number. o $field - Can be the field's offset, the field's name or the field's table dot field's name (tablename.fieldname). If the column name has been aliased ('select foo as bar from...'), it uses the alias instead of the column name. Note Specifying a numeric offset for the $field argument is much quicker than specifying a fieldname or tablename.fieldname argu- ment. RETURN VALUES
Returns the contents of the specified cell. EXAMPLES
Example #1 mssql_result(3) example <?php // Send a select query to MSSQL $query = mssql_query('SELECT [username] FROM [php].[dbo].[userlist]'); // Check if there were any records if (!mssql_num_rows($query)) { echo 'No records found'; } else { for ($i = 0; $i < mssql_num_rows($query); ++$i) { echo mssql_result($query, $i, 'username'), PHP_EOL; } } // Free the query result mssql_free_result($query); ?> The above example will output something similar to: Kalle Felipe Emil Ross Example #2 Faster alternative to above example <?php // Send a select query to MSSQL $query = mssql_query('SELECT [username] FROM [php].[dbo].[userlist]'); // Check if there were any records if (!mssql_num_rows($query)) { echo 'No records found'; } else { while ($row = mssql_fetch_array($query)) { echo $row['username'], PHP_EOL; } } // Free the query result mssql_free_result($query); ?> NOTES
Note When working on large result sets, you should consider using one of the functions that fetch an entire row (specified below). As these functions return the contents of multiple cells in one function call, they're MUCH quicker than mssql_result(3). SEE ALSO
Recommended high-performance alternatives: mssql_fetch_row(3), mssql_fetch_array(3), mssql_fetch_assoc(3), mssql_fetch_object(3). PHP Documentation Group MSSQL_RESULT(3)
All times are GMT -4. The time now is 01:55 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy