Jump to content

johnsmith153

Members
  • Posts

    709
  • Joined

  • Last visited

Everything posted by johnsmith153

  1. I want to search through some text and... (a) pull out the web address inside <a href="here" (b) replace the entire <a href="">xxx</a> with new text Any ideas?
  2. So you can't do an UPDATE where you add 1 on to the current value stored? If I had to SELECT and get the current value (say 232), then add 1 on in PHP and then UPDATE (with the new value, which is obviously 233), then clearly that would be stupid.
  3. I am logging occasions someone's profile is viewed. I will use a Cron to report the amount of views. Do I? (1) INSERT a record every time and count up at end. Remember, I'm using a Cron to report amount of views so won't be counting up on every page request!! (2) UPDATE a table (but won't I need to SELECT previous value first)? Unless, "UPDATE field1 and add 1 to it's value" is possible. Which is best?
  4. Any sample code to start me off? Would I just check for < and > or more (HTML)?
  5. Thanks all for the help. Muddy_Funster, the way you have written it is the most familiar to me as this is how I would write a normal join. In fact the reason I asked the question was the complication with the fact that they must appear in table 2 but can't in table 3. However, this part of your code: WHERE (table2.employeeID IS NOT NULL) AND (table3.employeeID IS NULL) ...is the main bit that isn't too familiar to me (and is obviously the key bit about there must be a record in t2 and can't in t3). Just one question if I could. - What if there was a record in table 3 but it held an empty value, lets say: notes / employeeID "various text entered here" / 2 (empty value) / 3 "hello, more notes" / 2 How would I change the query to ensure it still works? (can you ensure it works if there are a few empty values as well?) e.g.: "various text entered here" / 2 (empty value) / 3 "hello, more notes" / 2 (empty value) / 3 The example here is a small part of something bigger, I just wanted to use something like this to explain it. Thanks. Thanks again for the help everyone.
  6. Table 1 --- uniqueID / employeeName 1 / Dave 2 / Steve 3 / Robert Table 2 --- job / employeeID "telephone Mr Smith" / 2 "complete report abc" / 1 Table 3 --- notes / employeeID "various text entered here" / 2 "hello, more notes" / 2 For my sql query I need to check which employees (from table 1 and if any) DO appear in table 2, but then not in table 3. In this case this would be YES, employee 1.
  7. Thanks mikhl. This is what I needed: SELECT field1 FROM table1 ORDER BY field2, CASE WHEN field4='"" && field5=1 THEN 1 ELSE 0 END, field3
  8. SELECT field1 FROM table1 ORDER BY field2, field3 However I need to add something in so it also orders by a value that is returned from a calculation: SELECT field1 FROM table1 ORDER BY field2, (if field 4=="" and field 5==1 then order these records in order), field3 So they are ordered by field2, then the calculation, then field3
  9. http://www.sitepoint.com/forums/showthread.php?t=732255 Actually it's not complicated when you know how. Very simple.
  10. I have inherited this database and can't change the design. I need to perform a SELECT query and group certain records together for matching employeeID values. The fields: employeeID field1 field2 date (1) field1 can be 1,2,3,4 or 5 only (2) field2 can be a,b,c or a number from 1-100 (varchar though) (3) if field1 and field2 are blank/empty then group together So: employeeID / field1 / field2 / date 32 / 3 / / 1297184426 45 / / b / 1248723499 32 / 3 / / 1258762988 20 / / / 20 / / / 1268722384 So record 1 and 3 above will be grouped, and so will 4 and 5. When I mean grouped, I mean so that only one record will be returned / displayed. Also, when it displays only one record due to being 'grouped', I would like it to return the highest 'date' field value (UNIX Timestamp value) (so the newest / latst date) OR if one of the records is empty then show this instead. So in the above example, record 1 & 3 will return a date of 1297184426 and records 4 and 5 will return nothing for date.
  11. if(in_array("b", $array)) { } The above checks to see if a value is present in an array, but how do I then retrieve the array key value from the matching value? $array[0] = "a"; $array[1] = "b"; $array[2] = "c"; So in the example, the answer is 1 (array key 1).
  12. SELECT COUNT(*) obviously counts all records matching the WHERE clause, however... Field1 / Field2 1 / A / A 1 / B 1 / A I want to count all records where Field2 is "A", but if Field1 is set to "1" then that record counts as half. So above would return a result of 2 (one and two halfs = 2) I'm sure SQL can do this without the need to perfrom PHP calculations. Hope this makes sense. Thanks in advance.
  13. "ORDER BY field" would return 1, 2 3 in that order However I want it to return 3, 1, 2 (there are actually no other possible responses) How would I do this?
  14. I have never understood regular expressions, or spent enough time trying to. I could do with help being able to remove everything before a set value. So "jhfwhfeijhfgeih VALUE wufhehiehriehr" would return "VALUE wufhehiehriehr" Should be easy. Thanks in advance.
  15. I want a simple function that converts a sql query into two queries for pagination purposes. So if the sql query is "SELECT `Name` FROM table1" I would like to perform: "SELECT COUNT(*) FROM table 1" and "SELECT `Name` FROM table1 LIMIT 10, 20" (example) (1) Would this work for most basic queries? (obviously if LIMIT wasn't already used)? (2) What command would I use to convert "SELECT `Name` FROM table1" to "SELECT COUNT(*) FROM table 1" I am aware there is more involved than this, but am just interested in the query side of things.
  16. I know PHP setcookie can set for all subdomains - by setting parameter 5 to something like ".domain.com". However, I have quite a lot of code that just leaves param 5 blank (so sets for the current subdomain of that server). Hopefully there'd be an easy way how to do this (a server setting?). I know you can use ini_set('session.cookie_domain','http://domain.com'); but that only seems to set the session cookie value, not ones set in PHP. I only really want it to ensure if someone accesses the site through both www.domain.com and domain.com that they use the same cookies.
  17. Whenever I see a PHP website (and given ftp access) I often struggle to find the entry page. Most I see don't have index.php in the public_html directory - or that isn't the main entry page. Htaccess and adding Wordpress, shopping carts etc. also messes around with which file is the entry page. Is there a quick checklist of what a simpleton should do to find the entry page? E.g. (1) Check .htaccess................ etc.
  18. What does all this do? If I entered domain.com in the address bar, then where is the entry page? I don't think it's public/index.php #php_flag display_errors 0 Options -Indexes Options +FollowSymLinks # If a https page request is not part of the store, rewrite it to the http location <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{SERVER_PORT} 443 RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^index.php - RewriteCond %{SERVER_PORT} 443 RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^admin.php - RewriteCond %{SERVER_PORT} 443 RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ http://www.domain.com/$1 [L] #RewriteCond %{SERVER_PORT} 443 #RewriteRule ^$ http://www.domain.com/ [L] </IfModule> # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress
  19. I am aiming to use setcookie to refresh the expiry of a cookie on EVERY page request. Is this slow? I'm sure I can design things so i don't need to reset it on every page request, but if it isn't a big deal then I'll do it. Is setcookie slow?
  20. I can't understand the contents. Is there a way of decoding it (so a human can see it)? Or is this the point that it is encrypted for a reason? What reasons would somebody want to encrypt the contents? (protect their work?)
  21. That is the question I am asking. Can it be editted? If so, how? Maybe the answer is that is can't be editted, and that is fine, I just need to know.
×
×
  • 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.