Jump to content

Barand

Moderators
  • Posts

    24,606
  • Joined

  • Last visited

  • Days Won

    831

Everything posted by Barand

  1. Here's an example to get you started <?php function svgHead($txt) { $svg = "<svg class='longhead' width='150' height='100'> <style type='text/css'> .headtext { font-size: 11pt; fill: orange; } </style> <path d='M 0 100 l 40 0 l 100 -100 l -40 0 Z' fill='black' /> <text x='35' y='95' class='headtext' transform='rotate(-45, 35, 95 )'>$txt</text> </svg> "; return $svg; } ?> <style type='text/css'> div.outer { border: 1px solid black; height: 105px; } svg.longhead { margin: -50px; position: relative; top: 35px; left: 50px; } </style> <div class='outer'> <?= svgHead('Long Heading 1')?> <?= svgHead('Long Heading 2')?> <?= svgHead('Long Heading 3')?> <?= svgHead('Long Heading 4')?> <?= svgHead('Long Heading 5')?> <?= svgHead('Long Heading 6')?> </div> output
  2. The picture you attached is too difficult to see but it sounds like you could use a rotation transform
  3. "SQL select statement" would be a better start. Select statements are not PHP.
  4. Note that my suggested file inputs contain the id in the input name From those two, $FILES array will look something like this, showing those ids as keys in the array. Use those when updating the table. $_FILES = Array ( [myimages] => Array ( [name] => Array ( [2] => ab4567.jpg [4] => bc5678.jpg ) [type] => Array ( [2] => image/png [4] => image/jpeg ) [tmp_name] => Array ( [2] => C:\Windows\Temp\php9A0A.tmp [4] => C:\Windows\Temp\php9A2A.tmp ) [error] => Array ( [2] => 0 [4] => 0 ) [size] => Array ( [2] => 32769 [4] => 13741 ) ) )
  5. Join your tables in q query, matching content with image. Where there is no image (denoted by NULL) output a file input to upload an image. english_version english_gallery +----+---------+--------------+ +------------+----------+------------+ | id | title | content | | gallery_id | image_id | image | +----+---------+--------------+ +------------+----------+------------+ | 1 | Ttile 1 | aaaaaaaa | | 1 | 1 | ab1234.jpg | | 2 | Title 2 | bbbbbb | | 2 | 3 | ab2345.jpg | | 3 | Title 3 | cccccccc | | 3 | 5 | ab3456.jpg | | 4 | Title 4 | dddddd | +------------+----------+------------+ | 5 | Title 5 | eeeeeeeeeeee | +----+---------+--------------+ SELECT v.id , v.title , v.content , g.image FROM english_version v LEFT JOIN english_gallery g ON v.id = g.image_id ORDER BY v.id; query results +----+---------+--------------+------------+ | id | title | content | image | +----+---------+--------------+------------+ | 1 | Ttile 1 | aaaaaaaa | ab1234.jpg | | 2 | Title 2 | bbbbbb | NULL | <input type='file' name='myimages[2]'> | 3 | Title 3 | cccccccc | ab2345.jpg | | 4 | Title 4 | dddddd | NULL | <input type='file' name='myimages[4]'> | 5 | Title 5 | eeeeeeeeeeee | ab3456.jpg | +----+---------+--------------+------------+
  6. I'll send you a
  7. It works if your screen width is >= 775
  8. Bullsh*t. Have you even tried it? Example... $strings = [ "Joe has 5 large apples", "Joe has 5.25 large apples", "Joe has 500 large apples" ]; foreach ($strings as $str) { $number = current( array_filter(explode(' ', $str), 'is_numeric' ) ) ; echo "$str | $number<br>"; }
  9. Try my solution with 5.25
  10. One way <div> <div style='width: 30%; background:#FFC0C0; display: inline-block; padding:8px;'> Div 1 </div> <div style='width: 50%; background:#C0FFFF; display: inline-block; padding: 8px;'> Div 2 </div> </div>
  11. Alternative "sans-regex" solution... $str = "Joe has 5 large apples"; echo current( array_filter(explode(' ', $str), 'is_numeric' ) ) ; // 5
  12. Here is a simple example of what I was trying to explain. The elements to be output are created in the php section and stored in variables. Because they are now stored, they can be output to the page in any order you want (in this case completely different from the order they were calculated) Code <?php $votes = [ 'Archie' => 203, 'Ben' => 406, 'Carol' => 584, 'David' => 398, 'Emily' => 259 ]; $tdata = ''; $total_votes = 0; foreach ($votes as $candidate => $tot) { $tdata .= "<tr><td>$candidate</td><td>$tot</td></tr>"; $total_votes += $tot; } $max_votes = max($votes); $winner = array_keys($votes, $max_votes)[0]; $win_pcent = number_format($max_votes/$total_votes*100, 0); $result = "Winner is $winner with $win_pcent% of the votes"; ?> <!DOCTYPE html> <html lang='en'> <head> <title>sample</title> <meta http-equiv='Content-Type' content='text/html; charset=utf-8'> <script type='text/javascript'> </script> <style type='text/css'> body { background-color: #fbf7e9; } </style> </head> <body> <h2><?= $result ?></h2> <h3>Total votes cast was <?= $total_votes ?></h3> <table style='width: 300px;'> <tr><td><b>Candidate</b></td><td><b>No of votes</b></td></tr> <?= $tdata ?> </table> </body> </html> Output
  13. Are those functions in functions.php used by other scripts or are are they just for this page?
  14. Yes. Arrange your page so all php code comes first followed by the html section which does all the output <?php // call function to populate $statusCounts array // store anything that requires outputting in variables ?> <html> <body> <h2>Completed: <?=$statusCounts['Completed']?></h2> etc </body> </html>
  15. You can't just switch to HTML in the middle of PHP code. Use the code @Phi11W gave you
  16. This, I think https://dev.mysql.com/downloads/installer/
  17. Remove those echo "jpeg"; etc. You can't have output before a header();
  18. It would appear that the variable $username_already_used is empty.
  19. try SELECT r.sponsor , a.tot_sponsor , r.user_id , coalesce(b.tot_user, 0) as tot_user FROM user_referrals r JOIN ( SELECT sponsor , count(*) as tot_sponsor FROM user_referrals GROUP BY sponsor ) a ON r.sponsor = a.sponsor LEFT JOIN ( SELECT sponsor , count(*) as tot_user FROM user_referrals GROUP BY sponsor ) b ON r.user_id = b.sponsor WHERE r.sponsor = :root_sponsor +---------+-------------+---------+----------+ | sponsor | tot_sponsor | user_id | tot_user | +---------+-------------+---------+----------+ | 1 | 3 | 2 | 2 | | 1 | 3 | 3 | 1 | | 1 | 3 | 4 | 0 | +---------+-------------+---------+----------+ user_referrals: +----+---------+---------+ | id | sponsor | user_id | +----+---------+---------+ | 1 | 1 | 2 | | 2 | 1 | 3 | | 3 | 1 | 4 | | 4 | 2 | 5 | | 5 | 2 | 6 | | 6 | 3 | 7 | +----+---------+---------+ PS Alternative solution SELECT sponsor as user_id , count(*) as total , 'Direct' as type FROM user_referrals WHERE sponsor = 1 GROUP BY sponsor UNION ALL SELECT r.user_id , count(r2.sponsor) as total , 'Indirect' FROM user_referrals r LEFT JOIN user_referrals r2 ON r.user_id = r2.sponsor WHERE r.sponsor = 1 GROUP BY r2.sponsor ORDER BY type, user_id; +---------+-------+----------+ | user_id | total | type | +---------+-------+----------+ | 1 | 3 | Direct | | 2 | 2 | Indirect | | 3 | 1 | Indirect | | 4 | 0 | Indirect | +---------+-------+----------+
  20. Except for the sample test data and expected results!
  21. That's OK. I know what the query should look like - I just needed something to test it with. If you can't be bothered to help me to help you then I'll wish you luck.
  22. Can you post some sample data and the results you expect from that data?
  23. This time I have appended table1 and table2 data into a single table (table3) +---------+------------+--------+-------+ | company | sku_number | color | price | +---------+------------+--------+-------+ | ACME | sku12345 | beige | 6.00 | | ACME | sku99999 | pink | 44.00 | | ZUNFXZ | sku12345 | tan | 15.00 | | ZUNFXZ | sku50505 | orange | 7.00 | | ZUNFXZ | sku99999 | red | 30.00 | +---------+------------+--------+-------+ The query simplifies (no unions) to SELECT t3.company , t3.sku_number , t3.color , t3.price FROM table3 t3 JOIN ( SELECT sku_number , MAX(Price) as price FROM table3 GROUP BY sku_number ) max_prices USING (sku_number, price); +---------+------------+--------+-------+ | company | sku_number | color | price | +---------+------------+--------+-------+ | ACME | sku99999 | pink | 44.00 | | ZUNFXZ | sku12345 | tan | 15.00 | | ZUNFXZ | sku50505 | orange | 7.00 | +---------+------------+--------+-------+ NOTE: Table 3 primary key is (sku_number,company) to avoid duplicates
  24. You need to lose the $ signs from your prices and store in numeric type column, such as DECIMAL(10,2). If they are stored as varchar() the sort order will be alphabetical instead of numeric For example mysql> select * from table3 order by price; +------------+--------+--------+ | sku_number | color | price | +------------+--------+--------+ | sku12345 | tan | $15.00 | | sku99999 | red | $5.00 | | sku50505 | orange | $7.00 | +------------+--------+--------+ mysql> select max(price) from table3; +------------+ | max(price) | +------------+ | $7.00 | +------------+ As I told you earlier, values other than sku (group by) and price (aggregated) are arbitrary (If you get what you want it's by luck not design.)
  25. The tactic to use in this situation is create a subquery to get the max prices Join your original data to the subquery on the max price so you list those records that match the price. SELECT both_tables.sku_number , both_tables.color , both_tables.price FROM ( SELECT * FROM table1 UNION ALL SELECT * FROM table2 ) both_tables JOIN ( SELECT sku_number , MAX(Price) as price FROM ( SELECT sku_number, price FROM table1 UNION ALL SELECT sku_number, price FROM table2 ) both_prices GROUP BY sku_number ) max_prices USING (sku_number, price)
×
×
  • 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.