Jump to content

kickstart

Staff Alumni
  • Posts

    2,707
  • Joined

  • Last visited

Everything posted by kickstart

  1. Hi Can't see anything obvious (but not sure why you are using array_count_values). Could you try doing the following:- echo '<pre>'; print_r($_POST); print_r($_SESSION); echo '</pre>'; Wondering if the session variables have been already wiped out, All the best Keith
  2. Hi Not sure but one problem is the following line:- unset($_SESSION['cart']['$title']) You have $title within single quotes so it is trying to unset an array member with the key of $title rather than the key with the value of $title. However I would expect that to mean nothing gets set to zero rather than the whole cart wiped out. All the best Keith (another ex mainframe programmer)
  3. Hi First thing I would do is put the SQL into a string and echo it out. Then copy that and try it directly on the database. All the best Keith
  4. Hi Afraid I don't know. It works fine using file_get_contents, but I presume the html parser you are using requires the other function. All the best Keith
  5. Hi The problem seems to be that you have an inner loop which doesn't change anything, just keeps checking the same variables. Hence probably an endless loop. What you need to do is store the previous titles (probably just the identity of them), and then only output the titles when the new ones are different to the previous ones. All the best Keith
  6. Hi Using a normal file_get_contents brings back the contents. Afraid I have no experience of simplehtmldom to suggest anything on that. All the best Keith
  7. Hi Looking at the source of the page you are grabbing I am not sure it is valid HTML Rather than having:- <img it has < All the best Keith
  8. Hi Something like this SELECT users1.blah, COALESCE(a.somecol,b.anothercol,c.fredscol) AS FirstCol , COALESCE(a.joescol,b.lolcol,c.billscol) AS SecondCol FROM users LEFT OUTER JOIN regular_user_details details a LEFT OUTER JOIN business_user_details details b LEFT OUTER JOIN escort_user_details details c However seems a lot of effort to avoid returning a load of null rows. All the best Keith
  9. Hi Using a Mac at the moment and no real way to test this so almost certainly a load of typos. However something like this should work. Hopefully you can get the idea. <?php # Load Title echo '<div class="title" id="t_forum">Forums</div>'; # Get Forum Names & Info $q_forums = query("SELECT a.id AS aid, a.title AS atitle, b.id AS bid, b.title AS btitle, b.descr, COUNT(c.id) AS topicCount FROM forum a LEFT OUTER JOIN forum b ON a.id = b.parent AND a.parent = '0' and a.sub = '0' AND b.sub = '1' LEFT OUTER JOIN topic c ON b.id = c.id AND c.blog = '0' AND c.del = '0' ORDER BY a.ord, b.ord"); # Display echo '<table cellpadding="0" cellspacing="0" border="0" <tr><th>Forums</th><th class="center">Topics</th></tr>'; # Get Forum:Title Data $PrevAid = 0; while($d_forums = mysql_fetch_array($q_forums)) { if ($PrevAid != $d_forums['aid']) { if ($PrevAid != 0) { echo '<tr><td></td><td></td></tr><tr><td></td><td></td></tr>'; // Spacing between categories } echo '<tr><td class="forum_titledescr"><span class="forum_title" style="font-size:16pt;">'.$d_forums['atitle'].'</span></td><td class="forum_topiccount"></td></tr>'; $PrevAid = $d_forums['aid']; } # Get Forum:Forum Data echo '<tr class="row"> <td class="forum_titledescr"><a href="forum.php?id='.$d_forums['bid'].'"><span class="forum_title" id="spacer">'.$d_forums['btitle'].'</span><span class="forum_descr"> - '.$d_forums['descr'].'</span></a></td> <td class="forum_topiccount">'.$d_forums['topicCount'].'</td> </tr>'; if ($PrevAid != $d_forums['aid']) { echo '<tr><td></td><td></td></tr><tr><td></td><td></td></tr>'; // Spacing between categories $PrevAid = $d_forums['aid']; } } if ($PrevAid != 0) { echo '<tr><td></td><td></td></tr><tr><td></td><td></td></tr>'; // Spacing between categories } echo '</table>'; # Load Footer require('inc/frag/footer.php'); ?> All the best Keith
  10. Hi Err, just realised. You mention a hidden field but that suggests a form POST variable rather than a GET one. All the best Keith
  11. Hi Really think that doing this is just making code that will be a nightmare to read for no real purpose. Think you would need a separate case statement for each column. All the best Keith
  12. Hi Try putting the AS after the END, using a common name for both. You will also need both tables SELECT z_users.account_type, CASE WHEN z_users.account_type = 1 THEN z_user_details.name ELSE z_business_details.company END AS someName FROM z_users LEFT JOIN z_user_details ON z_user_details.id1 = z_users.id LEFT JOIN z_business_details ON z_business_details.id1 = z_users.id WHERE z_users.id = 1 All the best Keith
  13. Hi Can't see how that would work. If this was possible (and fairly certain it isn't) then the syntax would be something like SELECT * FROM users INNER JOIN CASE users.usertype WHEN 1 THEN SELECT * FROM regular_user_details WHEN 2 THEN SELECT * FROM business_user_details END CASE WHERE users. id = 1 But even if it did work it would probably result in fairly hideous php to go with it. I would either do the JOIN, or just set up different selects If if the columns you require from the other tables are consistent SELECT users1.blah, details.someotherblah FROM users INNER JOIN regular_user_details details UNION SELECT users1.blah, details.someotherblah FROM users INNER JOIN business_user_details details UNION SELECT users1.blah, details.someotherblah FROM users INNER JOIN escort_user_details details All the best Keith
  14. Hi Don't think it is possible. Probably be easier to just dynamically build separate queries for each one as each is going to need to have separate processing to cope with the different numbers of columns. All the best Keith
  15. Hi CONCAT is a string function and not sure what you are trying to use it for there. Also you have some extra brackets. Splitting a column into 2 is very possible. All the best Keith
  16. Hi Possible but messy as you will have different numbers of columns returned depending on the type of user. You could do this:- SELECT * FROM users LEFT OUTER JOIN regular_user_details ON users.id = regular_user_details.userid LEFT OUTER JOIN business_user_details ON users.id = business_user_details.userid Obviously this will return columns from both tables, with null values in the columns that do not match that rows user type. If you do this make sure you specify the columns rather than just use SELECT * All the best Keith
  17. Hi Table locking should do the job for you:- http://dev.mysql.com/doc/refman/5.0/en/lock-tables.html The other operations should just wait. All the best Keith
  18. Hi Using the scheme you already have SELECT URL, COUNT(Keyword) AS KeywordCount FROM KeywordTable WHERE Keyword IN ('Martial', 'Arts') GROUP BY URL ORDER BY KeywordCount All the best Keith
  19. Hi Something like this should do it (not tested, so probably some typos) SELECT Last7Days.aDay, COUNT(topics.id), COUNT(users.registerdate) FROM (SELECT DATE_ADD(NOW(), INTERVAL (-1*i) DAY) AS aDay FROM integers WHERE i BETWEEN 0 AND 6) Last7Days LEFT OUTER JOIN topics ON Last7Days.aDay = DATE(FROM_UNIXTIME(topics.topicDate)) LEFT OUTER JOIN users ON Last7Days.aDay = DATE(FROM_UNIXTIME(users.registerdate)) GROUP BY Last7Days.aDay Relies on a table of integers from 0 to 9. All the best Keith
  20. Hi How do you know which number of days to add to which row? I would guess that you have them stored on a different table. If so you probably want to do a JOIN within the UPDATE statement. Something like:- UPDATE FROM customer AS c LEFT JOIN someOtherTable as s ON c.blah = s.blah SET c.ServiceDate` = DATE_ADD('1900-01-01', INTERVAL s.SomeDayCount DAY) All the best Keith
  21. Hi You could also use a JOIN SELECT DISTINCT table1.id FROM table1 LEFT OUTER JOIN table2.id WHERE table2.id IS NULL Used to be far more efficient to do it this way, but think with newer versions of MySQL the 2 methods are far more evenly matched. All the best Keith
  22. Hi Last place I worked landed up with us in the IT section pushed into documenting everything that moved until it stopped moving. Inevitably the users started writing their own Access database based systems as it was way too hard to get IT to do anything . The query builder is a nightmare though. Anyway, to the OP, why do you need to avoid operators? Is the date you are checking in a date field? You could use between (but to my mind, just like an operator). You could hide the check off in a custom function, but that really just hides the operators. You could use datediff. All the best Keith
  23. Hi Yep, reliability. Or its lack of it. It does have a place, but really that is just as something a step up from Excel for single user use, and no way does such use justify a proper database. A few years back I had to use Access to backup and system that was soon to be dead. Data just needed for occasional use. About half a million records. I knocked up a script to load the data in which worked fine in testing. Came to use it for real and at about 45k records it would roll over and die, but not on any particular record. Access basically tripped over its own feet. The solution? Every 10k records I coded a 10 second wait to allow the data the be safely written to the database. Not sure that its SQL being different is something that can really be complained about as there is so much difference between all the flavours anyway. However how restrictive it is (and how it struggles with any kind of mildly complex table join without resorting to views) is a major pain. All the best Keith
  24. Hi Access can do relational stuff and has no problems with relational operators. It is just its reliability and dodgy syntax that shoots it down. All the best Keith (who has the misfortune to have to use Access with MySQL on a regular basis)
  25. Hi Had a play and think this will do it:- SELECT AllDays, AVG(open), AVG(high), AVG(low), AVG(close) FROM nse_eod_equity_data CROSS JOIN ( SELECT DATE_ADD(MinDate, INTERVAL NumDays DAY) AS AllDays, DATE_ADD(MinDate, INTERVAL NumDays-5 DAY) AS AllDays5, MinDate, MaxDate FROM ((SELECT a.i+b.i*10+c.i*100 AS NumDays FROM integers a, integers b, integers c) Deriv1 INNER JOIN (SELECT MIN(_date) AS MinDate, MAX(_date) AS MaxDate FROM nse_eod_equity_data) Deriv2) HAVING AllDays BETWEEN MinDate AND MaxDate) Deriv4 WHERE _date BETWEEN AllDays5 AND AllDays GROUP BY AllDays This is using a table called integers (one column called 1, 10 rows with values of 0 to 9) to generate a number between 0 and 999 (can easily be extended). This is JOINed to a select of the min an max dates on nse_eod_equity_data to get every date between them. This way it will give a figure for the 23rd and 24th despite them not being in the original list. Also gives the day minus 5 days to get the date range for the average. This is then CROSS JOINed with the original table with the result narrowed down to be between the date returned and the date 5 days before it. Then uses AVG on the various columns to get the 5 day rolling average. Seems to work on a test table All the best Keith
×
×
  • 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.