很多站长朋友们都不太清楚php采集table数据,今天小编就来给大家整理php采集table数据,希望对各位有所帮助,具体内容如下:
本文目录一览: 1、 table 在PHP中的应用,急!! 2、 请问php怎样抓取其它网站的动态数据,显示在自己的网页内并同步更新。 3、 thinkphp 怎么查出一个数据库的表的所有数据 4、 怎么从表格里读出PHP数据库里面的数据 5、 您好,我想通过循环调用php数据库中数据,通过table显示出了,但对php中table和while的写法不清楚 6、 PHP怎么将表格的数据保存到数据库 table 在PHP中的应用,急!!前提是你的 $zifuchuan是一个数组,你就可以这样用了:
<table>
<?php for($i=0; $i<count($zifuchuan); $i++){ ?>
<tr>
<td><?php echo $zifuchuan[$i] ?> </td>
</tr>
<?php } ?>
</table>
请问php怎样抓取其它网站的动态数据,显示在自己的网页内并同步更新。刚吃完午饭吧,来帮你实现一下吧。记得加分哦。
$url = "";
$queryServer = curl_init();
curl_setopt($queryServer, CURLOPT_URL, $url);
curl_setopt($queryServer, CURLOPT_HEADER, 0);
curl_setopt($queryServer, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($queryServer, CURLOPT_RETURNTRANSFER, true);
curl_setopt($queryServer, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($queryServer, CURLOPT_TIMEOUT, 30);
$html = curl_exec($queryServer);
$html = iconv('UTF-8','GBK//IGNORE',$html); //如果你需要是的数据是utf-8编码的,这一行可以注销,如果需要gbk编码的,请保留.如果出现乱码,就是一行的问题,你自己调着试吧
//echo $holder;exit; 此处可以输出来测试.
$html = str_replace(array("\n","\r","\t"),"",$html);
$preg = '/<table\s+width=\"800\"[^>]+>(.*?)<\/table>/';
preg_match_all($preg,$html,$out);
//匹配每行
preg_match_all('/<tr[^>]+>(.*?)<\/tr>/',$out[1][0],$tr);
//匹配每个td
$result = array();
$match = '/<td.+>([^<]+)<\/td>/U';
foreach( $tr[0] as $key => $value ){
preg_match_all($match,$value,$arr);
$result[] = $arr[1];
}
//输出测试,$result就是你要的数据,至于你要怎么输出显示格式,那就随心调就好了。
foreach( $result as $key => $value ){
echo implode("\t",$value);
echo "<br>";
}
exit;
thinkphp 怎么查出一个数据库的表的所有数据$goods = D('Goods');//实例化Model对象,实际操作Goods数据表
$info = $goods -> select();//获得数据信息
print_r($info);//打印信息
怎么从表格里读出PHP数据库里面的数据<?php
mysql_pconnect("localhost", "mysql_user", "mysql_password") or
die ("Could not connect" . mysql_error());
mysql_select_db("mydb");
mysql_query("DELETE FROM mytable WHERE id < 10");
?>
删除MYTABLE表中ID小于10的数据,where后边可以更改你要删除数据的条件。
您好,我想通过循环调用php数据库中数据,通过table显示出了,但对php中table和while的写法不清楚我一般这样写:
<?php
$con = mysqli_connect("localhost:3306","user","pwd");
if (!$con)
{
die('Could not connect: ' . mysqli_error());
}
mysqli_select_db("ichunqiu",$con);
$querry = "select * from users where id = " . $_GET['id'];
$sql = mysqli_query($querry,$con);
$result = mysqli_fetch_array($sql);
echo "<table class='itable' border='1' cellspacing='0' width='300px' height='150'>"; echo "<tr>";
echo "<td>id</td>";
echo "<td>username</td>";
echo "</tr>";
echo "<tr>";
echo "<td>".$result['id']."</td>";
echo "<td>".$result['username']."</td>";
echo "</tr>";
echo "</table>";
mysql_close($con);
?>
PHP怎么将表格的数据保存到数据库看你的表格,只需要从表单中循环取出所有行,然后依次写入数据库就行了
假设表单中是:txt1[] txt2[]......
通过$a=$_POST["txt1[]"]取得值,然后循环写入:
for($t=0;$t<=count($a)-1;$t++){
// insert into 表 (字段1,......) values ('$a[$t]',.....)
}
至于打印,在JS中直接windows.print就行了
关于php采集table数据的介绍到此就结束了,不知道本篇文章是否对您有帮助呢?如果你还想了解更多此类信息,记得收藏关注本站,我们会不定期更新哦。
查看更多关于php采集table数据 php数据采集方法的详细内容...