本文介绍了帮助脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我认为foreach声明是正确的,但不确定如何修复: [PHP]<? php for($ i = 1; $ i< 3000; $ i ++){ $ data = file_get_contents(''http: //www.website.com?id=''.$i); $ data = strip_tags($ data,"< tr>"); $ data = explode("< tr>",$ data); foreach($ data as $ index => $ value){ mysql_query(" INSERT INTO`table`(entry,entry2,entry3,entry4,entry5)VALUES(''"。$ data [12]。"'',''"。 $ data [13]。"'',''"。$ data [14]。"'',''"。$ data [15]。"'',''"。$ data [16]。'')"); } } ?> [/ PHP] 我从中提取数据的表结构是: [HTML]< table width = " 385"边界=" 0" CELLSPACING = QUOT; 0" CELLPADDING = QUOT; 0"> < tr> < td valign =" top">< h1>公司名称< / h1> < table width =" 100%"边界=" 0" CELLSPACING = QUOT; 0" CELLPADDING = QUOT; 3英寸;> < tr> < th width =" 30%">< strong>联系人:< / strong>< / th> < td width =" 70%">< strong>人员名称 < / strong> < / TD> < / tr> < tr> < th>< strong>电话:< / strong>< / th> < td>< strong> 000 000 000< / strong>< / td> < / tr> < tr> < td>& nbsp;< / td> < td>< span class =" small">信息在这里< / span>。< / td> < / tr> < tr> < th>< strong>电子邮件:< / strong>< / th> < td>< strong>< a href =" [email protected]"> [email protected]< / a>< / strong>< / td> < / tr> < tr> < th>< strong>网站:< / strong>< / th> < td>< strong>< a href =" http://www.website.com"目标= QUOT; _blank" ID = QUOT; 451" onClick =" return trackclick(this.id);" title ="访问网站"> www.website.com< / a>< / strong>< / td> < / tr> < / table> [/ HTML] 有什么想法吗? 干杯, Adam Hi, I think the foreach statement is correct but not to sure how to fix: [PHP]<?php for($i=1;$i<3000;$i++) { $data = file_get_contents(''http://www.website.com?id=''.$i);$data = strip_tags($data,"<tr>");$data = explode("<tr>",$data); foreach($data as $index => $value) { mysql_query("INSERT INTO `table` (entry, entry2, entry3, entry4, entry5) VALUES (''" . $data[12] . "'', ''" . $data[13] . "'', ''" . $data[14] . "'', ''" . $data[15] . "'', ''" . $data[16] . "'')"); } } ?>[/PHP] Table structure that i am extracting data from is: [HTML]<table width="385" border="0" cellspacing="0" cellpadding="0"> <tr> <td valign="top"><h1>Company Name</h1> <table width="100%" border="0" cellspacing="0" cellpadding="3"> <tr> <th width="30%"><strong>Contact:</strong></th> <td width="70%"><strong>Persons Name </strong> </td> </tr> <tr> <th><strong>Tel:</strong></th> <td><strong>000 000 000</strong></td> </tr> <tr> <td>&nbsp;</td> <td><span class="small">Information Here</span>.</td> </tr> <tr> <th><strong>E-mail:</strong></th> <td><strong><a href="[email protected]">[email protected]</a></strong></td> </tr> <tr> <th><strong>Web site:</strong></th> <td><strong><a href="http://www.website.com" target="_blank" id="451" onClick="return trackclick(this.id);" title="Visit Site">www.website.com</a></strong></td> </tr> </table>[/HTML] Any ideas? Cheers,Adam推荐答案 这篇关于帮助脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-29 21:12