-
Posts
24,563 -
Joined
-
Last visited
-
Days Won
822
Everything posted by Barand
-
If you are going to split then Form Update Report exampleForm.php exampleReport.php exampleUpdate.php
-
I've never used Wordpress so I'll have to pass on that one
-
The included file just contains define()s for my host, username and password. Keeps them hidden.
-
The blocks of code in the post are extracts from example.php. example.php is a complete application which gives an input form, updates the database and produces a report of the updated data
-
I tried it with the png image you posted. It fount the top left OK but when working up from the bottom of the image it couldn't find a long chain of white pixels until it reached row 7 (should have found one at row 47). The only thing I can think of is there may be some anti-aliasing and not all pixels in the text background are a perfect white. I saved the image as a a gif file to reduce the color resolution and it worked fine giving left top (20, 0) right bottom (462, 47) gif image attached Here's the code <?php $im = imagecreatefromgif('shiva1.gif'); $iw = imagesx($im); $ih = imagesy($im); $wht = imagecolorresolve($im,0xFF,0xFF,0xFF); $top = $left = $bottom = $right = -1; /*************************************** * search from top left * ****************************************/ for ($y=0; $y<$ih; $y++) { for ($x=0; $x<$iw; $x++) { if (countRight($im, $x, $y, $iw, $wht) >= 100) { $top = $y; $left = $x; break 2; } } } echo "left top ($left, $top)<br>"; /*************************************** * search from bottom right * ****************************************/ for ($y=$ih-1; $y>0; $y--) { for ($x=$iw-1; $x>0; $x--) { if (countLeft($im, $x, $y, $wht) >= 100) { $bottom = $y; $right = $x; break 2; } } } echo "right bottom ($right, $bottom)"; /******************************************************* * functions to count horizontal white pixels * ********************************************************/ function countRight($im, $x, $y, $iw, $wht) { $k = 0; while ($x < $iw) { if (imagecolorat($im, $x, $y)!=$wht) { return $k; } ++$k; ++$x; } return $k; } function countLeft($im, $x, $y, $wht) { $k = 0; while ($x > 0) { if (imagecolorat($im, $x, $y)!=$wht) { return $k; } ++$k; --$x; } return $k; } ?>
-
Easiest way would be to write to a text file then pick up that file in the home page script
-
This should do it $xml = simplexml_load_string($str); $acopy = array(); /********************************** * Build the array ***********************************/ foreach ($xml->match as $match) { $acopy[(string)$match->sportname][(string)$match->matchname]['time'] = (string)$match->thetime; $acopy[(string)$match->sportname][(string)$match->matchname]['tournament'] = (string)$match->tournamentname; foreach ($match->linkset->link as $link) { $acopy[(string)$match->sportname][(string)$match->matchname]['links'][] = array( (string)$link['channelname'], (string)$link['kbps'], (string)$link['lang'], (string)$link ); } } //echo '<pre>',print_r($acopy, true),'</pre>'; exit; /********************************** * Output the array ***********************************/ foreach ($acopy as $sportname => $sportarray) { echo "$sportname<br><br>"; uasort($sportarray, function($a,$b){return strcmp($a['time'], $b['time']);}); foreach ($sportarray as $match => $matcharray) { $dt = date('jS F Y, H:i', strtotime($matcharray['time'])); echo "{$matcharray['tournament']} - $match - $dt<br>"; foreach ($matcharray['links'] as $linkarray) { echo join(' : ', $linkarray) . '<br>'; } echo '<br>'; } }
-
I couldn't resist tidying up those tables. The male and female tables both have many redundant columns. Cols 2 - 12 are just multiples of Col 1 and therefore totally unnecessary (just multiply Col 1 by the number). No need for two separate tables either so I combined into one. (BTW, both had all the data duplicated in the dump) CREATE TABLE `weight_factor` ( `sex` char(1) NOT NULL, `weight` int(11) NOT NULL, `factor` decimal(5,3) DEFAULT NULL, PRIMARY KEY (`sex`,`weight`) ) The weight column has the "lb" removed from the end of every value. It should be a numeric value. For the drinktype table I added a numeric id (primary key) and removed those untidy underscores from the descriptions. (I'm attaching a dump of a database called "monty" containing the two revised tables. I'm also attaching a php script calculator with the now simplified queries.) AlcoholCalc.php Dump20140104.txt
-
-
If you are going to do that it would make more sense to echo the $sql so you can see if it is being called twice.
-
Not necessarily. At present there is an array of sports. Each sport contains an array of leagues. Each league contains an array of matches So when an array of matches is sorted by time, it is within each league. It's matter of deciding at what level you want them sorted. But, instead of using XML as your data source it would be much better to load the data from the XML into a database and use the XML as a data transfer medium.
-
Not that I know of, you may have to roll up your sleeves and dive in. It should just require a couple of nested for() loops and use of imagecolorat to test each pixel
-
$dbcs = new mysqli($mysql_hostname, $mysql_user, $mysql_password, $mysql_database); $mysqli->query("UPDATE product set status='$status_state' where product_id='$status1' ");
-
I'm referring you to the answer I just gave to another member http://forums.phpfreaks.com/topic/285078-how-to-manage-databases-with-groups-of-somewhat-related-items/?do=findComment&comment=1463798
-
How to manage databases with groups of somewhat related items
Barand replied to CrimpJiggler's topic in MySQL Help
The answer is one word - normalize. http://forums.phpfreaks.com/topic/273634-best-way-to-set-up-tables-when-multiple-values/?do=findComment&comment=1408360 -
Yes. Restructure the array or use a database.
-
"group" is a poor choice for a column name as it is a MySQL reserved word. Whenever you use it in a query you must put it in backticks (`group`) What you need to do is GROUP BY `group` in you query. SELECT SUM(`money_earned`) as totEarn , SUM(`army_strength`) as totstrength , SUM(`worker_opm`) as totopm FROM `highscores` GROUP BY `group` ORDER BY SUM(`money_earned`) DESC LIMIT $start,$per_page
-
Doesn't exactly give me the structure. Probably best if you attach a dump of those 3 tables. (Why separate table for Male/female?)
-
Given there is only one date value in the trivial amount of data provided then there is no way to test. However, try it with this extra line /********************************** * Output the array ***********************************/ foreach ($acopy as $sportname => $sportarray) { echo "$sportname<br><br>"; foreach ($sportarray as $tournament => $tournarray) { uasort($tournarray, function($a,$b){return strcmp($a['time'], $b['time']);}); // ADD foreach ($tournarray as $match => $matcharray) { $dt = date('jS F Y, H:i', strtotime($matcharray['time'])); echo "$tournament - $match - $dt<br>"; foreach ($matcharray['links'] as $linkarray) { echo join(' : ', $linkarray) . '<br>'; } echo '<br>'; } } }
-
what does your table structure look like?
-
try it like this foreach ($xml->tasks->task as $task) { echo $task->startDate . '<br>'; }
-
PHP form pull MySQL data for field when another field is selected
Barand replied to tycoonbob's topic in PHP Coding Help
post the code that's producing that -
PHP form pull MySQL data for field when another field is selected
Barand replied to tycoonbob's topic in PHP Coding Help
When you say "it breaks" are you getting an error message? If so, what? -
PHP form pull MySQL data for field when another field is selected
Barand replied to tycoonbob's topic in PHP Coding Help
Why not select sku and name from the table then, in the dropdown, set the value to $row['sku'] instead of name. $_POST['species'] will then contain the required sku