Jump to content

seany1234

New Members
  • Posts

    7
  • Joined

  • Last visited

seany1234's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks for your reply, I'm thinking looking at the code you have written this seems above my head, so i think i would be best to hire someone to do this for me. many thanks for your help. Sean
  2. Thanks for your reply, i think i will go with the second option, these html tables will only be 50 rows max, so speed isn't particularly required. i'm getting a little confused now as i haven't used ->children or ->plaintext before. how can i do the formatting on a specific data field? i was originally thinking i could do something like $val[1] = formatted text; but that wouldn't work.
  3. Thanks for your reply, I've never worked with CSV files in PHP, how would it be possible to format data, remove the first row? or would i still need to put the data into an array?
  4. Hi, So i have HTML table which i'm attempting to turn into executable SQL code which i can then insert into a SQL database table. I'm wondering if anyone has any good ideas for the best way to get this done? I need to extract the data from each of the <tr bgcolor="#EEEEEE">, scrape the text within each <td></td> and then format it in sql. so far i have removed the html not required and created an array by exploding "<tr bgcolor="#EEEEEE">", however, its creating an empty element in the first array index [0], to fix this i have tried $players = array_shift($players); however it removed everything from the array. next i was thinking i would need to remove all html within each array element and add a comma to the end, then i would need to compress it all back together again? would this be the best way to do this? source html <html> <head> <title><br/></title> <style type ="text/css"> body,td,th { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; } th { padding: 5px; text-align: left; } td { padding: 2px; border-style: solid; border-width: 1px } </style> </head> <body> <center><B><br/> </center></B> <p> <table bordercolor="#000000" width="90%" align="center"> <tr bgcolor="#EEEEEE"> <th>UID</th> <th>Name</th> <th>Nat</th> <th>Position</th> <th>Best Pos</th> <th>Age</th> <th>DoB</th> <th>Height</th> <th>Weight</th> <th>Expires</th> <th>Wage</th> <th>Value</th> <th>Aer</th> <th>Cmd</th> <th>Com</th> <th>Ecc</th> <th>Han</th> <th>Kic</th> <th>1v1</th> <th>Pun</th> <th>Ref</th> <th>TRO</th> <th>Thr</th> <th>Cor</th> <th>Cro</th> <th>Dri</th> <th>Fin</th> <th>Fir</th> <th>Fre</th> <th>Hea</th> <th>Lon</th> <th>L Th</th> <th>Mar</th> <th>Pas</th> <th>Pen</th> <th>Tck</th> <th>Tec</th> <th>Agg</th> <th>Ant</th> <th>Bra</th> <th>Cmp</th> <th>Cnt</th> <th>Dec</th> <th>Det</th> <th>Fla</th> <th>Ldr</th> <th>OtB</th> <th>Pos</th> <th>Tea</th> <th>Vis</th> <th>Wor</th> <th>Acc</th> <th>Agi</th> <th>Bal</th> <th>Jum</th> <th>Nat</th> <th>Pac</th> <th>Sta</th> <th>Str</th> </tr> <tr bgcolor="#EEEEEE"> <td>859596</td> <td>Tim Krul</td> <td>NED</td> <td>GK</td> <td>GK</td> <td>31</td> <td>3/4/1988 (31 years old)</td> <td>194 cm</td> <td>83 kg</td> <td>30/6/2022</td> <td>£25,000 p/w</td> <td>£12.75M</td> <td>15</td> <td>13</td> <td>14</td> <td>8</td> <td>13</td> <td>13</td> <td>15</td> <td>12</td> <td>16</td> <td>15</td> <td>12</td> <td>1</td> <td>2</td> <td>1</td> <td>3</td> <td>8</td> <td>4</td> <td>5</td> <td>3</td> <td>2</td> <td>2</td> <td>9</td> <td>4</td> <td>3</td> <td>8</td> <td>11</td> <td>12</td> <td>14</td> <td>13</td> <td>13</td> <td>12</td> <td>14</td> <td>2</td> <td>14</td> <td>2</td> <td>15</td> <td>10</td> <td>5</td> <td>13</td> <td>11</td> <td>13</td> <td>14</td> <td>17</td> <td>13</td> <td>8</td> <td>14</td> <td>10</td> </tr> <tr bgcolor="#EEEEEE"> <td>5204730</td> <td>Michael McGovern</td> <td>NIR</td> <td>GK</td> <td>GK</td> <td>34</td> <td>12/7/1984 (34 years old)</td> <td>188 cm</td> <td>86 kg</td> <td>30/6/2021</td> <td>£8,000 p/w</td> <td>£875K</td> <td>12</td> <td>11</td> <td>10</td> <td>2</td> <td>12</td> <td>12</td> <td>12</td> <td>11</td> <td>13</td> <td>8</td> <td>10</td> <td>5</td> <td>2</td> <td>1</td> <td>3</td> <td>9</td> <td>7</td> <td>6</td> <td>3</td> <td>3</td> <td>2</td> <td>7</td> <td>1</td> <td>2</td> <td>5</td> <td>7</td> <td>12</td> <td>14</td> <td>13</td> <td>13</td> <td>11</td> <td>17</td> <td>1</td> <td>12</td> <td>7</td> <td>12</td> <td>15</td> <td>10</td> <td>15</td> <td>10</td> <td>13</td> <td>12</td> <td>12</td> <td>12</td> <td>8</td> <td>15</td> <td>14</td> </tr> </table> <p> <p align="center"> </body> </html> code i've created so far: <?php // Defining the basic scraping function function scrape_between($data, $start, $end) { $data = stristr($data, $start); // Stripping all data from before $start $data = substr($data, strlen($start)); // Stripping $start $stop = stripos($data, $end); // Getting the position of the $end of the data to scrape $data = substr($data, 0, $stop); // Stripping all data from after and including the $end of the data to scrape return $data; // Returning the scraped data from the function } $myfile = fopen("source.html", "r") or die("Unable to open file!"); $page = fread($myfile,filesize("source.html")); $page = scrape_between($page, '</tr>', '</table>'); $players = explode('<tr bgcolor="#EEEEEE">', $page); echo '<pre>'; print_r($players); echo '</pre>'; fclose($myfile); ?>
  5. both 't' and 'src' are working now after i upgraded to PHP 7+ thanks for all the help!
  6. thanks for your replies echo path just returns 'Array', but i have followed Barands advice and the array is showing as below... Array ( [1] => Array ( [images] => Array ( [1] => Array ( [t] => http://astraframe.co.uk/wp-content/files_mf/cache/th_f2defad1772165b732faf2d184e379d3_windowtradecentrenorwich.jpg [o] => http://astraframe.co.uk/wp-content/files_mf/windowtradecentrenorwich.jpg [src] => http://astraframe.co.uk/wp-content/files_mf/windowtradecentrenorwich.jpg [name] => windowtradecentrenorwich.jpg ) [2] => Array ( [t] => http://astraframe.co.uk/wp-content/files_mf/cache/th_f2defad1772165b732faf2d184e379d3_buywindowsdirectfromastraframe17.png [o] => http://astraframe.co.uk/wp-content/files_mf/buywindowsdirectfromastraframe17.png [src] => http://astraframe.co.uk/wp-content/files_mf/buywindowsdirectfromastraframe17.png [name] => buywindowsdirectfromastraframe17.png ) [3] => Array ( [t] => http://astraframe.co.uk/wp-content/files_mf/cache/th_f2defad1772165b732faf2d184e379d3_conservatoriesinnorwichcopy.png [o] => http://astraframe.co.uk/wp-content/files_mf/conservatoriesinnorwichcopy.png [src] => http://astraframe.co.uk/wp-content/files_mf/conservatoriesinnorwichcopy.png [name] => conservatoriesinnorwichcopy.png ) [4] => Array ( [t] => http://astraframe.co.uk/wp-content/files_mf/cache/th_f2defad1772165b732faf2d184e379d3_astraframeconservatoriesfrom2995copy.png [o] => http://astraframe.co.uk/wp-content/files_mf/astraframeconservatoriesfrom2995copy.png [src] => http://astraframe.co.uk/wp-content/files_mf/astraframeconservatoriesfrom2995copy.png [name] => astraframeconservatoriesfrom2995copy.png ) ) ) )
  7. Hi, I'm trying to upgrade a website to PHP 7+, currently its on Version 5.6 The website uses a custom wordpress theme which the developers are no longer reachable. when i do the upgrade, pictures of the website no longer appear and having looked at the source code its showing this error message - I have been able to narrow the problem code to below: <?php $images = get_group('Banner Images'); ?> <?php foreach ($images as $image) { foreach ($image as $paths) { foreach ($paths as $path) { ?> <img src="<?php echo $path[t];?>"/> any idea what the t is used for in the $path array? all help would be amazing Kind regards Sean
×
×
  • 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.