-
Posts
24,429 -
Joined
-
Last visited
-
Days Won
807
Posts posted by Barand
-
-
I hadn't realised that you had already converted your finished column to the correct DATE type and format. Well done.
SELECT CASE WHEN FINISHED = 0 THEN '' ELSE DATE_FORMAT(FINISHED, '%d %M %Y') END as FINISHED FROM games
-
By default a dump (export) file is .sql.
But a .csv would be fine if you prefer to provide it that way
-
What does you FINISHED column contain if there is no finished date yet? (I am assuming a blank string)
Can you provide some sample data? (Dump of your 'games' table)
-
What does $row['FINISHED'] contain when you get that result?
EDIT And why didn't you just use strtotime() again?
$date = date('d F Y', strtotime($date))
-
You have a similar problem in your original code when the finished date is blank
echo date('d F Y', strtotime('')); //--> 01 January 1970
With STR_TO_DATE(), if the date string is blank you get 0000-00-00
mysql> select finished -> , str_to_date(finished, '%d-%m-%Y') -> from games; +------------+-----------------------------------+ | finished | str_to_date(finished, '%d-%m-%Y') | +------------+-----------------------------------+ | | 0000-00-00 | | 20-12-2019 | 2019-12-20 | +------------+-----------------------------------+
I recommend formatting the date in the query instead of in php EG
SELECT FINISHED , CASE WHEN FINISHED = '' THEN '' ELSE DATE_FORMAT(STR_TO_DATE(FINISHED, '%d-%m-%Y'), '%d %M %Y') END as DATE_FINISHED FROM games; +------------+------------------+ | FINISHED | DATE_FINISHED | +------------+------------------+ | | | | 20-12-2019 | 20 December 2019 | +------------+------------------+
Then in the php code , just output $row['DATE_FINISHED']
-
-
As for that '✔', store in your table as 1/0 for completed/not completed.
You convert to a '✔' on output, not on input.
-
You can use the sql function str_to_date() to convert your dates to the correct format.
In the mean time you can also use that in your query
SELECT GAME, YR, PLATFORM, PUBLISHER, STR_TO_DATE(FINISHED, '%d-%m-%Y') as FINISHED FROM games WHERE COMPLETED='✔' ORDER BY STR_TO_DATE(FINISHED, '%d-%m-%Y') DESC LIMIT 10
-
What format are you storing them in? You can get away with varchar so long as they are in" yyyy-mm-dd" format.
31 minutes ago, Revolutsio said:WHERE COMPLETED='✔'
Why the **** are you storing values as '✔' in your database?
-
I don't know if you are using PDO or MySqli, but whichever it is, use its error reporting functionality to find out why.
-
17 hours ago, Barand said:
Your data model should provide the teams and their players for any given date/fixture
EG
+---------------+ | school | +---------------+ | school_id |---+ | name | | +--------------+ +---------------+ | | team | +---------------+ | +--------------+ | player | | | team_id |--+ +---------------+ | | team_name | | +---| player_id | +---<| school_id | | | | name | | sport_id | | | | height | +--------------+ | | | weight | | | | email | | | | dob | | | +---------------+ | +-----------------+ | | | team_player | | | +-----------------+ | | | id | | +---<| team_id | | | position | | | player_id |>--+ | played_from | | played_until | +-----------------+
-
Forget the json then.
This should give you the first 5 records in the format your C# is currently expecting
$res = $conn->query("SELECT username , level , points , killrate FROM atable ORDER BY points DESC LIMIT 5; "); $data = []; foreach ($res as $row) { $data[] = join('|', $row); } echo join('/', $data);
-
$res = $conn->query("SELECT username , level , points , killrate FROM atable LIMIT 5; "); $data = $res->fetchAll(); echo json_encode($data);
That doesn't look like much of a hassle.
-
It occurred to me that it might be easier to
- query for the first 5 records
- fetchAll() on the result set
- json encode the array of results
then echo the json string.
In C#, convert the json back to an array and process.
-
Very confusing.
- You say you have 2 entries in the database.
- Then you say you want the top five entries in the database.
- Your php code only echoes one entry
Not surprised you're having problems.
10 minutes ago, J450n said:Is there any other way of getting PHP form data into C#
Don't know. This is a PHP forum.
-
So you're getting the file names, getting the creation dates for those files, storing in an array then sorting the array by date - yes?
-
29 minutes ago, Jim R said:
Can we please just focus on the date stamps and seasons
I thought that was settled. The timestamp in the notes contains the date. The from and to dates in the season table tell you the season. Job done.
-
Then for the note table I'd suggest...
- note_id
- Timestamp
- Comment (1st line from above examples)
- home_team_id
- away_team_id
-
6 minutes ago, Jim R said:
I'm not drawing from my own games/fixture table
If that's the case, how do you get from
team = 46
to
DeAndre Davis, 6'6" senior guard; Nijel Pack, 5'11" senior guard; DeAnte Davis, 6'6" sophomore forward
-
Looks like all your note table should have is
- note_id
- Timestamp
- Comment (1st line from above examples)
- fixture_id
Your data model should provide the teams and their players for any given date/fixture
-
Are you making notes other than the player notes?
(Remember, there is only you who knows what you are trying to achieve, what your process are and what your data looks like)
-
Are you talking about making notes about players during a game?
- id
- PlayerID
- TeamID
- Timestamp
- Comments
-
Just a guess, but do you have several objects with same id (#userDeleteConfirmationModal)?
-
I would need to review your model before committing.
To me, a "player" table would contain player attributes such as PlayerID, Name | Address | Phone | Dob | etc.
Code not working
in PHP Coding Help
Posted