Jump to content

akitchin

Staff Alumni
  • Posts

    2,515
  • Joined

  • Last visited

    Never

Everything posted by akitchin

  1. the problem with this structure is, what if you want to suddenly associate a product with five sections? you'd have to add a column, and if the database is designed properly, you should never need to change the structure itself after starting to use it.
  2. no, there's no need - you can just assign the return value from mysql_fetch_array() to a variable. that will give you an array, so you'll need to specify the column as the array's index: echo $variable['column_name'];
  3. you can edit this query: $result = mysql_query("SELECT * FROM wars ORDER by id DESC"); to use DATE_FORMAT() on the `date` column. what did you try?
  4. you need to use some or all of the following functions: mysql_connect mysql_select_db mysql_query mysql_fetch_array mysql_result there are also a number of tutorials if you simply google the phrase "using mysql with php".
  5. i'm aware of what you're trying to do; it just doesn't seem you're actually interested in learning how, you appear to just want a chunk you can copy/paste. and frankly, that doesn't do anyone any good, because if it suddenly needs to be changed, you'll just come back instead of understanding how to change it yourself. teach a man to fish and all that. anyway, in the interest of solving this thread, you need (as i mentioned) an if-else statement: if (isset($_GET['id'])) { $where_clause = "WHERE ID='{$_GET['id']}'"; } if (isset($_GET['county'])) { if (empty($where_clause)) $where_clause = "WHERE County='{$_GET['county']}'"; else $where_clause .= " AND County='{$_GET['id']}'"; } echo $where_clause; now here's where your homework is: you need to find out how to get $where_clause in the correct spot to make the query work correctly. it's worth mentioning that this isn't validating the input at all, leaving your script extremely vulnerable to attacks.
  6. i would guess that with this setup, the most straightforward method would be with PHP, given the amount of control structures required. have you investigated the preorder tree traversal structure for your data? MySQL has a good article on it. it makes querying for the data you're after a much simpler affair, but of course it requires that you restructure your model. i'm ready to be chastised for saying this, but i think for using the old parent_id structure, using either PHP or SQL would have similar performance if you simply manage your database connections and resultsets wisely.
  7. if you want the honest truth, what you're doing wrong is trying to edit a script without any understanding whatsoever of what the current script is doing.
  8. well, you're already grabbing the lastexport column's value in the query you use to get the markets in the first place: SELECT * FROM markets WHERE export=1 ORDER BY market unless i'm mistaken about where that column resides.
  9. yes - that's what your whole parenthesized portion of the query is: short-hand notation for an if-else conditional block. if you don't understand what if/else statements are, you need to read the PHP manual section on Control Structures. if you don't understand those, you can't possibly hope to string together a proper query based on URL variables.
  10. ... no. you should be writing each query out, on its own, without any HTML formatting or semicolons in the string, and running it as an individual query. right now you're trying to feed it a string that looks like this: QUERY HERE;<br />QUERY HERE;<br />QUERY HERE;<br /> you need to be giving it JUST the: QUERY HERE portion. EDIT: beaten to the punch, but this has a bit more info.
  11. exactly: WHERE registration_datetime > DATE_SUB(lastexport, INTERVAL 3 MINUTE) since you're starting to play with dates and times, be sure to have a look in the MySQL manual's section on Date and Time Functions, as there are a slew of very handy functions that you can use right in your queries.
  12. the formatting you've got there is extremely convoluted. why not break it out and use some proper if()-else blocks and see if you can get it working that way?
  13. if you want greater than single-day resolution in the operations, you will need to change the user's registration date columns to a DATETIME format. in order to try to avoid orphaning, you may want to add a padding (say, maybe 5 minutes' worth) for the time it takes to actually run the excel export as well.
  14. you're trying to run a query that contains HTML formatting (those <br /> tags). as well, mysql_query only takes one query, so you can't pass it a string with several queries separated by semicolons.
  15. actually, you would add it at the end - you don't want to update the lastexported column until the export has actually completed (which isn't until after those two closing braces). you may also want to adjust the query to only update the lastexported column for the markets with an export value of 1. don't forget to adjust the SELECT query for the users to include the lastexported value - remember, you only want to select users that have registered since the date/time in that column.
  16. it's tough to say without knowing the application that you're trying to install - the error seems to be in the code for the application itself. i'm moving this to third-party applications, as that is where the issue is.
  17. you should be able to store the resultset within an array regardless of how many records are in the set: $master_data_set = array(); while ($myrow1 = mysql_fetch_array($result1)) $master_data_set[] = $myrow1; then, when you need to go through the info, rather than running the query and using a while() loop, simply run a foreach() loop on $master_data_set. this saves you from having to query the database and have it return the same resultset.
  18. run through the query a single time, store the data into an array, and then use the array to re-display your data.
  19. i take it your definition of "new" is simply "new registrations since last export"? if that's the case, then your best bet is indeed to have a `last_exported` column in your markets table with the format DATETIME and update it each time that market's users have been exported. then it's simply a matter of selecting WHERE `date_registered` > `last_exported`. i'm not sure how you intend to run these exports, or what the `export` column's specific significance is (ie. does it mean "export on the next script run," or "export everytime the script runs").
  20. the MySQL manual has some good information on syntax. there are also a bunch of tutorials online to help you with simple query syntax, so google works wonders. WHERE ID='blah' AND County='blah'
  21. one option would be to add to the pattern to match any number of non-end-brace characters so that it matches up until the end of the braced section: '/((?:{module title\="((?:[a-zA-Z0-9_ ]*))" action\="((?:[a-zA-Z0-9_ ]*))"[^}]*\}))/i' i'm not a regex guru, so you might need to escape that end brace in the character set i've added. EDIT: wasn't paying close enough attention. see JAY's post.
  22. look in the MySQL manual at the DATE_FORMAT() function, which does exactly what you're asking. a script with that few lines is not a problem to paste here, and is easier to read here than having to jump to another link. please post in the forum for small scripts like this in future.
  23. the manual offers the answer: mysql_fetch_array the function will return an array with both numerical and string indexes for each column. use the optional $result_type flag to restrict it to one type or the other.
  24. if your problem was fixed by adding those quotes, please make sure to mark this as solved.
  25. your conditions are incorrectly written: if ($sort=0) you're evaluating whether $sort=0 is true. it always will be, since you're just checking whether $sort can be successfully assigned a value of 0. if you want to COMPARE the values, you need to use two equal signs. read up in the PHP manual on operators.
×
×
  • 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.