Jump to content

Barand

Moderators
  • Posts

    24,563
  • Joined

  • Last visited

  • Days Won

    822

Everything posted by Barand

  1. Could be problems in your data. For example, if one of the tables had spaces at the end of the revenue_dep then it wouldn't match that in the other table.
  2. What does that mean?
  3. for ($year = $endYear; $year >= $startYear; $year--) Reverse your for loop
  4. Before I do, tell me why you would write a php script using separate lines and indents to make it structure readable, but you write sql code on one line, disappearing off to the far distance?
  5. Try this. You don't need date arithmetic for years. $start = 2020; $end = 2029; for ($y=$start; $y<=$end; $y++) { $session = sprintf('%d-%d', $y, $y+1); echo $session . '<br>'; } output 2020-2021 2021-2022 2022-2023 2023-2024 2024-2025 2025-2026 2026-2027 2027-2028 2028-2029 2029-2030
  6. Just use bcadd() with a foreach loop $total = 0; $numbers = array( '9780393872439', '9780134130422', '30.50' ); foreach($numbers as $num) { $total = bcadd($total, $num, 2); } echo $total ; // 19560528002891.50
  7. MY (reduced number of colours) take on your problem - using SVG for the gradients Code... <?php function disc($col, $name) { $cd = colourDarker($col); $cl = colourLighter($col); return "<svg width = '50' height='50'> <defs> <linearGradient id='grad' x1='0' x2='1' y1='0' y2='0'> <stop offset='0.1' stop-color='$cd'/> <stop offset='0.85' stop-color='$cl'/> </linearGradient> </defs> <circle cx='25' cy='25' r='24' fill='url(#grad)' /> <circle cx='25' cy='25' r='17' fill='$col' fill-opacity='0.4' stroke='$cl' stroke-width='2' class='disc' data-name='$name'> <title>$name</title> </circle> </svg> "; } function colourDarker($colour) { $lc = strlen($colour); $format = $lc==4 ? '#%1x%1x%1x' : '#%2x%2x%2x'; $rgb = sscanf($colour, $format); foreach ($rgb as $k=>&$v) { if ($lc==4) { $v = $v*16+$v; } $dv = min($v,0x66); $v -= $dv; } return vsprintf('#%02X%02X%02X', $rgb); } function colourLighter($colour) { $lc = strlen($colour); $format = $lc==4 ? '#%1x%1x%1x' : '#%2x%2x%2x'; $rgb = sscanf($colour, $format); foreach ($rgb as $k=>&$v) { if ($lc==4) { $v = $v*16+$v; } $dv = min(255-$v,0x66); $v += $dv; } return vsprintf('#%02X%02X%02X', $rgb); } ?> <html> <head> <title>Example</title> <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> <script type='text/javascript'> $(function() { $(".disc").click(function() { let name = $(this).data('name') $("#namecolor").css('color', name).val(name) $(".disc").parent().css('border','1px solid #000') $(this).parent().css('border','1px solid #ccc') }) }) </script> <style type='text/css'> #cpicker { width: 500px; margin: 50px auto; background-color: #000; color: white; text-align: center; } #nctable { width: 200px; margin: 0 auto; /*background-color: black; color: white;*/ } #sctable { width: 100%; background-color: black; color: white; border-top: 2px solid white; } td { text-align: center; } .hotspot { fill: #fff; fill-opacity: 0.4; stroke: #FFF; cursor: pointer; } .title, th { font-variant: small-caps; } .rounded { background-color: #ccc; border-radius: 15px 15px; height: 36px; width: 340px; padding: 0 15px; font-size: 24pt; } </style> </head> <body> <header> <h1>Example</h1> </header> <form id='form1' method='post'> <div id='cpicker'> <h3 class='title'>Name Color</h3> <table id='nctable'> <tr><td><?= disc('#0000ff', 'Blue') ?></td> <td><?= disc('#ff0000', 'Red') ?></td> <td><?= disc('#00ff00', 'Green') ?></td> </tr> <tr><td><?= disc('#8B0000', 'DarkRed') ?></td> <td><?= disc('#000000', 'Black') ?></td> <td><?= disc('#ff69b4', 'HotPink') ?></td> </tr> </table> <table id='sctable'> <tr><th>Current&nbsp;Color</th> <th>New Selected Color</th> </tr> <tr><td><?= disc('#000000', 'Black') ?></td> <td><input type='text' class='rounded' name='namecolor' id='namecolor' value=''></td> </tr> </table> </div> </form> </body> </html>
  8. I don't know what gap you refer to but the line of code you posted needs changing to <?php echo '<pre>'; print_r($_POST, true); echo '</pre>'; ?> ^^^^ The "true" ( or you can use '1') prevents print_r() from returning a value after it has output the array. Ignore - as it was all on one line I assumed it was all one statement. But as print_r() is a debugging tool, why don't you just remove the line?
  9. I tried the image map example in the above link. When I double the image size (by adding width="700" to the image tag) the image map circles remain at their original sizes and positions, so not scaling with image. Using SVG, they did scale and reposition correctly. (Coloured borders added to circles to view) Example code... <html> <head> <title>Example</title> <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> <script type='text/javascript'> $(function() { $(".hotspot").click(function() { let page = $(this).data('href') window.open ("https://developer.mozilla.org/docs/Web/" + page) }) }) </script> <style type='text/css'> .hotspot { fill: #fff; fill-opacity: 0; stroke: #F0F; } </style> </head> <body> <!-- Normal size image --> <svg width='25%' viewBox='0 0 350 150'> <image x='-30' y='0' href="parrots.jpg" width="360" height="150" preserveAspectRatio/> <circle cx='70.5' cy='75' r='50' class='hotspot' data-href="JavaScript" /> <circle cx='233' cy='75' r='50' class='hotspot' data-href="CSS" /> </svg> <br> <!-- Double size image --> <svg width='50%' viewBox='0 0 350 150'> <image x='-30' y='0' href="parrots.jpg" width="360" height="150" preserveAspectRatio/> <circle cx='70.5' cy='75' r='50' class='hotspot' data-href="JavaScript" /> <circle cx='233' cy='75' r='50' class='hotspot' data-href="CSS" /> </svg> </body> </html> P.S. Another option you may want to consider for this application is the Google Maps API.
  10. Try <img src="btn/colorpicker/darkred.png" onClick= "document.forms[0].name_pref.value = 'darkred'" class="pointer clrimg"> <img src="btn/colorpicker/yellow.png" onClick= "document.forms[0].name_pref.value = 'yellow'" class="pointer clrimg"> <img src="btn/colorpicker/purple.png" onClick= "document.forms[0].name_pref.value = 'purple'" class="pointer clrimg"> <input type="text" name="name_pref" style="font-size: 24px;" value="">
  11. $total = 0; // add this line to define $total before trying to increment $numbers = array( '9780393872439', '9780134130422', '30.50' ); foreach($numbers as $num) { $total += $num; } echo $total ; And why are you defining the numbers as string values?
  12. What does this code outputif you put it in the while loop? var_dump($do_not_duplicate);
  13. Perhaps create an array then json_encode it EG $user_id = 1234; $data = [ 'user_id' => $user_id , 'name' => 'John Doe' , 'card' => 0 ]; CURLOPT_POSTFIELDS => json_encode($data),
  14. You are executing a query passing two bound parameter values, but your query has no placeholders for those parameters.
  15. Start by looking at the array structure you are working with... echo '<pre>' . print_r($ch, 1) . '</pre>';
  16. Put this line just before you create $connection... mysqli_report(MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT); ... to report any problems with your queries.
  17. The first fetch() will return false if no records were found. if ($result->fetch_assoc()) { // ticket found } else { // ticket not found }
  18. That's already been done (twice). I suggest you learn to read before embarking on a programming career.
  19. From the link requinix gave you to the preg_match_all() function in the manual ...
  20. I what universe is that two subqueries joined on category? SELECT act.category , target , actual FROM ( -- subquery 1 SELECT category , sum(quantity) as actual FROM tiv_data WHERE brand = 'XCMG' AND dealerid = 81019218 GROUP BY category ) act JOIN ( -- subquery 2 SELECT category , sum(total) as target FROM currentyeardata WHERE dealerid = 81019218 GROUP BY category ) targ USING (category);
  21. You may have to resort to subqueries subquery 1 - total actual for each category subquery 2 - total target for each category join the subqueries using category to get final result.
  22. PHP and JS scripts run in different space-time dimensions... PHP runs on server and sends output to client browser, then client browser runs the JS script Solutions: Ask Google to change their charts api to output the dropdown for you, or Write you own code to creat pie chart (using SVG or Canvas), or Create div with border. Put dropdown and google chart (without border) inside this div.
  23. The best way to find out is to test it. Run it Check it This looks like deja vu! https://forums.phpfreaks.com/topic/317078-issue-generating-student-class-position-based-on-the-grand-exam-score/?do=findComment&comment=1610463
  24. Plus, if you are accessing $_SESSION, then you need session_start() at the top of the script. Also errors in the query You are trying to match the value in column myid with the string value 'myid' You are trying to order the results by the string value 'id'
×
×
  • 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.