Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation since 01/21/2025 in all areas

  1. the file system path/filename must be to where the file is located on the disk, either using a relative path (relative to the file with the include/require starting in it) or an absolute path. a leading / refers to the root of the current disk, which is doubtful where that file is located, and which will be producing a php error about a non-existent path/file. you must get php to help you by reporting and displaying all the errors it detects. you can temporarily set php's error_reporting/display_errors in your code (you will want to remove the settings when you are done learning, developing, and debugging). you can add the following immediately after the first opening <?php tag in the main file - ini_set('display_errors', '1'); error_reporting(-1);
    2 points
  2. I'd do something like this... <?php $data = [ '46.105.73.18:27015' => [ 'gq_address' => '46.105.73.18', 'gq_dedicated' => '', 'gq_gametype' => '', 'gq_hostname' => '', 'gq_joinlink' => 'steam://connect/46.105.73.18:27015/' , 'gq_mapname' => '', 'gq_maxplayers' => '', 'gq_mod' => '', 'gq_name' => 'Counter-Strike: Source' , 'gq_numplayers' => '', 'gq_online' => '', 'gq_password' => '', 'gq_port_client' => 27015 , 'gq_port_query' => 27015 , 'gq_protocol' => 'source' , 'gq_transport' => 'udp' , 'gq_type' => 'css' , 'players' => Array (), 'teams' => Array () ] ] ; $tdata = ''; foreach ($data as $k => $v) { $v = array_filter($v); // get rid of blank values $tdata .= "<table border='1'> <tr><th>Array key</th><th>" . join('</th><th>', array_keys($v)) . "</th></tr>\n"; // output headings $tdata .= "<tr><th class='rowth'>$k</th><td>" . join('</td><td>', array_values($v)) . "</td></tr> // output values </table>\n"; } ?> <html lang='en'> <head> <meta 'charset'='utf-8'> <title>Example</title> <style type='text/css'> table { border-collapse: collapse; margin-bottom: 10px; } th { background-color: #444; color: white; padding: 8px; } .rowth { background-color: #888; } td { padding: 8px; text-align: center; } </style> </head> <body> <?= $tdata ?> </body> </html> Giving ...
    2 points
  3. First step to manually parsing HTML is to stop manually parsing HTML. Use DOM instead.
    2 points
  4. After about 3 hours of waiting I killed the process as the SQL server never showed a status other than "idle". I think it hit a problem and got itself into an infinite loop doing nothing. To give myself some data to work with, I managed to extact the table structure , the first 3,400 and the last 600 records from the sql file. I could have done all of them but it (thankfully) uses multiple row inserts (1700 at a time) and it takes an age scrolling through the text to find each block's start and end then select the block. There are about 200 such blocks and each takes about 2.5 seconds to load the data - so the whole load should have taken 8-9 minutes. Enough of the excuses. I finally came up with a solution using the post table. The first part (WITH ...) creates a temporary table called "plast" which contains a row for each threadID with the latest date of all the posts for the thread. The main part of the query (SELECT ...) matches the threadid/latest date with the post table to find the matching post and also joins to the thread table to pick uo thread info. Finally, I limit the output to just those dates in the last 7 days. (Apologies for screwing up the text encoding along the way - eg "Jürgen Peters". It's only test data.) WITH plast AS ( SELECT threadID , MAX(time) as latest FROM wbb1_1_post GROUP BY threadID ) SELECT t.threadID , t.topic , p.userID , p.username , p.postid , FROM_UNIXTIME(p.time) AS time , FROM_UNIXTIME(plast.latest) AS latest FROM wbb1_1_post p JOIN wbb1_1_thread t ON p.threadID = t.threadID JOIN plast ON plast.threadid = p.threadid AND plast.latest = p.time WHERE FROM_UNIXTIME(p.time) > CURDATE() - INTERVAL 7 DAY ; +----------+----------------------------------------------------------------+--------+------------------+--------+---------------------+---------------------+ | threadID | topic | userID | username | postid | time | latest | +----------+----------------------------------------------------------------+--------+------------------+--------+---------------------+---------------------+ | 131549 | welche Spinne? --> eventuell Lepthyphantes sp. | 5455 | Manfred Zapf | 507256 | 2025-01-26 10:08:19 | 2025-01-26 10:08:19 | | 131698 | Baumwanze | 1397 | zobel | 507259 | 2025-01-26 12:48:43 | 2025-01-26 12:48:43 | | 56659 | Grüne Futterwanze? | 15196 | Christine | 507261 | 2025-01-26 14:57:09 | 2025-01-26 14:57:09 | | 131576 | Kleine schwarze Spinne --> Enoplognatha cf. thoracica | 15395 | Bernd 07 | 507263 | 2025-01-26 16:01:45 | 2025-01-26 16:01:45 | | 131307 | Amaurobius fenestralis? --> bestätigt | 15395 | Bernd 07 | 507264 | 2025-01-26 16:08:09 | 2025-01-26 16:08:09 | | 131701 | Unbekannte Schneckenart | 15395 | Bernd 07 | 507267 | 2025-01-26 16:43:50 | 2025-01-26 16:43:50 | | 131702 | Encyrtidae? | 11406 | JohnEs81 | 507268 | 2025-01-26 17:00:37 | 2025-01-26 17:00:37 | | 131700 | Welche Wanze ist das? --> Arocatus longiceps | 15395 | Bernd 07 | 507272 | 2025-01-26 17:36:02 | 2025-01-26 17:36:02 | | 131699 | Tegenaria --> nein sondern Amaurobius similis/fenestralis | 1999 | Klaus Fritz | 507274 | 2025-01-26 17:48:07 | 2025-01-26 17:48:07 | | 131683 | Grüne Larve -> Geometridae Art | 11406 | JohnEs81 | 507280 | 2025-01-26 20:41:49 | 2025-01-26 20:41:49 | | 131703 | eine Acericerus heydenii? | 1 | Jürgen Peters | 507282 | 2025-01-26 20:45:32 | 2025-01-26 20:45:32 | | 131687 | Zygina nivea? | 15392 | Sascha_N | 507286 | 2025-01-26 21:15:21 | 2025-01-26 21:15:21 | | 131686 | Welcher Schnellkäfer? --> Melanotus sp. | 15395 | Bernd 07 | 507287 | 2025-01-26 21:29:11 | 2025-01-26 21:29:11 | | 131693 | Lispocephala brachialis --> bestätigt | 15800 | Bernd Cogel | 507293 | 2025-01-26 22:06:16 | 2025-01-26 22:06:16 | | 131704 | Cantharis paradoxa? --> Cantharis sp., ein schwarzer, immerhin | 15335 | Simeon Indzhov | 507295 | 2025-01-26 22:29:15 | 2025-01-26 22:29:15 | | 131695 | Peyerimhoffina gracilis? | 15335 | Simeon Indzhov | 507296 | 2025-01-26 22:36:08 | 2025-01-26 22:36:08 | | 131705 | Phytoecia coerulescens? | 1 | Jürgen Peters | 507297 | 2025-01-26 22:52:48 | 2025-01-26 22:52:48 | +----------+----------------------------------------------------------------+--------+------------------+--------+---------------------+---------------------+ Are you planning on rebuilding the database?
    2 points
  5. /homepages/29/d1007800584/htdocs is your site root - this is set by your host at the server level. If site-header.php and tester-include.php are both in the /page/ directory, the include from tester-include.php should be simply `require_once('./site-header.php');` If that still doesn't work, try `require_once(dirname(__FILE__).'/site-header.php');` (if site-header.php is in a sub-directory called /root/, add that into the require). As an aside, your host should be on php 8.1 at the least - 7.4 reached end of life in November 2022. You may want to ask them why they haven't upgraded yet. If they can't give you a decent answer, there are plenty of low-cost modern hosts around - ask here. Someone can point you in the right direction.
    1 point
  6. From the looks of it, you are simply unclear on how PHP arrays work, and the syntax involved. PHP arrays are highly versatile, in that they combine what in many other languages, requires multiple different data structure types. It is a combination of an Array, a List and a Map, if we were going back to the standard library of C++. Maps are probably the most interesting, in that a map is a structure that has a 'key' = 'value' association. This is different from an array, which is simply a data structure of 1-N elements, indexed numerically. In c and c++ arrays are limited to a data type. Due to strict typing requirements in c and c++ (and other similar "strongly typed") languages, you are constrained in how you assemble, add to and modify an array, but PHP is extremely flexible in essentially letting you store data type or object as a value in an array, and allowing you to nest arrays within arrays any way that suits you. In your example, you presented a series of nested arrays, some being traditionally numeric, and others containing one or more "key/value" elements. The curious thing is that the array you presented is invalid. Notice that your syrup values are missing the => required to define a key/value element. $arr = [ 0 => ["meds" => [ "IV" => 1, "pill" => 2, "syrup" = 3] ], 1 => ["meds" => [ "IV" => 2, "pill" => 4, "syrup" = 6] ], 2 => ["meds" => [ "IV" => 5, "pill" => 5, "syrup" = 5] ] ]; I fixed that for the following example code. Rather than defining this in one shot, consider how you could start with an empty array and arrive at the same structure. <?php function printArr($a, $name='') { echo "$name --------------------------\n\n"; print_r($a); echo PHP_EOL; } $arr = [ 0 => ["meds" => [ "IV" => 1, "pill" => 2, "syrup" => 3] ], 1 => ["meds" => [ "IV" => 2, "pill" => 4, "syrup" => 6] ], 2 => ["meds" => [ "IV" => 5, "pill" => 5, "syrup" => 5] ] ]; printArr($arr, 'Original Array'); // Empty $arr2 = []; printArr($arr2, 'Rebuilt Array'); $arr2[0] = []; printArr($arr2); $arr2[0]['meds'] = []; printArr($arr2); $arr2[0]['meds']['IV'] = 1; printArr($arr2); $arr2[0]['meds']['pill'] = 2; printArr($arr2); $arr2[0]['meds']['syrup'] = 3; printArr($arr2); // Add a new empty array to 1st dimenion of array. This will become $arr2[1] $arr2[] = []; printArr($arr2, '1st Dimension, new index 1. Arrays are zero based'); // Assign value to be new array with key "meds" having a value of an empty array. $arr2[1]['meds'] = []; printArr($arr2); // Set the value of this nested array element to be a nested array $arr2[1]['meds'] = [ "IV" => 2, "pill" => 4, "syrup" => 6]; printArr($arr2); //Set entire element 3 structure in one assignment $arr2[] = ['meds' => [ "IV" => 5, "pill" => 5, "syrup" => 5]]; printArr($arr2, 'Array complete'); echo "Comparisons ---------------------\n"; echo $arr[0]['meds']['pill'] . PHP_EOL; echo $arr2[0]['meds']['pill'] . PHP_EOL; echo "\n\n"; foreach($arr[2]['meds'] as $nestedKey => $nestedVal) { echo "$nestedKey = $nestedVal\n"; } echo "\n\n"; foreach($arr2[2]['meds'] as $nestedKey => $nestedVal) { echo "$nestedKey = $nestedVal\n"; } The Results: Original Array -------------------------- Array ( [0] => Array ( [meds] => Array ( [IV] => 1 [pill] => 2 [syrup] => 3 ) ) [1] => Array ( [meds] => Array ( [IV] => 2 [pill] => 4 [syrup] => 6 ) ) [2] => Array ( [meds] => Array ( [IV] => 5 [pill] => 5 [syrup] => 5 ) ) ) Rebuilt Array -------------------------- Array ( ) -------------------------- Array ( [0] => Array ( ) ) -------------------------- Array ( [0] => Array ( [meds] => Array ( ) ) ) -------------------------- Array ( [0] => Array ( [meds] => Array ( [IV] => 1 ) ) ) -------------------------- Array ( [0] => Array ( [meds] => Array ( [IV] => 1 [pill] => 2 ) ) ) -------------------------- Array ( [0] => Array ( [meds] => Array ( [IV] => 1 [pill] => 2 [syrup] => 3 ) ) ) 1st Dimension, new index 1. Arrays are zero based -------------------------- Array ( [0] => Array ( [meds] => Array ( [IV] => 1 [pill] => 2 [syrup] => 3 ) ) [1] => Array ( ) ) -------------------------- Array ( [0] => Array ( [meds] => Array ( [IV] => 1 [pill] => 2 [syrup] => 3 ) ) [1] => Array ( [meds] => Array ( ) ) ) -------------------------- Array ( [0] => Array ( [meds] => Array ( [IV] => 1 [pill] => 2 [syrup] => 3 ) ) [1] => Array ( [meds] => Array ( [IV] => 2 [pill] => 4 [syrup] => 6 ) ) ) Array complete -------------------------- Array ( [0] => Array ( [meds] => Array ( [IV] => 1 [pill] => 2 [syrup] => 3 ) ) [1] => Array ( [meds] => Array ( [IV] => 2 [pill] => 4 [syrup] => 6 ) ) [2] => Array ( [meds] => Array ( [IV] => 5 [pill] => 5 [syrup] => 5 ) ) ) Comparisons --------------------- 2 2 IV = 5 pill = 5 syrup = 5 IV = 5 pill = 5 syrup = 5 If you can look at these results and understand them, you'll have a better idea of how to reference any element in a nested array directly. You can also reference any dimension, going from left to right, where the first Dimension (array) will be $r[], the 2nd dimension $r[][] and so on, for as many nested dimensions as you might have.
    1 point
  7. First an editorial comment: Please do not take screen shots of code for your questions. We can't use that in our replies or help. We have a code block for a reason. You can easily copy/paste snippets of relative code into the code block, and that makes it possible for us to make edits based on the original code. Nobody here likes having to re-type parts of your code. Paths in your html are relative to the document root. The document root is a function of the web server configuration for the server or vhost you have configured. The types of things you can refer to in an html script are only things that the server understands to have an associated URL. In other words, they are things that you could use a url to access directly from your website. PHP works entirely with files, and file system paths on your workstation. Using PHP code to open include/require files always requires a file system path. When you include a file, the "working directory" for PHP is the path/location in the server file system where the script exists. So to include a php script from another php script you have 2 options: Provide the fully qualified path to the script. Because this path is operating system dependent, you typically don't want to do this as it requires you to add configuration in a file or even edit your source code purely because you moved servers. A Relative Path This is relative, again to the directory where the script that is including this code is. Relative paths can utilize 2 "special files": "." is the current directory. ".." is the parent directory. We don't know what the file system layout is for your project, so we can only guess at the correct path relative to the index.php? or whatever file it is that you are trying to do this php include in is named. If this directory has a sub-directory named "page" and you have put the site-header.php script into that directory, then the relative path you want to use will be: include("page/site-header.php"); This is how you specify a subdirectory path relatively. If you include a leading "/" that is considered the "root" directory of the filesystem. One other thing you might want to do is change include to require_once(). With a require_once() the script will actually error out rather than continue to run along without regard to the fact that your include failed.
    1 point
  8. It doesn't sound like you are looking ahead into other rooms, just looking at the stock levels of all the supplies in the current room. Ex: foreach ($roomList as $room){ $ivStockLow = $room['meds']['IV'] < 2; $pillStockLow = $room['meds']['pill'] < 4; $syrupStockLow = $room['meds']['syrup'] < 8; $ivOrder = max(0,2-$room['meds']['IV']); $pillOrder = max(0,4-$room['meds']['pill']); $syrupOrder = max(0,8-$room['meds']['syrup']); if ($pillStockLow){ $ivOrder=10; } else if ($syrupStockLow){ $pillOrder=10; } } Determine whether each item is low first, then use that information to adjust the order amount later on. Add in whatever constraints you need for budget as well.
    1 point
  9. only checked checkboxes are set in the submitted form data. for what you are doing, you should only be concerned if they are set or are not set, not what the value is (the default value will be the text 'on'). i recommend that make an array that defines the checkbox field names and labels, then loop over this defining array to dynamically produce the form fields, pre-checking any existing checked boxes, in the case of a user/validation error, then loop over this defining array in the post method form processing code, testing which one(s) are set or are not set in the form data to produce whatever result you want.
    1 point
  10. the attached code displays the menu, but has nothing to do with adding items to an order (cart), entering the customer information, or submitting/saving that information as an order. some points about the posted code, most of which will greatly simplify it (eliminating more than half of the typing) - use 'require' for things your code must have. don't prepare and execute a query that doesn't have any dynamic value being supplied to it. just use the ->query() method. the settings don't need elseif() logic, just if(), because the option_name can only be one value at any time. Don't Repeat Yourself (DRY.) there are only a few small things different between the corresponding if/else code blocks. the conditional logic should only setup the values for the different things in variables, then simply output them in one instance of the code. don't run queries inside of loops. use a single LEFT JOIN query to get the menu categories and menu items all at once. when you fetch the data, index/pivot it using the category id as the main array index. you can then simply loop over the data using two nested foreach(){} loops to produce the output. don't create unused variables/code. when embedding a php echo statement in html markup, use php's short-open-echo tag <?= and you can leave out the closing ; right before a closing ?> tag, for example - <?=$source?> SELECT queries that can return more than one row need an ORDER BY ... term to insure that the rows are in an expected order.
    1 point
  11. here's an example for the fields you have shown in this thread - <?php // define the fields // you would add other things to this definition, such as validation rules and processing rules $fields["it_c"] = ['label'=>'Whatever it_c is','type'=>'numeric']; $fields["it_h"] = ['label'=>'Whatever it_h is','type'=>'numeric']; $fields["ot_c"] = ['label'=>'Whatever ot_c is','type'=>'numeric']; $fields["ot_h"] = ['label'=>'Whatever ot_h is','type'=>'numeric']; // add entires for all the form fields... // examine the submitted data echo '<pre>'; print_r($_POST); echo '</pre>'; ?> <?php // produce the form ?> <form method='post'> <input type='submit'><br> <?php foreach($fields as $field=>$arr) { switch($arr['type']) { case 'numeric': echo "<label>{$arr['label']}: <input name='$field' type='text' class='numeric'></label><br>"; break; // code for other types... } } ?> <input type='submit'> </form>
    1 point
  12. Hi jtorral, I think that, based upon your posted four-point problem, responsive css is a better method than trying to use php to respond to media sizes. https://developer.mozilla.org/en-US/docs/Web/HTML/Responsive_images media queries can also help for images or overall css adjustments for "other functions on the page like resizing pop up boxes and so on" https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_media_queries/Using_media_queries when you veer away from JavaScript driven pop-up dialogs and move to css modal methods, the above methods will save you alot of hassle, such as trying to post to an included php file and expecting it to receive the post. Have a look at the css and try that method instead. The session should be used to maintain state, which includes databases by storing a user id for repeated querying. You could post CSS questions in the CSS Help forum: https://forums.phpfreaks.com/forum/17-css-help/ And have a second look at what Gizmola posted, John
    1 point
  13. Basically what is being described to you is a race condition. You aren't going to be able to hack around it. A PHP script runs on the server, and has "page/request" scope. The client provide an HTTP request, and the server provides an HTTP response, and the connection is closed. Ajax is used to make changes to the state of a fully rendered DOM on the client. You are not going to be able to trick PHP into doing some of its work -- delaying while the client's DOM is in a partial/indeterminate state, in order for ajax to spawn another request, and then have the original PHP script resume in the way you hope it will, all so that you can get access to session variables that didn't even exist when the original HTTP request was made. I have no idea why you are trying to store some client state in a session, given that browser dimensions are dynamic, relative to the device and decisions made by the client. It's not clear what you expect to do with these dimensions, which you're getting from javascript code, but you certainly don't need to put them into a session, and you haven't made an attempt to explain what problem you are trying to solve, but this is not the way to solve whatever problem that is. If you want to actually take the time to explain the "problem to be solved" we might be able to better advise you on ways to solve it.
    1 point
  14. this doesn't exist at the point when the ajax request is made, because they are two different http(s) requests. that's because ALL the code in index.php has already been executed during the initial http(s) request for index.php, by the time the ajax request occurs. for the initial case when the session variable doesn't exist, after you output the javascript code, the php code needs to exit/die without doing anything else (it currently runs to completion.) the ajax request needs to be to index.php, instead of screenDetect.php. the code will then set the session variable and it will be available when the rest of the code in index.php runs.
    1 point
  15. I fell foul of that this morning. It worked fine yesterday when I posted the query but when I loaded some more data and ran it again after midnight I got nothing. The last date I had was 2025-01-26 so -7 DAY worked fine on the 2nd Feb but not on the 3rd. On the subject of temporary tables, have a look at WITH RECURSIVE. There may be occasions when you want to list, say, total sales for each day last month and show a zero total for days with no sales. You can't just sum, grouping by the dates, as you won't get output if there is no data fora date. You need a table containing all the dates in the month and use a left join. WITH RECURSIVE gives a great way of create such a temporary date table on the fly.
    1 point
  16. Could be there is no data in the table for the last 7 days. Try "- INTERVAL 1 MONTH"
    1 point
  17. You don't need a separate table to specify the structure, your board table already contains the structure by virtue of the parentid column. Just needs a recursive function to resolve... include 'db_inc.php' ; $pdo = mdbConnect('jodunno'); // connect to database $res = $pdo->query("SELECT parentID, boardID, title FROM wbb1_1_board ORDER BY parentID, title"); $brds = []; foreach ($res as $r) { $brds[$r['parentID']][] = [ 'id' => $r['boardID'], 'title' => $r['title']]; } // echo '<pre>' . print_r($brds, 1) . '</pre>'; echo "<ul>\n"; outputBoard($brds, 0); echo "</ul>\n"; function outputBoard(&$brds, $parent) { foreach ($brds[$parent] as $b) { echo "<li>{$b['title']}</li>\n"; if (isset($brds[$b['id']])) { // if this is a parent board echo "<ul>\n"; outputBoard($brds, $b['id']); // recursively output the child boards echo "</ul>\n"; } } }
    1 point
  18. Thank you. You should know that i have a text file of data that you have posted. I always appreciate the wisdom from the top talent here at phpfreaks. I have learned alot from this forum and its top members. I give credit where credit is due. I actually learned how this JOIN is working and i have successfully implemented my own query on the db last night before bed. I'll post the code in a reply to Barry. My point is that i learn from Barry and not simply take code and be on my way. I'm not looking for a free ride, only help when something is above my current level of knowledge. I hope that you have a splendid day, Gizmola.
    1 point
  19. I'm sure he does know that, and we are both motivated by an interest in mentoring and passing along our expertise to people like yourself if we are able. We appreciate the feedback.
    1 point
  20. i recommend giving the fields a class name. you can then eliminate the array and just use getElementsByClassName to get a collection of the elements to loop over. see if this gets you closer to what you want - <html> <head> </head> <body> <script> function hasNumericValue() { const matches = document.getElementsByClassName("numeric"); for (let i = 0; i < matches.length; i++) { alert(Number.parseInt(matches[i].value)); } } </script> <form name="tester" method="post" action="" onsubmit="return hasNumericValue();" > <input name="it_c" type="text" class='numeric' value=""> <br> <input name="it_h" type="text" class='numeric' value=""> <br> <input name="ot_c" type="text" class='numeric' value=""> <br> <input name="ot_h" type="text" class='numeric' value=""> <br> <input type="submit" value="submit"> </form> </body> </html> you can then test if each value is or is not a number.
    1 point
  21. Hi Gizmola, very helpful post. I've read about this topic for quite some time today and it is very fascinating to me. I should've explored sql many years ago but atleast i'm trying to catch up now. I have learned alot from Barand but i never implemented it with my own code to gain experience. I am learning alot today and your notes are also very helpful. I see how it is working now and it is quite clever 🙂 Thank you for taking time to educate me on this subject. I appreciate your expertise. I appreciate Barand's expertise always, although he may not know it. I hope that you have a pleasant evening and i'll keep experimenting with this concept to gain more experience with it.
    1 point
  22. Yes this is common practice. When you first introduce a table you can alias it. You are then free to alias all the columns which can be quite a time saver when you have joined tables together, using "alias.column_name" as Barand did. You can do this explicitly using the 'AS' keyword but you can also omit the 'AS'. It's up to you, but I typically will abbreviate the name in some way, as do most experienced developers, such that your alias is at most a few letters. You should also notice, that he used an alias for the computed columns. Column names can also be aliased, and it's also a common practice. FROM_UNIXTIME(t.time) AS time So in this case you have an example of both alias options being used: thread table was aliased to t Used the t alias to specify the time thread.time field being passed to the FROM_UNIXTIME() SQL function the result of the function being aliased to the name 'time' in the final result set Also time was used in the order by. MySQL allows you to do this (use an aliased column name in an ORDER BY) although not all RDBMS do.
    1 point
  23. Barry is truly a master of relational database design, implementation and SQL. However , at least initially, a small investment on your part in learning how to join tables together, will dramatically improve your understanding of his analysis and the SELECT statement he provided you. I browsed this material and it's a solid free tutorial on Joins using MySQL. https://www.mysqltutorial.org/mysql-basics/mysql-join/ You may see references to ANSI standard SQL, which is a standard for portable SQL syntax that should be compatible with most relational databases, but I did want to mention that different databases will have features that are specific to their implementation (non-standard), so you might see that in the case of joins there is more than one syntax possible, but they all do the same things. Don't let that confuse you -- JOINS are an essential concept that all relational databases implement. If you have an option, and can use ANSI standard syntax, opt for that, but it really doesn't matter that much, so long as you are clear on what the join produces. A basic understanding of Set theory might give you some insight into the ideas that went into relational database management (union, intersection, difference, subset) might help as well. This article cover the topic pretty well, and you may notice some of the overlap in concept and terminology: https://kyleshevlin.com/set-theory/ It's also worth learning how to read an Entity-Relationship-Diagram (ERD). Once you understand the fundamentals, you should be able to look at an ERD and understand how tables can be joined together. There are also many tools that people use to design or reverse engineer databases. For example, mysql provides ERD design features in their free SQL Workbench tool. ERD's are the way that people socialize a database design, and are the documentation that teams use to document for developers, the database design.
    1 point
  24. Yes! If you have each post with its time_posted then you can alway s find the times of first and last posts without storing those dates. Basically, do not store derived data like those dates or totals. Also the thread table contains usierID and username - username belongs only in the user table, not repeated in every thread record for that user. The dats/times are stored as unix timestamps. Horrible and completely unreadable. Use the inbuilt date/time/datetime/timestamp type columns.
    1 point
  25. From what I have been given, I came up with this ... SELECT b.boardID , b.title , t.threadID , t.topic , t.userID , t.username , FROM_UNIXTIME(t.time) AS time , FROM_UNIXTIME(t.lastPostTime) AS lastPostTime FROM wbb1_1_board b JOIN wbb1_1_thread t USING (boardid) JOIN wbb1_1_board_last_post l USING (boardid, threadid) ORDER BY boardID, threadid, time; Hovever, it seems to me that there should be a "post" table containing the post details, including the time_posted. Then you could just extract the posts containing the latest timestamp for each thread.
    1 point
  26. Hi everyone! My name is Jerry, and I’m new to the PHP Freaks community. I’m just starting to learn more about PHP and web development, and I’m excited to be part of this group. I’m here to improve my coding skills, learn best practices, and hopefully contribute to discussions as I grow. If you have any advice for a beginner or resources you recommend, I’d love to hear about them! Looking forward to connecting with you all and learning more about PHP. Best regards, Jerry
    1 point
  27. If the php.exe executable is in your windows path, you probably won't have to manually add the path to that configuration. In fact you would likely need to delete the value from vscode. 1st to understand what the path environment variable does. When you try and run a program, windows will look for that program in the current directory. If it is not found, then it tries to find it in the path. So by design the path variable should have directories in it, NOT the full pathname to the program. So in your example the path you want to add is: C:\laragon\bin\php\php-8.4.3-Win32-vs17 x64\ Follow these instructions to add the location of your laragon php directory file to your system path: These directions were for Windows 10, but they also work for Windows 11. Make sure you don't overwrite your current path, but instead just edit it by adding the path to your php8x installation. Let us know if that fixes the problem. Make sure you restart Vscode after you have added the laragon path to your windows path variable.
    1 point
  28. Contact your hosting provider for assistance. In the meantime, you will need to upload your PHP file change by some other means, such as by using SFTP.
    1 point
  29. Earlier in this thread you said that this ... +----+-----------+-----------+ | id | slug | tag_check | +----+-----------+-----------+ | 1 | hugh-jass | 1 | | 2 | hugh-jass | 2 | +----+-----------+-----------+ ... was acceptable. Your "solution" would not permit this. Secondly, you are using a "dependent subquery" which means for every record inserted you must query all the existing lookig for a duplicate. This can be extremely slow and should be avoided when writing queries. Changing your unique key to ... UNIQUE INDEX `unq_name` (`name`) USING BTREE, ... and using this query would have same result ... INSERT IGNORE into wp_terms (name,slug) SELECT concat(nameFirst,' ',nameLast) , lower(concat(nameFirst,'-',nameLast)) FROM a_players ;
    1 point
  30. You can add a usort function, which sorts the $files1 array based on the modification time of each file. Something like this: usort($files1, function($a, $b) { return filemtime($b) - filemtime($a); }); I would also recommend using htmlspecialchars for added security. Hope this helps.
    1 point
  31. I've started the load of that dump into a test DB. Now I'll just bingewatch a couple of Netfix series while it runs.
    0 points
  32. You could experiment quite safely without any danger of causing a global catastrophe
    0 points
  33. The last 2 lines of your query are ... where you are joining options and filters tables. Your option_id column contains values between 1 and 12. select * from ap_element_options LIMIT 15; +--------+---------+------------+-----------+----------+---------------+-------------------+------------------+------+ | aeo_id | form_id | element_id | option_id | position | option | option_is_default | option_is_hidden | live | +--------+---------+------------+-----------+----------+---------------+-------------------+------------------+------+ | 431 | 10556 | 1 | 4 | 1 | MCSO | 0 | 0 | 1 | | 432 | 10556 | 1 | 5 | 2 | CCSO | 0 | 0 | 1 | | 433 | 10556 | 1 | 6 | 3 | LCSO | 0 | 0 | 1 | | 434 | 10556 | 1 | 7 | 4 | DPD | 0 | 0 | 1 | | 435 | 10556 | 1 | 8 | 5 | FPHM | 0 | 0 | 1 | | 436 | 10556 | 1 | 9 | 6 | FHPC | 0 | 0 | 1 | | 437 | 10556 | 1 | 10 | 7 | FHPL | 0 | 0 | 1 | | 438 | 10556 | 1 | 11 | 8 | AUTO CLUB | 0 | 0 | 1 | | 439 | 10556 | 1 | 12 | 9 | OWNER | 0 | 0 | 1 | | 446 | 10556 | 2 | 4 | 1 | F550 | 0 | 0 | 1 | | 447 | 10556 | 2 | 5 | 2 | F350 | 0 | 0 | 1 | | 448 | 10556 | 2 | 6 | 3 | International | 0 | 0 | 1 | | 449 | 10556 | 2 | 7 | 4 | Ranger | 0 | 0 | 1 | | 453 | 10556 | 4 | 1 | 1 | Credit Card | 0 | 0 | 1 | | 454 | 10556 | 4 | 2 | 2 | Cash | 0 | 0 | 1 | +--------+---------+------------+-----------+----------+---------------+-------------------+------------------+------+ Which of these values are you expecting to match the filter_keyword Tow ? select * from ap_form_filters; +--------+---------+---------+--------------------+--------------+------------------+----------------+ | aff_id | form_id | user_id | incomplete_entries | element_name | filter_condition | filter_keyword | +--------+---------+---------+--------------------+--------------+------------------+----------------+ | 312 | 10556 | 3 | 0 | element_6 | is | Tow | +--------+---------+---------+--------------------+--------------+------------------+----------------+ I suggest you rethink your design and come back when you have something that could work.
    0 points
  34. lol. Glad to see that Powershell had nothing to do with your question, though.
    0 points
This leaderboard is set to New York/GMT-05:00
×
×
  • 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.