Jump to content

Barand

Moderators
  • Posts

    24,563
  • Joined

  • Last visited

  • Days Won

    822

Everything posted by Barand

  1. In your dropdown, even thought the times are displayed as 7:00pm, store the option values in hh:ii:ss format EG <option value='19:00:00' selected>7:00pm</option>
  2. I have altered the structure of the array so they are grouped by sportname/tournamentname/matchname. Makes it nice and easy to loop through the structure. $xml = simplexml_load_string($str); $acopy = array(); /********************************** * Build the array ***********************************/ foreach ($xml->match as $match) { $acopy[(string)$match->sportname][(string)$match->tournamentname][(string)$match->matchname]['time'] = (string)$match->thetime; foreach ($match->linkset->link as $link) { $acopy[(string)$match->sportname][(string)$match->tournamentname][(string)$match->matchname]['links'][] = array( (string)$link['channelname'], (string)$link['kbps'], (string)$link['lang'], (string)$link ); } } /********************************** * Output the array ***********************************/ foreach ($acopy as $sportname => $sportarray) { echo "$sportname<br><br>"; foreach ($sportarray as $tournament => $tournarray) { foreach ($tournarray as $match => $matcharray) { echo "$tournament - $match<br>"; foreach ($matcharray['links'] as $linkarray) { echo join(' : ', $linkarray) . '<br>'; } echo '<br>'; } } }
  3. 1. The option values should be 7, 28 and 180 and not the text descriptions <option value='7'>Seven</option> 2. You need to test if the $_GET data exists (ie has the form been submitted) $days = isset($_GET['days']) ? intval($_GET['days']) : 7; // sets seven as the default
  4. UPDATE details d1 LEFT JOIN details d2 ON d1.pro_id = d2.pro_id AND d2.fie_id = 2 SET d1.value = CASE WHEN d2.value IS NULL THEN d1.value ELSE CONCAT(d1.value, ',', d2.value) END WHERE d1.fie_id = 6;
  5. you need to have defined the "alt" class in the styles eg <html> <head> <style type="text/css"> table { border-collapse: collapse; } tr { background-color: #CCCCCC; } tr.alt { background-color: #C0FFC0; } </style> </head> <body> <table border="1" cellpadding="4" cellspacing="0"> <?php $c = 'A'; for ($row=0; $row<6; $row++) { $cls = $row%2 ? '' : "class='alt'"; echo "<tr $cls>"; for ($col=0; $col<3; $col++, $c++) { echo "<td>$c</td>"; } echo "</tr>\n"; } ?> </table> </body> </html>
  6. If $days is the value selected from your dropdown, then your query will be like $days = intval($_GET['days']); $query = "SELECT account, amount, date FROM transaction WHERE date BETWEEN CURDATE() - INTERVAL $days DAY AND CURDATE()";
  7. If you are talking about the DATE field type, then you don't have to change it. BUT, if you don't you'll be forever reformatting it with STR_TO_DATE() in every query that does anything useful with it (comparing dates, sorting by date, using datetime functions etc). For currency fields use type DECIMAL with 2 dec. places defined rather than FLOAT
  8. Just to add to Irate's reply, if you are using floats then rather than test for equality you have to test that the difference is small enough to be considered acceptably close. $a = 0.1; $b = 0.2; $c = 0.3; echo ($a + $b === $c) ? 'TRUE' : 'FALSE'; // FALSE echo ($a + $b - $c < .000001) ? 'TRUE' : 'FALSE'; // TRUE
  9. if what key exists? array_key_exists Time you turned error reporting on!
  10. If in one you are accumulating then rounding, but in the the other you are rounding then accumulating, maybe.
  11. You are attempting to insert PlayerX into the table when there is already a PlayerX in the table - as the error message says.
  12. what is the "other query"?
  13. If you are paginating then you will have LIMIT X, Y in your query. Instead of setting $pos = 1, set it to $pos = X+1
  14. why don't you try that
  15. try $sql = "SELECT o.ord_id, o.customer_type, CASE customer_type WHEN 1 THEN c.details WHEN 0 THEN nc.details END as details FROM orders o LEFT JOIN non_customer nc ON o.cust_id = nc.cust_id LEFT JOIN customer c ON o.cust_id = c.cust_id";
  16. In the code above you have $row['psc_int'] = $row['psc'] * $arr_currency[$row['partner_share_currency']]; with no mention of venzo_xe table or backrate values. Whereas in the query I was helping with you had SUM((extended_partner_share_currency * x.backrate) * 0.80) as annual_psc FROM venzo_app_sales s JOIN venzo_xe x ON x.code = s.partner_share_currency ???
  17. The R should be in quotes == 'R' Putting a customer id in the invoice table would have been a better idea
  18. Does the order table have a customer id to relate to the other tables? If they are a non_customer is there still a customer ID. How about sharing your table structures
  19. The dates listed in your dropdown were m/d/y, eg 3/15/2012 - 3/31/2012. However it is better if the value of the dropdown is y-m-d format so it can be used in queries without reformatting, so you would have something like <option value="2012-03-15">3/15/2012 - 3/31/2012</option> Easiest way is select the start_date twice eg SELECT start_date as rawdate, FORMAT_DATE(start_date, '%m/%d/%Y') as sdate, .....
  20. http://en.wikipedia.org/wiki/Sort_algorithms
  21. SQL queries don't do any indenting. Remove what formatting? Keep dates in db tables as YYYY-MM-DD. Apply any formatting required either in the query (as above) or on output using PHP
  22. Give us a clue and post the entire error message
  23. This will get you the annual totals instead of value from first SELECT YEAR(s.start_date) as Year, annual_psc, DATE_FORMAT(start_date, '%m/%d/%Y') as s_date, DATE_FORMAT(end_date, '%m/%d/%Y') as e_date FROM venzo_app_sales s INNER JOIN venzo_user_apps a ON s.title = a.appname INNER JOIN ( SELECT YEAR(start_date) as yr, SUM((extended_partner_share_currency * x.backrate) * 0.80) as annual_psc FROM venzo_app_sales s JOIN venzo_xe x ON x.code = s.partner_share_currency JOIN venzo_user_apps a ON s.title = a.appname WHERE a.uid = 1 GROUP BY yr ) as tot ON YEAR(s.start_date) = tot.yr WHERE a.uid = 1 ORDER BY Year DESC, start_date DESC;
×
×
  • 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.