IvanPeso Posted September 19, 2009 Share Posted September 19, 2009 Hey there, I am not so experienced in this area of PHP so I need very big help With cURL i login to 1 website and get content of that website on my site . In that content there is this table (under this text) for every player that is on server code looks like this <tr align="left"><td align="center"><input class="checkbox" type='checkbox' name='Kick5' value='True'> </td> <td align="center"><input class="checkbox" type='checkbox' name='Ban5' value='True'> </td> <td align="left" nowrap>FireX</td> <td align="center" nowrap><span style='background-color: Blue'> </span>Blue</td> <td align="center">48</td> <td align="center">0</td> <td align="center"> 89.164.221.222</td> <td align="center"> 5h600ez07dcda5a64685985d955c1552</td> </tr> In that code i need to select "Kick5" (from that input on the beginning of code but it can be Kick13 or something like that Kick5 is just example). Then i need to select "FireX" that is always put between <td align="left" nowrap> and </td>, then need to select this "89.164.221.222" it is aways between <td align="center"> and </td> and I need to select "5h600ez07dcda5a64685985d955c1552" witch is always between <td align="center"> and </td> an write this down to mysql database. I know how to make database code so you don't need to do it just leave place for that code (comment it somehow). Script needs to do it for every player (that means every time when that code on top appears). I already made code for getting code from that web site Thanks for help . I am trying to make this code for almost 1 week and not going very well ... Cheers Ivan Quote Link to comment https://forums.phpfreaks.com/topic/174831-solved-need-help-pregmatch/ Share on other sites More sharing options...
MadTechie Posted September 19, 2009 Share Posted September 19, 2009 try this <?php $html = <<<EOD <tr align="left"><td align="center"><input class="checkbox" type='checkbox' name='Kick5' value='True'> </td> <td align="center"><input class="checkbox" type='checkbox' name='Ban5' value='True'> </td> <td align="left" nowrap>FireX</td> <td align="center" nowrap><span style='background-color: Blue'> </span>Blue</td> <td align="center">48</td> <td align="center">0</td> <td align="center"> 89.164.221.222</td> <td align="center"> 5h600ez07dcda5a64685985d955c1552</td> </tr> EOD; if (preg_match('%<tr align="left"><td align="center"><input class="checkbox" type=\'checkbox\' name=\'([^\']*)\' value=\'True\'>.*?<td align="left" nowrap>([^<]*)</td>.*?<td align="center"> ([^<]*)</td>\s*<td align="center"> ([^<]*)</td>%sm', $html, $regs)) { $name = $regs[1]; $group = $regs[2]; $ip = $regs[3]; $hash = $regs[4]; } echo "$name, $group, $ip, $hash<br>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/174831-solved-need-help-pregmatch/#findComment-921377 Share on other sites More sharing options...
IvanPeso Posted September 19, 2009 Author Share Posted September 19, 2009 Omg thx fast reply but 1 thing. That code works for only 1 of that field but I can have more of them depending of players on server. More players more that fields. I need that script to keep repeating Quote Link to comment https://forums.phpfreaks.com/topic/174831-solved-need-help-pregmatch/#findComment-921387 Share on other sites More sharing options...
MadTechie Posted September 19, 2009 Share Posted September 19, 2009 So more like this <?php $html = <<<EOD <tr align="left"><td align="center"><input class="checkbox" type='checkbox' name='Kick5' value='True'> </td> <td align="center"><input class="checkbox" type='checkbox' name='Ban5' value='True'> </td> <td align="left" nowrap>FireX</td> <td align="center" nowrap><span style='background-color: Blue'> </span>Blue</td> <td align="center">48</td> <td align="center">0</td> <td align="center"> 89.164.221.222</td> <td align="center"> 5h600ez07dcda5a64685985d955c1552</td> </tr> <tr align="left"><td align="center"><input class="checkbox" type='checkbox' name='Kick99' value='True'> </td> <td align="center"><input class="checkbox" type='checkbox' name='Ban5' value='True'> </td> <td align="left" nowrap>FdfdsfsdfireX</td> <td align="center" nowrap><span style='background-color: Blue'> </span>Blue</td> <td align="center">48</td> <td align="center">0</td> <td align="center"> 89.155.221.222</td> <td align="center"> 5h600ez07dcgfjh5985d955c1552</td> </tr> <tr align="left"><td align="center"><input class="checkbox" type='checkbox' name='MadTechie' value='True'> </td> <td align="center"><input class="checkbox" type='checkbox' name='Ban5' value='True'> </td> <td align="left" nowrap>Fire111</td> <td align="center" nowrap><span style='background-color: Blue'> </span>Blue</td> <td align="center">48</td> <td align="center">0</td> <td align="center"> 89.164.221.222</td> <td align="center"> 5h600eBLAR64685985d955c1552</td> </tr> EOD; preg_match_all('%<tr align="left"><td align="center"><input class="checkbox" type=\'checkbox\' name=\'([^\']*)\' value=\'True\'>.*?<td align="left" nowrap>([^<]*)</td>.*?<td align="center"> ([^<]*)</td>\s*<td align="center"> ([^<]*)</td>%sm', $html, $players, PREG_SET_ORDER); foreach($players as $player) { list($void, $name, $group, $ip, $hash) = $player; echo "$name, $group, $ip, $hash<br>\n"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/174831-solved-need-help-pregmatch/#findComment-921395 Share on other sites More sharing options...
IvanPeso Posted September 19, 2009 Author Share Posted September 19, 2009 It is working 8) 8) Thanks man you have no idea how gratefull I am :]]] Cheers Quote Link to comment https://forums.phpfreaks.com/topic/174831-solved-need-help-pregmatch/#findComment-921396 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.