-
Posts
24,563 -
Joined
-
Last visited
-
Days Won
822
Everything posted by Barand
-
Sorry, my head's hurting after banging it repeatedly aginst the wall in frustration after having looked at your table structures. Foe example... Columns which you are joining on, like CustomerID, are not indexed. ID columns, which (strangely) you are not using for your joins, are indexed twice (primary key and you also create another key on the same column). The gross_amount column that you are totalling is a varchar column!!! CustomerName, which belongs only in the customer table is repeated in billing and machinemaster tables. NORMALIZE!. And that's before I can comprehend what you want to do.
-
I know this isn't a CSS solution but, when in doubt, cheat. I used an SVG image. Fonts will differ I I don't know which you used. <body> <header style='text-align: center'> <svg width='90%' viewBox='0 0 500 100' style='max-width: 800;'> <defs> <style type='text/css'> #main { font-family: "arial black"; font-size: 20pt; font-weight: 800; fill: #000; } #better { font-family: "segoe script"; font-size: 40pt; font-weight: 600; fill: #80FF80; } </style> </defs> <text x='338' y='65' id='better'>better</text> <text x='12' y='60' id='main'>Making every day taste</text> </svg> </header> </body> screen width: 1024 screen width: 450
-
So you are only interested in the 203 customers that are in machinemaster but not in billing?
-
Could you explain that requirement, particularly "who are not doing the billing"?
-
How did you learn advanced SQL? With practice. How did you start tinkering with data? By designing and building databases to support applications I needed to develop, then developing them using the database. Problem is I've no data to tinker with. Then create some. (See tutorials link in my signature)
-
FYI - Matthew.
-
I have no idea how your chart software works but if you provide five data values (8, 19, 11, 3, 49) for one type and three data values (1, 3, 7) for the other, how is it supposed to know which months those values are for? You have a very weird x-axis for that chart (the month sequence is 6-5-4-3-2-1-12-11-10-9-8-7). The norm is to put them in chronological order.
-
Another option, maybe Create question in MSWord Save page as html doc Display it in an <iframe> on your page
-
Why don't you group by job type, month
-
If you save "X.doc", which contains an equation, as "X.html" into a "documents" folder it creates as subfolder "X_files" containing the equation as an image documents | +- X.html +- X_files | +- image1.jpg
-
Have you triedd using xpath()? <?php $str = '<xml><chapter num="17"> <verse num="1">And after six days Jesus taketh Peter, James, and John his brother, and bringeth them up into an high mountain apart,</verse> <verse num="2">And was transfigured before them: and his face did shine as the sun, and his raiment was white as the light.</verse> <verse num="3">And, behold, there appeared unto them Moses and Elias talking with him.</verse> <verse num="4">Then answered Peter, and said unto Jesus, Lord, it is good for us to be here: if thou wilt, let us make here three tabernacles; one for thee, and one for Moses, and one for Elias.</verse> <verse num="5">While he yet spake, behold, a bright cloud overshadowed them: and behold a voice out of the cloud, which said, This is my beloved Son, in whom I am well pleased; hear ye him.</verse> <verse num="6">And when the disciples heard <i>it,</i> they fell on their face, and were sore afraid.</verse> <verse num="7">And Jesus came and touched them, and said, <span class="j">Arise, and be not afraid. </span></verse> <verse num="8">And when they had lifted up their eyes, they saw no man, save Jesus only.</verse> <verse num="9">And as they came down from the mountain, Jesus charged them, saying, <span class="j">Tell the vision to no man, until the Son of man be risen again from the dead. </span></verse> <verse num="10">And his disciples asked him, saying, Why then say the scribes that Elias must first come?</verse> <verse num="11">And Jesus answered and said unto them, <span class="j">Elias truly shall first come, and restore all things. </span></verse> <verse num="12"><span class="j">But I say unto you, That Elias is come already, and they knew him not, but have done unto him whatsoever they listed. Likewise shall also the Son of man suffer of them. </span></verse> <verse num="13">Then the disciples understood that he spake unto them of John the Baptist.</verse> <verse num="14">And when they were come to the multitude, there came to him a <i>certain</i> man, kneeling down to him, and saying,</verse> <verse num="15">Lord, have mercy on my son: for he is lunatick, and sore vexed: for ofttimes he falleth into the fire, and oft into the water.</verse> <verse num="16">And I brought him to thy disciples, and they could not cure him.</verse> <verse num="17">Then Jesus answered and said, <span class="j">O faithless and perverse generation, how long shall I be with you? how long shall I suffer you? bring him hither to me. </span></verse> </chapter></xml> '; $xml = simplexml_load_string($str); $verses = $xml->xpath('//verse'); ?> <!DOCTYPE html> <html lang='en'> <head> <title>XML example</title> <meta charset='utf-8'> <style type='text/css'> .j { color: blue; font-style: italic; font-weight: 600; } </style> </head> <body> <?php foreach ($verses as $v) { echo "<p>{$v->asXML()}</p>"; } ?> </body> </html> Gives...
-
Open your browser's develop tools. Click on "Network" tab Click on one of the rows to view its headers FYI, when using date(), the default time is the current time, so this will suffice... <?= date("d-M-Y H:i:s") ?> BST
-
You can save MSWord docs as html. In this case, equations are saved as image files in a subfolder EG
-
Note that you are outputting Hours:seconds and not hours:minutes!
-
How to use PHP to Redirect to another page after form submition?
Barand replied to Ezybusy's topic in PHP Coding Help
Safe browsing dictates never to accept links from strangers, so please post code (in a code block using <> button). The usual reason for a header () to fail is because output has already been sent to the browser (even if it is only whitespace) at the time of the call. Check this is not the case. Also make sure you call exit() after the call so there is no unwanted subsequent processing of the page. If the above is the reason you should have received an error message - do you have error reporting ON? -
PHP help needed. Webpage php script works for all teams except team "0"
Barand replied to vbcoach's topic in PHP Coding Help
On the subject of "loose typing of variables", version 8 of PHP is stricter than earlier versions. It could be that be that the failure now is due to an upgrade to this version from an old version. What error messages are you getting? -
Find the difference between two dates in non-standard format, mysql
Barand replied to oslon's topic in MySQL Help
You can do it SQL when you load the CSV data into MySQL using the STR_TO_DATE() function to reformat the dates // CSV INPUT $input = 'Tom DiCanari,28/Apr/24 11:50 AM,29/Apr/24 5:29 PM'; // create tete table $pdo->exec("CREATE TABLE IF NOT EXISTS test1 (name varchar(50), timefrom datetime, timeuntil datetime)"); // process the input $stmt = $pdo->prepare("INSERT INTO test1 (name, timefrom, timeuntil) VALUES (?, STR_TO_DATE(?, '%d/%b/%y %h:%i %p'), STR_TO_DATE(?, '%d/%b/%y %h:%i %p'))"); $data = str_getcsv($input); $stmt->execute($data); then mysql> SELECT name -> , timefrom -> , timeuntil -> , timestampdiff(MINUTE, timefrom, timeuntil) as mins_diff -> FROM test1; +--------------+---------------------+---------------------+-----------+ | name | timefrom | timeuntil | mins_diff | +--------------+---------------------+---------------------+-----------+ | Tom DiCanari | 2024-04-28 11:50:00 | 2024-04-29 17:29:00 | 1779 | +--------------+---------------------+---------------------+-----------+ -
Find the difference between two dates in non-standard format, mysql
Barand replied to oslon's topic in MySQL Help
Some example code for you // INPUT DATES $col1 = '28/Apr/24 11:50 AM'; $col2 = '29/Apr/24 5:29 PM'; // FORMAT DEFINITIONS $jira = 'd/M/y h:i a'; $SQLformat = 'Y-m-d H:i:s'; $dt1 = DateTime::createFromFormat($jira, $col1); // create DateTime object $dt2 = DateTime::createFromFormat($jira, $col2); $d = $dt1->diff($dt2); // create DateInterval object echo $dt1->format($SQLformat) .'<br>'; // output dates echo $dt2->format($SQLformat) .'<br>'; printf("%d days %d hr %d min", $d->days, $d->h, $d->i); // show difference Output... 2024-04-28 11:50:00 2024-04-29 17:29:00 1 days 5 hr 39 min -
whoops! undefined array key, how to define this array key?
Barand replied to chickencommander123's topic in PHP Coding Help
Check the content of your arrays. It looks like $allowed_forums contains a blank entry. -
whoops! undefined array key, how to define this array key?
Barand replied to chickencommander123's topic in PHP Coding Help
There are about a dozen array keys in that picture. If you want help... Be specific. Post textual code in a code block (<> button) and not a useless picture. -
By now you should have learned to place code inside a code block! I'm happy try and help. Any data tables I already have from you are several years out of date and does not include the following tables used in your code: subject_position dummy arms_level promotion I would, therefore, require an up-to-date DB dump. (I'll PM you with my email address). Also - what MySQL version are you using?
-
FYI Here is a simpler non-recursive solution... $cat_data = []; $res = $pdo->query("SELECT id , CONCAT(name, '::', position) as name , parent FROM category "); foreach ($res as $r) { $cat_data[$r['id']] = [ 'name' => $r['name'], 'parent' => $r['parent'] ] ; } $breadcrumbs = retrieve_category_path(552, $cat_data); echo $breadcrumbs; function retrieve_category_path($id, &$cats) { if (!isset($cats[$id])) { return "Unknown category"; } $category_path_array = []; do { array_unshift($category_path_array, $cats[$id]['name']); $id = $cats[$id]['parent']; } while ($id); return join(' / ', $category_path_array); }
-
We want to add a new element to the $cpa array in each call to the function. To do this we need always to add to the original empty array. The ampersand allows us to to this. Without it, a copy of the array would be passed to the function and we would just keep adding to a new empty array each time. &$cpa passes the array by reference (ie its address in memory) instead of a copy. P.S. This method below (which stores all the category data into a $cat_data array instead of running a query in every call to the function, is 5x faster. $cat_data looks like this... Array ( [532] => Array ( [name] => Motorbikes::1 [parent] => 0 ) [533] => Array ( [name] => Cars::2 [parent] => 0 ) [534] => Array ( [name] => Boats::3 [parent] => 0 ) [535] => Array ( [name] => Bicycles::4 [parent] => 0 ) . . . ) CODE $cat_data = []; $res = $pdo->query("SELECT id , CONCAT(name, '::', position) as name , parent FROM category "); foreach ($res as $r) { $cat_data[$r['id']] = [ 'name' => $r['name'], 'parent' => $r['parent'] ] ; } $category_path_array = []; retrieve_category_path ($cat_data, 552, $category_path_array); $breadcrumbs = join('/', $category_path_array); echo $breadcrumbs; function retrieve_category_path (&$cats, $id, &$cpa) { array_unshift($cpa,$cats[$id]['name']); if ($cats[$id]['parent']) { retrieve_category_path($cats, $cats[$id]['parent'], $cpa); } } Thank you - much appreciated.
-
After calling your recursive array you need finish up with a single array - you output a separate array during each iteration. Don't connect to db inside functions - it's the slowest part of the process and inefficient (plus you can quickly reach your connctions limit). Connect once then pass the connection to the functions. Don't include the separator in you results - add that when you implode (join). (Sorry for any delay - it's not easy to load an image of data into a database test table) My method... function retrieve_category_path($pdo, $id, &$cpa){ // DB connection // Company ID $stmt = $pdo->prepare("SELECT CONCAT(name, '::', position) as name , parent FROM category WHERE id = ? "); $stmt->execute([$id]); while($row=$stmt->fetch()){ $parent =$row['parent']; $name = $row['name']; $cpa[] = $row['name']; // append into array if($row['parent'] > 0){ retrieve_category_path($pdo, $row['parent'], $cpa); } } } $category_path_array = []; retrieve_category_path($pdo, 552, $category_path_array); $breadcrumbs = join('/', array_reverse($category_path_array)); echo $breadcrumbs; // Cars::2/Sports cars::1/Petrol::1/2 Door::0