Jump to content

All Activity

This stream auto-updates     

  1. Today
  2. Fixed it! The only thing I did was change $_POST["id"] to $_GET["id"] in the form. Thanks all for helping me with the thought proces : )
  3. If you don't want to take our advice, you could resort to SELECT h1.emp_id , h1.pay , h1.hours1 , h2.hours2 , h3.hours3; SELECT * FROM ( SELECT e.emp_id , e.pay , ot.hours1 as hours FROM employeex e JOIN employeex e2 ON e.time1 = e2.emp_id JOIN overtimex ot ON e2.grade = ot.rank ) h1 JOIN ( SELECT e.emp_id , e.pay , ot.hours2 FROM employeex e JOIN employeex e2 ON e.time2 = e2.emp_id JOIN overtimex ot ON e2.grade = ot.rank ) h2 ON h1.emp_id = h2.emp_id JOIN ( SELECT e.emp_id , e.pay , ot.hours3 FROM employeex e JOIN employeex e2 ON e.time3 = e2.emp_id JOIN overtimex ot ON e2.grade = ot.rank ) h3 ON h1.emp_id = h3.emp_id WHERE h1.emp_id = 67;
  4. hi there - good day dear Barand - dear Requinix and all php-friends, found a solution - this i want to share with you... cf https://stackoverflow.com/questions/51990613/getting-a-list-of-all-plugins There is a plugin API which we can query for plugins like this: $api = plugins_api( 'query_plugins', $args ); developer.wordpress.org/reference/functions/plugins_api – we can make use of plugins_api('hot_tags'), array('page' => 90000000000, 'number' => 90000000000). It returns some plugins but not all. we can go this way: $api = plugins_api( 'query_plugins', [ 'per_page' => - Because getting all plugins at once will be too heavy for the server, it is a better idea to do it in steps we could do as many plugins at once as the server can handle. For the example I use a safe 100 plugins at once. Everytime the script runs, it increments the "page" number with 1. So the next time the script runs the next 100 plugins are retrieved. The contents of the existing plugins.json will be parsed. The new plugins will be added (or overwritten if the plugin already is present) to the existing data, before encoding and saving it again. If the page number is past the last, no results will be returned. This way the script knows there are no more plugins next. It then resets the page to 1, so it starts over. we can use the wp_options table to keep track of the pages, simply because it's the quickest way. It would be better to use some kind of filesystem caching. That will be easier to reset manually if needed.we can set a cronjob to execute the script every x minutes. Now the plugins.json file will build up and grow step by step, every time it runs. // get the current "page", or if the option not exists, set page to 1. $page = get_option( 'plugins_page' ) ? (int)get_option( 'plugins_page' ) : 1; // get the plugin objects $plugins = plugins_api( 'query_plugins', [ 'per_page' => 100, 'page' => $page, 'fields' => [ //......... ] ] ); // increment the page, or when no results, reset to 1. update_option( 'plugins_page', count( $plugins ) > 0 ? ++ $page : 1 ); // build up the data array $newData = []; foreach ( $plugins as $plugin ) { foreach ( $plugin as $key => $p ) { if ( $p->name != null ) { $newData[ $p->name ] = [ 'slug' => $p->slug ]; } } } // get plugin data already in file. // The last argument (true) is important. It makes json objects into // associative arrays so they can be merged with array_merge. $existingData = json_decode( file_get_contents( 'plugins.json' ), true ); // merge existing data with new data $pluginData = array_merge( $existingData, $newData ); file_put_contents( 'plugins.json', json_encode( $pluginData ) ); Getting a list of plugins: This will not return ALL plugins but it will return the top rated ones: $plugins = plugins_api('query_plugins', array( 'per_page' => 100, 'browse' => 'top-rated', 'fields' => array( 'short_description' => false, 'description' => false, 'sections' => false, 'tested' => false, 'requires' => false, 'rating' => false, 'ratings' => false, 'downloaded' => false, 'downloadlink' => false, 'last_updated' => false, 'added' => false, 'tags' => false, 'compatibility' => false, 'homepage' => false, 'versions' => false, 'donate_link' => false, 'reviews' => false, 'banners' => false, 'icons' => false, 'active_installs' => false, 'group' => false, 'contributors' => false ))); we can save the data as JSON Since the data that we get is huge and it will be bad for performance, we can try to get the name and the slug out of the array and then we write it in a JSON file: $plugins_json = '{' . PHP_EOL; // Get only the name and the slug foreach ($plugins as $plugin) { foreach ($plugin as $key => $p) { if ($p->name != null) { // Let's beautify the JSON $plugins_json .= ' "'. $p->name . '": {' . PHP_EOL; $plugins_json .= ' "slug": "' . $p->slug . '"' . PHP_EOL; end($plugin); $plugins_json .= ($key !== key($plugin)) ? ' },' . PHP_EOL : ' }' . PHP_EOL; } } } $plugins_json .= '}'; file_put_contents('plugins.json', $plugins_json); Now we have a slim JSON file with only the data that we need. To keep updating the JSON file, we run that script to create a JSON file every 24 hours by setting up a Cron Job. just wanted to share this with you have a great day...
  5. Yesterday
  6. I feel like I need to emphasize the last thing I wrote a little bit more. By using URLs like /ClientOrganizationName, where you have only one "segment" of the path, you are limiting what you can do in the future. Anything else that's one segment will look like a company name. That means you can't do stuff like /about or /Contact-Us because those will look like companies. You should namespace the URL so that you can safely dedicate the entire pattern to companies without worrying about it conflicting with anything else. Doesn't have to be complicated. I'm thinking like /shop/ClientOrganizationName: you're able to add a new keyword in there and it's still easy for anyone to understand.
  7. thanks very much for that, i'll look into it now. Am only going to be using it for the one page, and not using wordpress just that where i thought i'd seen something like it. thanks again.
  8. You can definitely do /ClientOrganizationName being treated as /productpage.php?companyName=ClientOrganizationName. Note the two names are the same. The concept is called URL rewriting and there's a lot of information on the internet about it. What you do is tell your web server that requests for a URL in a certain pattern should be "rewritten" to another URL. In your case, you would tell it that a URL that is a name without any "directory" (so /Client matches but not /foo/Client or /Client/foo) takes that name and gives it to productpage.php. If you're using WordPress, IIRC it has a URL rewriting feature by itself (the web server was told that everything should go through WP, and then WP itself decides what to do) so you would tell WP that pages in that pattern should be treated a certain way. There is one restriction, though: this URL pattern needs to be dedicated to this one particular feature. Otherwise the URLs would be ambiguous.
  9. JoshEir

    Hello

    Hello, I am new to this forum. I am gaining experience with different languages to get an internship. I like PHP, it is very nifty. My PHP project is an ecommerce site such as something like Amazon. What a great place to share great knowledge! JoshEir
  10. In a very to similar manner to the code already given. SELECT name , 'Y' as paid FROM fee WHERE month(month) IN (3,4,5) AND paid = 'Y' GROUP BY name HAVING count(*) = 3;
  11. Hi Not even sure if this is possible, but well here goes: We have a wholesale site where companies, organisations, clubs etc can buy products. We are setting it up so that these organisations can pick their items then our system will set up a webshop for them, they can then send the link to their employees, members to order the items that the company has chosen ahead of time. our site would be http://www.ourcompanyname.com/productpage.php?companyName=ourClient we would like if poss : http://www.ourcompanyname.com/ClientOrganisationName(either with or without the PHP extension). ClientOrganisationName would be taken from their record in mysql. If this is possible could someone please just tell me what i need to look up. I think wordpress has something similar which is prob where i thought about using on our site. thanks very much, MsKazza.
  12. You have what appear to be a number of problems with your original query. FROM chat_message AS msgs LEFT JOIN chat_to_users AS msgsTo ON msgs.chat_message_id = msgsTo.id AND msgsTo.to_user_id = 7 Here you are joining based on the condition chat_messages.chat_message_id = chat_to_users.id. Both of those columns are AUTO_INCREMENT PRIMARY KEYS according to your table definitions which means that condition makes no sense. Only one side of a condition should be to a AUTO_INCREMENT column, the other side needs to reference a regular INT column that's a reference. Based on your table definitions, you probably want to be making the condition on the chat_to_users.message_id column FROM chat_message AS msgs LEFT JOIN chat_to_users AS msgsTo ON msgs.chat_message_id = msgsTo.message_id AND msgsTo.to_user_id = 7 You also seem to have an order_id column that is linking the tables. Whether this is necessary or not is unclear, but if you're expecting them to be the same then that should also be part of your join condition. FROM chat_message AS msgs LEFT JOIN chat_to_users AS msgsTo ON msgs.chat_message_id = msgsTo.message_id AND msgs.order_id = msgsTo.order_id AND msgsTo.to_user_id = 7
  13. Hi Barand, thanks for the help. How can we show just one row per student's name and only two columns, name and "Y", those who paid all 3 months.
  14. Okay...I've got it doing what I need it doing...lol but I know I'm doing some repetitive stuff but I couldn't figure out what I was doing wrong with my query above. Here is my current function: //get all messages directd to a specifc user function get_messages_directed_to( $user_id, $pdo ) { //get all entries from chat_to_users $query = " SELECT msgsTo.*, msgs.timestamp FROM chat_to_users AS msgsTo LEFT JOIN chat_message AS msgs ON msgsTo.message_id = msgs.chat_message_id WHERE to_user_id = :user_id ORDER BY msgs.timestamp DESC "; $statement = $pdo->prepare( $query ); $statement->execute( [ 'user_id' => $user_id ] ); $result = $statement->fetchAll(); foreach ( $result as $r ) { $query = " SELECT msgs.*, orders.job_number, orders.enterprise FROM chat_message AS msgs LEFT JOIN production_data AS orders ON ". $r['order_id'] ." = orders.id WHERE msgs.chat_message_id = ". $r['message_id'] ." "; $statement = $pdo->prepare( $query ); $statement->execute(); $results = $statement->fetchAll(); $structure_results[] = [ 'from_user_id' => $r['from_user_id'], 'to_user_id' => $r['to_user_id'], 'order_id' => $r['order_id'], 'order_job_number' => $results[0]['job_number'], 'order_enterprise' => $results[0]['enterprise'], 'chat_message_id' => $results[0]['chat_message_id'], 'chat_message' => $results[0]['chat_message'], 'chat_timestamp' => $results[0]['timestamp'], ]; } print_r( $structure_results ); } Here is the resulting array with a user_id of 7: Array ( [0] => Array ( [from_user_id] => 23 [to_user_id] => 7 [order_id] => 366 [order_job_number] => 22004702 [order_enterprise] => CONOCO [chat_message_id] => 152 [chat_message] => Have to repaint the cabinet. Wrong color on the BOM. [chat_timestamp] => 2020-05-29 09:39:30 ) [1] => Array ( [from_user_id] => 18 [to_user_id] => 7 [order_id] => 157 [order_job_number] => 22992201 [order_enterprise] => CONOCO [chat_message_id] => 138 [chat_message] => LEDS came in on the 5-22 please advise new ship date [chat_timestamp] => 2020-05-28 15:06:38 ) [2] => Array ( [from_user_id] => 18 [to_user_id] => 7 [order_id] => 215 [order_job_number] => 22991891 [order_enterprise] => CONOCO [chat_message_id] => 137 [chat_message] => According to Amanda principals to be rcvd 5-28 can you please advise new ship date thank you [chat_timestamp] => 2020-05-28 14:15:40 ) [3] => Array ( [from_user_id] => 6 [to_user_id] => 7 [order_id] => 1051 [order_job_number] => 22994751 [order_enterprise] => SHRVIE [chat_message_id] => 134 [chat_message] => We are needing a traveler for the 1x price faces part#FA2026SG.1LD [chat_timestamp] => 2020-05-28 11:11:16 ) [4] => Array ( [from_user_id] => 6 [to_user_id] => 7 [order_id] => 759 [order_job_number] => 22972681 [order_enterprise] => GREASEMN [chat_message_id] => 109 [chat_message] => panels are finished [chat_timestamp] => 2020-05-27 07:48:37 ) [5] => Array ( [from_user_id] => 8 [to_user_id] => 7 [order_id] => 3 [order_job_number] => 22982151 [order_enterprise] => AMERICAN [chat_message_id] => 95 [chat_message] => Derrick needs the can for this 3'x6' American Standard [chat_timestamp] => 2020-05-26 11:21:49 ) [6] => Array ( [from_user_id] => 6 [to_user_id] => 7 [order_id] => 634 [order_job_number] => 22000782 [order_enterprise] => EXXON [chat_message_id] => 91 [chat_message] => Waiting on vinyl to arrive, is supposed to be here this week. [chat_timestamp] => 2020-05-26 05:55:25 ) [7] => Array ( [from_user_id] => 6 [to_user_id] => 7 [order_id] => 759 [order_job_number] => 22972681 [order_enterprise] => GREASEMN [chat_message_id] => 89 [chat_message] => had to be repainted, will have ready by 5/28. [chat_timestamp] => 2020-05-26 05:07:44 ) [8] => Array ( [from_user_id] => 6 [to_user_id] => 7 [order_id] => 758 [order_job_number] => 22972681 [order_enterprise] => GREASEMN [chat_message_id] => 88 [chat_message] => had to be repainted, will have ready by 5/28 [chat_timestamp] => 2020-05-26 05:06:37 ) [9] => Array ( [from_user_id] => 6 [to_user_id] => 7 [order_id] => 757 [order_job_number] => 22972681 [order_enterprise] => GREASEMN [chat_message_id] => 87 [chat_message] => had to be repainted, will have ready by 5/28 [chat_timestamp] => 2020-05-26 05:05:34 ) [10] => Array ( [from_user_id] => 6 [to_user_id] => 7 [order_id] => 1026 [order_job_number] => 22973261 [order_enterprise] => SHRVIE [chat_message_id] => 86 [chat_message] => One of the prints was a Shop N Stop. took pictures sent to purchasing. requested a new one. [chat_timestamp] => 2020-05-25 22:33:44 ) [11] => Array ( [from_user_id] => 6 [to_user_id] => 7 [order_id] => 1048 [order_job_number] => 22986511 [order_enterprise] => SHRVIE [chat_message_id] => 85 [chat_message] => Waiting on the vinyl to come in. They are supposed to be in this week. [chat_timestamp] => 2020-05-25 21:12:38 ) [12] => Array ( [from_user_id] => 6 [to_user_id] => 7 [order_id] => 9 [order_job_number] => 35550690 [order_enterprise] => AMOCO [chat_message_id] => 81 [chat_message] => waiting on vinyl to arrive [chat_timestamp] => 2020-05-21 10:01:49 ) [13] => Array ( [from_user_id] => 4 [to_user_id] => 7 [order_id] => 75338 [order_job_number] => [order_enterprise] => [chat_message_id] => 44 [chat_message] => Drawing is updated [chat_timestamp] => 2020-04-21 10:28:07 ) )
  15. Since none of us are clairvoyant, as far as I know, it might help if you posted your code. Be sure to use the code icon (<>) and select PHP.
  16. Still don't know what chat message data or production data you have. All I see are four chat_message_to records. Nor do I know what results you are expecting.
  17. Hmm..it still is behaving strangely. It's like it's just replacing data (ie like the order id)...here is an example after I updated the statement to this: SELECT msgs.chat_message, msgs.order_id, msgs.timestamp, msgsTo.id, msgsTo.from_user_id, msgsTo.to_user_id, msgsTo.status, orders.job_number, orders.enterprise FROM chat_message AS msgs LEFT JOIN chat_to_users AS msgsTo ON msgs.chat_message_id = msgsTo.id AND msgsTo.to_user_id = 7 LEFT JOIN production_data AS orders ON msgs.order_id = orders.id ORDER BY msgs.timestamp DESC Which returns this data: https://imgur.com/4ux5Lu6 I have highlighted a specific row (with an id of 55) and then pulled up that row https://imgur.com/39Tougx See how on the first screenshot it shows an order id of 666 when in fact the actual record has an id of 759? You said you can't see my data...maybe table structure would help? CREATE TABLE `chat_message` ( `chat_message_id` int(11) NOT NULL AUTO_INCREMENT, `order_id` int(11) DEFAULT NULL, `chat_message` text NOT NULL, `timestamp` timestamp NOT NULL DEFAULT current_timestamp() COMMENT 'time message was sent', PRIMARY KEY (`chat_message_id`) ) ENGINE=InnoDB AUTO_INCREMENT=169 DEFAULT CHARSET=latin1 CREATE TABLE `chat_to_users` ( `id` int(11) NOT NULL AUTO_INCREMENT, `message_id` int(11) NOT NULL, `order_id` int(11) DEFAULT NULL, `to_user_id` int(11) NOT NULL DEFAULT 0, `from_user_id` int(11) NOT NULL, `read_timestamp` timestamp NULL DEFAULT NULL COMMENT 'time user read message', `status` int(1) NOT NULL DEFAULT 0, PRIMARY KEY (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=230 DEFAULT CHARSET=latin1 CREATE TABLE `production_data` ( `id` int(11) NOT NULL AUTO_INCREMENT, `job_number` int(8) NOT NULL, `enterprise` tinytext NOT NULL, `part_number` text NOT NULL, `description` text NOT NULL, `qty` int(11) NOT NULL, `line_item` varchar(11) NOT NULL, `as400_ship_date` date DEFAULT NULL, `hold_reason` text NOT NULL DEFAULT '0', `hold_date` date DEFAULT NULL, `insert_time` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'time order was inserted', PRIMARY KEY (`id`), KEY `job_line` (`job_number`,`line_item`) ) ENGINE=MyISAM AUTO_INCREMENT=1685 DEFAULT CHARSET=latin1 FYI: I just realized this post was moved the MySQL help. I should have posted it there. Sorry about that.
  18. Hi I am using facebook auth but email id not fetching from facebook login please help me why is happening?
  19. Simpler than you might think. The foreach loops through the array, giving you the key and value of each item in turn. For every item, you want to insert the Table Row construct. For the item where the key is "ct", you want to insert some extra "stuff". Try this: foreach( $arr as $k => $v ){ $x .= sprintf( '<tr><td> Td %s </td><td> Td %s</td></tr>', $k, $v ); if ( 'ct' === $k ) { $x .= $Insert_HTML_Here ; } } Regards, Phill W.
  20. Try explaining what your problem is using paragraphs and complete sentences.
  21. It doesn't look like your query contains the name of the commenter in its results. Could that be the problem?
  22. Ah yes , the three types of programmer, those who can count and those who can't Use a table subquery to find those who paid all two and match against it with a join SELECT name , month(month) as mno , paid FROM fee JOIN ( SELECT name , count(*) FROM fee WHERE month(month) IN (3,4,5) AND paid = 'Y' GROUP BY name HAVING count(*) = 3 ) paid3 USING (name) WHERE month >= '2020-03-01' ORDER BY name, month
  23. <?php function test(){ $x = ''; $arr = array('co'=>'color','ct'=>'design','cv'=>'weight','cm'=>'hight','cp'=>'price'); foreach($arr as $k=> $v){ $x .= '<tr><td> Td '.$k.' </td><td> Td '.$v.'</td></tr>' /* AFTER ACCESS THE ROW THAT DISPLAY "<tr><td> Td ct </td><td>Td design </td></tr>" */ /* insert HTML CODE (not by echo ) then complete the loop */ } return $x; } ?> How can I do it?
  24. Hi Barand, I now want to extract the details of students who have paid all 2 months, i.e. march, april and may. I have written the following query but it is not bringing any records, however there are many students who have paid all 3 months. SELECT nroll.id as id, nroll.sname, nroll.ctclass, parents.memail, parents.femail FROM nroll INNER JOIN parents on nroll.id=parents.id INNER JOIN mfee on nroll.id=mfee.sid WHERE nroll.ctstudent = 'Y' and nroll.ctclass='1 Reception-1' and nroll.shift='1' and (mfee.month='2020-01-01' and mfee.month='2020-02-01') ORDER BY nroll.sname
  25. Or just use Excel instead of trying to store spreadsheet tables in a database. I agree with @benanamen - normalize. Something like this +------------+ | employee | +------------+ +------------+ | emp_id |----+ | time | | fname | | +------------+ | lname | | | time_no |----+ | pay | +----<| emp_id | | | grade |--+ | time_emp | | +------------+ | +------------+ | | | | +------------+ | | | overtime | | | +------------+ | +------<| grade | | | time_no |>---+ | hours | +------------+ Your table data employee time overtime +--------+-------+-------+ +---------+--------+----------+ +-------+-------+---------+-------+ | emp_id | pay | grade | | time_no | emp_id | time_emp | | ot_id | grade | time_no | hours | +--------+-------+-------+ +---------+--------+----------+ +-------+-------+---------+-------+ | 11 | 12500 | 3 | | 1 | 11 | 6 | | 1 | 3 | 1 | 10 | | 15 | 15000 | 5 | | 1 | 15 | 4 | | 2 | 3 | 2 | 5 | | 23 | 17000 | 7 | | 1 | 23 | 15 | | 3 | 3 | 3 | 0 | | 67 | 20000 | 9 | | 1 | 67 | 23 | | 4 | 5 | 1 | 15 | +--------+-------+-------+ | 2 | 11 | 2 | | 5 | 5 | 2 | 10 | | 2 | 15 | 23 | | 6 | 5 | 3 | 5 | | 2 | 23 | 8 | | 7 | 7 | 1 | 20 | | 2 | 67 | 15 | | 8 | 7 | 2 | 15 | | 3 | 11 | 19 | | 9 | 7 | 3 | 10 | | 3 | 15 | 10 | | 10 | 9 | 1 | 25 | | 3 | 23 | 11 | | 11 | 9 | 2 | 20 | | 3 | 67 | 11 | | 12 | 9 | 3 | 15 | +---------+--------+----------+ +-------+-------+---------+-------+ Then SELECT e.emp_id , e.pay , t.time_no , ot.hours FROM employee e JOIN time t ON e.emp_id = t.emp_id JOIN employee e2 ON t.time_emp = e2.emp_id JOIN overtime ot ON e2.grade = ot.grade AND t.time_no = ot.time_no WHERE e.emp_id = 67 ORDER BY time_no; +--------+-------+---------+-------+ | emp_id | pay | time_no | hours | +--------+-------+---------+-------+ | 67 | 20000 | 1 | 20 | | 67 | 20000 | 2 | 10 | | 67 | 20000 | 3 | 0 | +--------+-------+---------+-------+
  1. Load more activity
×
×
  • 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.