Jump to content

Barand

Moderators
  • Posts

    24,563
  • Joined

  • Last visited

  • Days Won

    822

Everything posted by Barand

  1. Why the " * 0.80" in SUM((extended_partner_share_currency * x.backrate) * 0.80) as total_psc,
  2. Is there and attorneyid in the attorney positions table?
  3. Table structure? How are those three tables related?
  4. As I said, no output from INSERT, UPDATE or DELETE queries. Listing the arrays would show which recs were inserted and deleted
  5. You were asked for the name too!
  6. Check the value of $conn->error after executing the query
  7. Not at all With a single file it would be "UPDATE filename SET a = b". The filename in this case is a JOIN expression
  8. semi-colons missing from the ends of both mysql_query() lines
  9. Insert and delete queries do not return rows $result = mysql_fetch_array($query) or die(mysql_error()); should be mysql_query($query) or die(mysql_error()) String values need to be in single quotes $query = "DELETE FROM adkats_accesslist WHERE player_name = '$old' "; mysql_query($query); Plus the above needs to be inside the loop Also it is inefficient to run queries inside loop
  10. Bear in mind I don't know the table data structure but it looks like you need two queries similar to these to complete the task INSERT INTO adkats_accesslist (player_name, member_id, player_email, access_level) SELECT rp.player_name, 0, 'NoEmail', 5 FROM reservedPlayers rp LEFT JOIN oldReservedPlayers orp ON rp.player_name = orp.player_name AND orp.access_level = 5 WHERE orp.player_name IS NULL DELETE adkats_accesslist FROM adkats_accesslist JOIN ( SELECT orp.player_name FROM oldreservedPlayers orp LEFT JOIN reservedPlayers rp ON rp.player_name = orp.player_name AND rp.access_level = 5 WHERE rp.player_name IS NULL ) as players USING (player_name)
  11. Don't put column names in quotes, it treats them as a string value if you do
  12. try $q = "update tms_test_matchdata p join (select m.* from tms_test_matchdata m where m.Tourn_key='$tourn_key' and m.Printed is null) s on p.Tourn_key=s.Tourn_key and p.Eventcode=s.Eventcode and p.MatchId=s.MatchId set p.Printed='Y'";
  13. Easiest way, probably, is to concatenate the two fields and store those in an array. Then, for example $keys = array ('FldA1FldB1', 'FldA2FldB2', 'FldA3FldB3'); // stored concatenated values $keylist = join("','", $keys); $sql = "UPDATE tablename SET FldC = 'x' WHERE CONCAT(FldA, FldB) IN ('$keylist') ";
  14. Do the records from you original select query have unique record ids? If so, you could store those ids in an array and use the array to define the rows to be updated
  15. Just for topic completion I am posting a solution using the revised array format $tHead = "<table cellpadding='5' border='1' style='border-collapse: collapse'> <tr><th>County</th><th>Mean</th><th>Median</th><th>Mode</th></tr>\n"; $tFoot = "</table><br><br>\n"; foreach ($newdata as $name => $arr) { echo "<strong>$name</strong><br>$tHead"; foreach ($arr as $row) { echo "<tr><td>" . join('</td><td>', $row) . "</td></tr>\n"; } echo $tFoot; }
  16. At top, put $db = new mysqli('HOST', 'USERNAME', 'PASSWORD', 'DATABASE'); // substitute your values You can do the currency conversion in the query eg ... , SUM(currency * conversion_rate) as total_psc
  17. A better array structure to start from would have helped. If your array is $data, then this will transform to an easier array for your task $newdata = array(); foreach ($data as $prod) { $newdata[$prod['product']['name']][] = array_slice($prod['product'],1); } echo '<pre>',print_r($newdata, true),'</pre>'; /** RESULTING ARRAY ***************************** Array ( [1004 URAR] => Array ( [0] => Array ( [county] => KENT [mean] => 366.67 [median] => 375 [mode] => 375 ) [1] => Array ( [county] => NEW CASTLE [mean] => 360 [median] => 375 [mode] => 375 ) [2] => Array ( [county] => SUSSEX [mean] => 378.57 [median] => 375 [mode] => 375 ) ) [1004 URAR W MC & UAD] => Array ( [0] => Array ( [county] => KENT [mean] => 0 [median] => 0 [mode] => 0 ) [1] => Array ( [county] => NEW CASTLE [mean] => 0 [median] => 0 [mode] => 0 ) [2] => Array ( [county] => SUSSEX [mean] => 0 [median] => 0 [mode] => 0 ) ) [1073 CONDO] => Array ( [0] => Array ( [county] => KENT [mean] => 370.83 [median] => 375 [mode] => 375 ) [1] => Array ( [county] => NEW CASTLE [mean] => 305.65 [median] => 375 [mode] => 375 ) [2] => Array ( [county] => SUSSEX [mean] => 375 [median] => 400 [mode] => 400 ) ) ) ***********************************************/
  18. Perhaps a little code and table structures would give us more information about you are trying to do. Is fieldC in different table from the first query, for instance?
  19. Not too sure yet exactly what you are trying to achieve. Does this come anywhere close (I'm assuming your dates have been converted to yyyy-mm-dd) $uid = 1; // set this from your session var $sql = "SELECT YEAR(start_date) as Year , MONTH(start_date) as Month , SUM(extended_partner_share_currency) as total_psc FROM venzo_app_sales s INNER JOIN venzo_user_apps a ON s.title = a.appname WHERE a.uid = $uid GROUP BY Year, Month WITH ROLLUP"; $res = $db->query($sql); $prevYr = 0; echo "<table border=1>\n"; echo "<tr><td>Year</td><td>Month</td><td>Total PSC</td></tr>\n"; while ($row = $res->fetch_assoc()) { if (is_null($row['Year'])) { $yr = "All years "; } elseif ($row['Year']== $prevYr) { $yr = ' '; } else { $yr = $row['Year']; } $mth = is_null($row['Month']) ? 'Total' : $row['Month']; echo "<tr><td>$yr</td><td>$mth</td><td>{$row['total_psc']}</td></tr>\n"; $prevYr = $row['Year']; } echo "</table>\n"; results attached
  20. Sorry about those 2 lines, I have those automatically in my php files as nearly all are DB related. Are pigeon.php and the file with the image tag in the same folder - it was definitely working when it left the factory. (sample attached)
  21. The strings are enclosed in double quotes (") you specify single quote (') in while ($data = fgetcsv($handle,100000,",","'")) You could just use default values as in while ($data = fgetcsv($handle,100000))
  22. do you mean something like this? $xml = simplexml_load_string($str); $acopy = array(); foreach ($xml->match as $match) { $acopy[(string)$match->matchname]['sportname'] = (string)$match->sportname; $acopy[(string)$match->matchname]['tournamentname'] = (string)$match->tournamentname; $acopy[(string)$match->matchname]['time'] = (string)$match->thetime; foreach ($match->linkset->link as $link) { $acopy[(string)$match->matchname]['links'][] = array( (string)$link['channelname'], (string)$link['lang'], (string)$link['kbps'], (string)$link ); } } echo '<pre>',print_r($acopy, true),'</pre>'; result Array ( [Town Rovers vs Chanel] => Array ( [sportname] => Football [tournamentname] => Red League [time] => 201311021245 [links] => Array ( [0] => Array ( [0] => Link 1 [1] => en [2] => 300 [3] => link1.html ) [1] => Array ( [0] => Link 2 [1] => en [2] => 350 [3] => link2.html ) [2] => Array ( [0] => Link 3 [1] => en [2] => 320 [3] => link3c.html ) [3] => Array ( [0] => Link 3 [1] => en [2] => 320 [3] => link4.html ) ) ) )
×
×
  • 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.