Jump to content

Psycho

Moderators
  • Posts

    12,157
  • Joined

  • Last visited

  • Days Won

    129

Everything posted by Psycho

  1. JavaScript alerts do not have the ability to add checkboxes or other fields. You can use something like a JQueryUI dialog: https://jqueryui.com/dialog/#modal-form
  2. I can't give you any advice as you still have not answered my previous questions. Are the fees a one-time event or will there be recurring fees: monthly, yearly, etc? Are the fees to be paid in their entirety when paid or can they be paid partially?
  3. You didn't answer my questions, so why should I take the time to answer yours? I don't see how the joined date can be used to know if a user has paid their fees (even though the field doesn't even state that it is a joined date). That date only tells you, presumably, when they joined. So, what data are you storing to know when a user has paid the fees? Are you reducing the fees field when they make payment? That's a poor way to do it since you would have no history of exactly when they were paid and how much they paid. But, making a HUGE assumption that the fees field is the outstanding fees (which is a terrible process), this query would get you the list of users who have an outstanding fee and their joined date was > 30 days ago. SELECT id, fname, name, fee, `date` FROM users WHERE fees > 0 AND date < CURDATE() - INTERVAL 30 DAY Or, if you want ALL the users to display in a list and show specific notices next to the ones who's fee is pending, you could either add that logic to the output processing OR you could add a dynamic field to the query result. SELECT *, (`date` < CURDATE() - INTERVAL 30 DAY and fees > 0) as fee_due FROM `users` But, if you are doing as I suspect, it is a poor implementation.
  4. The problem is not the query. The problem is likely the logic in displaying the output. I expect you have a loop to process all the records in the result set. You need to have logic so the first record in the result set display the post content and the first comment (if it exists). Each subsequent record in the result set should only display the comment. But, there is a problem with the query. It uses a normal JOIN. So, if there are no records in the comments table, the post won't be returned either. This needs to use a LEFT JOIN so all relevant posts will be returned - even if they do not have comments.
  5. Not enough information to help: Are these one-time fees? If not, you will need to track when fees are paid separately from the joined date. In fact, it should be stored in a separate table so you can maintain a history. Even if the fees are a one-time event, there's nothing in your current table to know if fees have been paid or not. And, unless fees are required to be paid in full at one time, you would still want a separate table to track them. Only if fees are paid once (non renewed) and in full at once, you will need a separate table. And, even if it is all at once and non-recurring, you will need an additional field in the existing table to track when they are paid. So, some database changes will be needed. Then, how are you wanting these reminders to occur? Do you just want a reminder through the UI - either the user sees it when logging in, a management page, etc. Or, do you want a proactive notification such as an email? The former just requires a DB query to get the requisite data and display the appropriate content. But, the latter would require a scheduled even to check for payments that are older than a specified period and initiate an email or emails.
  6. It is my understanding that a timestamp is the correct type if the "event" is one that must be normalized based upon a given user's timezone. A datetime is one that would be statis regardless of timezone. For example, if I am recording the date and time that someone is born, you would display the exact same date and time to a user regardless of their locale (a datetime type). Otherwise, my birthday would be a day earlier if I traveled to Europe. Conversely, if I was to record the date and time of when a specific event was to occur, such as the super bowl, I would use a timestamp so it could be displayed as to the correct date and time relative to the user.
  7. To add to requinix's response: Since you mention "time" in your post, it is very important to know whether you want to subtract 30 calendar days or if you want to subtract 30 days (i.e. 30 x 24 hours). It will likely depend on "how" the value(s) are used. This is due to Daylight Savings time that is used in some parts of the world. Let me give two examples that would need to be handled differently. Scenario #1: Let's say you want to run a report from a specific date/time back 30 days. If the user expects to run the report at 5PM (close of business) today to see a report of all activity from 30 days ago at close of business - the logic needs to subtract 30 calendar days, but set 5PM as a constant. Scenario #2: An application that needs to track the status of an activity over very specific times would likely be different. For example, say there is an experiment to measure the results over hours/weeks/months. If I wanted a report for the results over 30 days it would need to take into account time changes due to daylight savings. So, if I wanted the report to end at 5PM today, it would need to start at 6PM on the calendar day 30 days back. That is because last weekend we set the clock back an hour last weekend (i.e. we repeated the 1AM to 2AM hour).
  8. Well, you could use GROUP_CONCAT() which will concatenate the values within a grouped record. But, it has some limitations. For example, I don't think it will remove duplicates. BUt, there are other, more technical issues. that I don't want to go into details with. If you need those values, then I would suggest just selecting all the records instead of getting calculated totals. Then when outputting the results, get the totals. Using GROUP_CONCAT SELECT pseudo, SUM(nmbr) as score, GROUP_CONCAT(DISTINCT player_name ORDER BY player_name ASC SEPARATOR ', ') as player_list FROM unanimo INNER JOIN ( SELECT mot , COUNT(*) as nmbr FROM unanimo GROUP BY mot HAVING nmbr > 1 ) tot USING (mot) GROUP BY pseudo ORDER BY score DESC; Or, just query all the relevant records without the GROUP BY and handle the logic to calculate totals and determine the player list in the code.
  9. I'm not an expert in CSS. There may be a better way but this works (tested in Chrome). Of course you would likely need to modify the styles further to get the actual look/feel of the content and boxes as you like. but, it does create the look of the little sub-dialog boxes peeking out at the bottom. I would create those within the server-side code using smaller increments for the width. Everything else can be done through the CSS style sheet. <html> <head> <style> #container { display:inline-block; width: 300px; } #dialog { border: 1px solid #000000; text-align: center; } #title { background: blue; width: 300px; color: #ffffff; } #body { height: 100px; } .subDialog {height: 5px; border: 1px solid #000000; margin: 0 auto; } </style> </head> <body> <div id="container"> <div id="dialog"> <div id="title">Dropbox</div> <div id="body"><br>4 Files were updated in your folder<br><br><button>View Folder</button></div> </div> <div class="subDialog" style="width: 290px;"></div> <div class="subDialog" style="width: 280px;"></div> <div class="subDialog" style="width: 270px;"></div> </div> </body> </html>
  10. The fields are updated in order, so be sure to have the pad_count updated first in the query. Then the update to the cn1 field would use the 'current/new' value of pad_count UPDATE users SET pad_count = (pad_count + $add_pad_count), cn1 = CONCAT('cn', pad_count) -- will use the new pad_count value set on the line above WHERE username = '$session->username' EDIT: In retrospect, this is unnecessary to have pad_count and cn1 fields. You can always get the cn1 value from the pad_count. Either by dynamically creating the value in the select query or generating the value in the PHP code from the pad_count. Dynamically creating cn value in SELECT query. SELECT pad_count, CONCAT('cn', pad_count) as cn_value FROM users
  11. I'm not really following. First of all, there should be no reason to run two queries. Are you wanting to set the field cn1 to the string value of "CN" concatenated with the new numerical value for pad_count? For example, if the exising pad_count value equals 10 and the $add_pad_count is 5: do you want to set pad_count to '15' and cn1 to 'cn15'?
  12. Have you connected to the database? If not, mysql_real_escape_string() will not work (But, you should not be using the mysql_ functions anymore anyways). My guess is that the function is failing and returning FALSE (The Boolean value, not the string). Try running this to verify what, exactly $score contains: var_dump($score);
  13. In other words, find the code that inserts those records and do the replacements on the text before the data is inserted. Once the problem has been fixed at the source, you can then run the necessary REPLACE queries to resolve the existing data.
  14. You stated the objective was to retrieve the records. I assumed you would have a script that would select the records then perform some actions that included DELETE - e.g. possible apply the labels of the duplicates to the original if needed. I'm not following. The first query I provided should return the records from the food_tags table associated with foods that are duplicated (excluding the original food records). Which is exactly what you stated in your objective. Perhaps you can provide a small subset of example data and what you expect to have returned (deleted)?
  15. And why wouldn't you want to fix the schema? I know you stated " . . . let's assume that these options are not available". But, many times people come here asking for a complicated solution for something that was built incorrectly because they can't conceptualize the correct solution. Then the people helping spend time providing something that is less than optimal. Or, we spend a lot of time trying to dig to the source of the issue and have to guide the OP to the better solution. Not sure why you only want the tags of the duplicates and not the first record. Are you using an existing query to get the tags of the original and are wanting the tags of the duplicates to append them together? Anyway, what you are asking is quite simple. Here is the query to get ALL the records from food_tags associated with 'duplicate' records (excluding the original record that is duplicated) SELECT * FROM food_tags WHERE food_id NOT IN ( SELECT MIN(id) FROM foods GROUP BY name ) Here's a version with JOINs to show descriptive values SELECT foods.name, foods.id, tags.name, tags.id FROM food_tags JOIN foods ON foods.id = food_tags.food_id JOIN tags ON tags.id = food_tags.tag_id WHERE food_id NOT IN ( SELECT MIN(id) FROM foods GROUP BY name ) ORDER BY foods.name, foods.id
  16. There is always a different way, the question is if there is a better way or not - and in this case there is. I was actually going to speak to the same problem that I'm sure benanamen was going to address, but decided against it once Ch0cu3r responded. You should not have data where there is an assumption of correlation based on position. This is bad form and will eventually lead to bugs. Instead, the correlated data should be structured such that the correlation is specifically defined. In this case you have pairs of fields that should be correlated within the structure. Using a multidimensional array was the right choice - but I would swap the keys so that the records are logically structured. But, instead of "[]" you will need to define the key. E.g. <input type="text" name="productVariations[0][name] /> <input type="text" name="productVariations[0][price]" /> <input type="text" name="productVariations[1][name] /> <input type="text" name="productVariations[1][price]" /> <input type="text" name="productVariations[2][name] /> <input type="text" name="productVariations[2][price]" /> I'm sure I've left off some content that goes between the fields and, ideally, the output would be generated within a loop. using that structure, the array of the post data would look like this productVariations array ( 0 => ("name" => "Default", "price" => "12.99"), 1 => ("name" => "100ml", "price" => "9.99"), 2 => ("name" => "150ml", "price" => "14.99") ) Then the code to process the data could look like this foreach($productVariationsAry as $record) { $name = $record['name']; $price = $record['price']; // do insert query } FYI: It would also be more efficient to create ONE insert query to insert all records at one.
  17. There is no definitive way to know that a user is "online". A server doesn't know what the user's state is between one page request and another. All you can do is store a timestamp for each page request and if a user has not requested a page in (some time that you define) assume they are no longer on your site. Now, you *could* implement some JavaScript to make an AJAX call every X minutes to better know when they are not on your site, but the overhead of doing that is not worth it. EDIT: Also, do not DELETE records when you "think" they leave. Just use the last timestamp as the last time the user has made a request. Delete's are big performance hogs and there is no need for it in this context.
  18. There's quite a few things which need to be "fixed" in this code, not the least of which is the password verification. But, we can start with that. When a user creates their password, use the function password_hash() to generate a hash value and save it to the DB. Then, when a user attempts to log in, run a DB query to find the record matching just the username. Take the hash value from the DB and the password the user provided on the login and use the password_verify() function to see if the password is valid. FYI: Font tags have been deprecated for over a decade!
  19. Give this a try <?php if (!empty($results)) { foreach ($results as $row) { echo "<tr>\n" echo " <td>{$row['user_nome']}</td>\n"; echo " <td>{$row['user_email']}</td>\n"; echo " <td>{$row['user_tel']}</td>\n"; echo " <td><a data-toggle='modal' data-id='{$row['user_id']}' class='open-AddDialog btn btn-sm btn-danger center-block' href='#myModal'>Validar</a></td>\n"; echo "</tr>\n" } } ?>
  20. You have an 'echo' inside the quoted text. Couple that with the fact that you start the string with a single quote and then put an array with a single quoted index inside the string, the PHP parser is confused (as am I). Also, why do you have this? if (empty($results)) { } else { There is no purpose for the TRUE branch of that statement. Just use this ]if (!empty($results)) { Although, if $results is just an empty array, you don't need the empty check at all - just run the foreach. EDIT: You are also creating some invalid HTML code. There is no closing TD for one element - and I would expect a closing TR on each foreach as well.
  21. There are many characters that can legitimately be within and at the end of a sentence " . . . just like in literature". If this is for a real-world application that will presumably produce an error for sentences entered by users, you are going to have the very likely possibility of false negatives.
  22. Short answer, No. You could either learn enough to accomplish what you want to achieve or find someone who will do it for you (possibly for a fee). But, I can provide some insight as to the problem. When a request is made to a server for a PHP page, the server will complete all of the action within that script (and included scripts). Once all processing is complete it will then send the completed page to the user. There are a lot of exceptions to that, but for your situation it applies. Then once the user's browser receives the page, any JavaScript in that page can then execute. The solution to your problem would likely be to make an AJAX call to get the RSS feed data. So, the page you have now should just create a container to put the RSS output and remove the PHP line that goes to get the content. Then, in addition to having JavaScript code to preload the images, you would implement an AJAX call to a PHP page to just return the RSS content that you would then populate on the page with JavaScript. This may sound complicated, but there is a framework called JQuery that would make this rather easy. But, if you don't know any coding it could take a while to figure out how to implement it. http://api.jquery.com/load/
  23. What is the difference between the two manners in which you are referencing the value?? Hint, one of these things is not like the other:
  24. shan, Your description does not provide any real help in understanding what you are needing help with. I'm sure it makes perfect sense to you as you are fully engaged i the code and the problem. But, your statement doesn't make sense to those of us without any context. Also, just copy/pasting a lot of code suggests you expect those providing free help to try and read through all that code to figure out what the problem may be. Please try to identify the specific part of the code causing the problem, what that code is currently doing, and what you expect the code to do.
  25. benanamen is correct, tables should not be used for the purpose of layouts. But, to provide an answer to your problem - colspans do not apply to TR tags. A TR is just to define a row. The rowspan attribute applies to TD elements to state whether they should take multiple columns. So, you could do the following: - Add a colspan="2" to the Organization name TD - Add a collspan="3" to the last TD in each row starting with the Fax number
×
×
  • 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.