-
Posts
24,566 -
Joined
-
Last visited
-
Days Won
822
Everything posted by Barand
-
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. 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?
-
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
-
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.
-
I would datestamp the note records rather than store the season code. At least you then know exactly when you made the note. Have a "season" table to define the seasons Season From To 18-19 | 2018-11-01 | 2019-03-31 19-20 | 2019-11-01 | 2020-03-31 Then if you want this season's notes SELECT note_date , note FROM note n JOIN season s ON n.note_date BETWEEN s.From and s.To WHERE CURDATE() between s.From and s.To ORDER BY note_date
-
Split string into new lines at comma -> update text
Barand replied to Adamhumbug's topic in Javascript Help
try the html attribute instead of the text attribute modal.find('#active-sheets').html(activesheets) -
Split string into new lines at comma -> update text
Barand replied to Adamhumbug's topic in Javascript Help
What is the object whose id = active-sheets? -
Escape the quotes. IF(Media='Physical', '<img src=\"Images/floppy.png\">', Media) as Media
-
if you want to do it in the query (as you have above) then something like SELECT IF(Media='Physical', '<img src="images/floppy.png">', Media) as Media
-
Split string into new lines at comma -> update text
Barand replied to Adamhumbug's topic in Javascript Help
You need "<br>" for newlines in an html document ("\n" and multiple spaces are ignored unless between <pre>..</pre> tags or in a <textarea>) -
Outputting MySql data that contains ' into php variables
Barand replied to Adamhumbug's topic in PHP Coding Help
It certainly doesn't live up to its name. -
Outputting MySql data that contains ' into php variables
Barand replied to Adamhumbug's topic in PHP Coding Help
I just pasted the code you posted into my editor. As you can see from the green text, everything following is considered part of the TEXT string It should look like this -
Outputting MySql data that contains ' into php variables
Barand replied to Adamhumbug's topic in PHP Coding Help
It could be that the real cause is higher up in the code but isn't being noticed until the reported line. Post the code from your <<<TEXT to the error line. -
Outputting MySql data that contains ' into php variables
Barand replied to Adamhumbug's topic in PHP Coding Help
Strange!. Line 132 doesn't give a problem for me. However, I would write it differently, removing the concatenation by using {..}s around the array variables echo "<option value='{$row['role_id']}'>{$row['role_name']}</option>"; Alternatively, as constants are not permitted within a string, the single quotes around the keys can be omitted echo "<option value='$row[role_id]'>$row[role_name]</option>"; That one doesn't need preparing - query() is fine. No parameters. -
By default the separator is just a comma. IMHO it's more readable if you use GROUP_CONCAT(job_eventname SEPARATOR ', ') as eventname
-
Outputting MySql data that contains ' into php variables
Barand replied to Adamhumbug's topic in PHP Coding Help
One of things I really liked about PHP, having previously used VB (ugh!) was the ability to directly embed variables into strings without all the confusing quoting and concatenating. Coupled with the ability to use HEREDOC syntax life became much easier when confronted with strings like this one. I would suggest... echo <<<TEXT <td><a class="btn btn-primary col-sm-12" data-toggle="modal" data-userid="$uid" href="#userModal" data-firstname="$ufn" data-lastname="$uln" data-email="$ue" data-accountlevel="$ualid" data-mobile="$um" data-role="$urid" data-active-sheets="$ename">Manage</a></td> TEXT; Alternatively, go for a string inside "...." and with single quotes around attribute values, BUT, where you have an attribute value that could contain a single quote character or apostrophe, use escaped double quotes. EG echo "<td><a class='btn btn-primary col-sm-12' data-toggle='modal' data-userid='$uid' href='#userModal' data-firstname=\"$ufn\" data-lastname=\"$uln\" data-email='$ue' data-accountlevel='$ualid' data-mobile='$um' data-role='$urid' data-active-sheets=\"$ename\">Manage</a></td>"; -
Selecting array elements based on an index range
Barand replied to NotionCommotion's topic in PHP Coding Help
One way ... $list=[ 12314=>'OBJ1', 321=>'OBJ2', 42142=>'OBJ3', 14314=>'OBJ4', 123=>'OBJ5', 13314=>'OBJ6' ]; function getIt($list, $min, $max) { $arr = array_filter($list, function ($k) use ($min,$max) { return $k >= $min && $k <= $max; }, ARRAY_FILTER_USE_KEY); krsort($arr); return current($arr); } echo getIt($list, 10000, 15000); // OBJ4 echo getIt($list, 15000, 20000); // false -
InnoDB has many advantages over MyIsam. The time MyIsam comes out top is when you have lots of data retrieval from large databases; then it's faster.