= - php 求助 ~~ 谢谢

蓝色海丶 2015-06-08 02:29:17

<select name="rootid" id="rootid" onChange="changelocation(document.form1.rootid.options[document.form1.rootid.selectedIndex].value)">
<option value="" selected>- 请选择 -</option>
<option value="HK Island East">HK Island East</option>
<option value="2">Yuen Long</option>
<option value="3">Central and Western</option>
<option value="4">Kwun Tong</option>
<option value="5">HK Island South</option>
<option value="6">Yau Tsim Mong</option>
<option value="7">Tsuen Wan</option>
<option value="8">Sham Shui Po</option>
<option value="9">Wan Chai</option>
<option value="10">Kowloon City</option>
<option value="11">Tai Po</option>
<option value="12">NT North</option>
<option value="13">Remote Island</option>
<option value="14">Sai Kung</option>
<option value="15">Shatin</option>
<option value="16">Sham Shui Po</option>
<option value="17">Tseung Kwan O</option>
<option value="18">Kwai Tsing</option>
<option value="19">Tuen Mun</option>

</select></td>



<?php
$conn=mysql_connect('localhost','root','');
mysql_select_db('project');
if (!$conn)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("project",$conn)or die(mysql_error());

mysql_query('set names UTF-8');
var_dump($_POST['rootid']);
$result = mysql_query("SELECT * FROM job where 'rootid'=$rootid");

while($row = mysql_fetch_array($result))
{


echo"<tr>";
echo"<th>" . $row['Job No'] . "</th>";
echo"<th>" . $row['Project Type'] . "</th>";
echo"<th>" . $row['District'] . "</th>";
echo"<th>" . $row['Title'] . "</th>";
echo"<th>" . $row['Google Map label'] . "</th>";

echo"</tr>";
}



/*var_dump($_POST['rootid']);
var_dump($_POST['areaid']);
*/
mysql_close($conn);
?>

我这样打印不出来 ~~
这个下拉列表当前选择的值我取得后 如何将有关这个值的那一条数据全部打印出来 ,我用post提交 谢谢 !!!
...全文
274 13 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
彬莫 2015-06-26
  • 打赏
  • 举报
回复
<?php
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("project", $con);
mysql_query("set names 'utf8'");
$rootid=$_POST['rootid'];
//$rootid=1;
// echo $rootid;
$sql="SELECT * FROM job where District='$rootid' ";
$result = mysql_query($sql);
// echo $result;


while($row = mysql_fetch_array($result))
{

echo "<table border='1'>";
echo "<tr>";
echo "<th>" . $row['Job No'] . "</th>";
echo "<th>" . $row['Project Type'] . "</th>";
echo "<th>" . $row['District'] . "</th>";
echo "<th>" . $row['Title'] . "</th>";
echo "<th>" . $row['Google Map label'] . "</th>";
echo "</tr>";
echo "</table>";
}

mysql_close($con);
?>
打印正常-.-虽然还是不太清楚你的问题在哪 还有你想用表格显示的话 别忘啦<table>标签
蓝色海丶 2015-06-12
  • 打赏
  • 举报
回复
引用 11 楼 fdipzone 的回复:
这样还有问题吗?

<?php
$conn=mysql_connect('localhost','root','');
mysql_select_db('project');
if (!$conn)
  {
  die('Could not connect: ' . mysql_error());
  }
mysql_select_db("project",$conn)or die(mysql_error());
  
mysql_query('set names UTF-8');
var_dump($_POST['rootid']);
$rootid = $_POST['rootid'];
$result = mysql_query("SELECT * FROM job where rootid='$rootid'");
  
while($row = mysql_fetch_array($result))
{
  
  
echo"<tr>";
echo"<th>" . $row['Job No'] . "</th>";
echo"<th>" . $row['Project Type'] . "</th>";
echo"<th>" . $row['District'] . "</th>";
echo"<th>" . $row['Title'] . "</th>";
echo"<th>" . $row['Google Map label'] . "</th>";
  
echo"</tr>";
}
  
  
  
 /*var_dump($_POST['rootid']);
var_dump($_POST['areaid']);
*/
mysql_close($conn);
?>
有问题呢 打印不出来 = - 我全部的源码加上数据库在7楼 ~ 求帮看 谢谢
傲雪星枫 2015-06-11
  • 打赏
  • 举报
回复
这样还有问题吗?

<?php
$conn=mysql_connect('localhost','root','');
mysql_select_db('project');
if (!$conn)
  {
  die('Could not connect: ' . mysql_error());
  }
mysql_select_db("project",$conn)or die(mysql_error());
  
mysql_query('set names UTF-8');
var_dump($_POST['rootid']);
$rootid = $_POST['rootid'];
$result = mysql_query("SELECT * FROM job where rootid='$rootid'");
  
while($row = mysql_fetch_array($result))
{
  
  
echo"<tr>";
echo"<th>" . $row['Job No'] . "</th>";
echo"<th>" . $row['Project Type'] . "</th>";
echo"<th>" . $row['District'] . "</th>";
echo"<th>" . $row['Title'] . "</th>";
echo"<th>" . $row['Google Map label'] . "</th>";
  
echo"</tr>";
}
  
  
  
 /*var_dump($_POST['rootid']);
var_dump($_POST['areaid']);
*/
mysql_close($conn);
?>
青鬆下的坚躯 2015-06-11
  • 打赏
  • 举报
回复
变量$rootid没用定义! $rootid = $_POST['rootid'];
灬上海爽爷 2015-06-11
  • 打赏
  • 举报
回复
而<option value="HK Island East">HK Island East</option> 这个是字符串呢? HK Island East这个是字符串 自然就是字符串了
蓝色海丶 2015-06-11
  • 打赏
  • 举报
回复
为什么其他value都是数字 而<option value="HK Island East">HK Island East</option> 这个是字符串呢? 因为之前我打印出来是数字 我想的是根据 District来 打印出只要有这个字符的全部数据 , 所以我就先改了select的第一个来试试 = - 我实在弄不出来 求助
蓝色海丶 2015-06-11
  • 打赏
  • 举报
回复

<form name="form1" method="post" action="post.php"><table border="0" align="center" cellpadding="2" cellspacing="1">
<tr>
<td><div align="right">District:</div></td>
<script language = "JavaScript">
var onecount;
onecount=0;
subcat = new Array();
//subcat[5] = new Array("abc","1","1");
// 5:类别ID abc:名称 1:类别 1:ID

subcat[0] = new Array("Traffic Engineering","HK Island East","Traffic Engineering");

subcat[1] = new Array("Traffic Engineeering - GBP","HK Island East","Traffic Engineeering - GBP");

subcat[2] = new Array("TTA","HK Island East","TTA");

subcat[3] = new Array("Traffic Engineering","2","Traffic Engineering");

subcat[4] = new Array("Traffic Engineeering - GBP","2","Traffic Engineeering - GBP");

subcat[5] = new Array("TIA","2","TIA");

subcat[6] = new Array("Traffic Engineering","3","Traffic Engineering");

subcat[7] = new Array("Traffic Engineeering - GBP","3","Traffic Engineeering - GBP");

subcat[8] = new Array("TTA","3","TTA");

subcat[9] = new Array("Traffic Engineering","4","Traffic Engineering");

subcat[10] = new Array("Traffic Engineeering - GBP","4","Traffic Engineeering - GBP");

subcat[11] = new Array("Pedestrian Study","4","Pedestrian Study");

subcat[12] = new Array("Traffic Study","4","Traffic Study");

subcat[13] = new Array("TTA","4","TTA");

subcat[14] = new Array("TIA","4","TIA");

subcat[15] = new Array("TIA","HK Island East","TIA");

subcat[16] = new Array("TIA","2","TIA");

subcat[17] = new Array("Traffic Study","3","Traffic Study");

subcat[18] = new Array("TIA","3","TIA");

subcat[19] = new Array("Traffic Engineering","5","Traffic Engineering");

subcat[20] = new Array("Traffic Engineeering - GBP","5","Traffic Engineeering - GBP");

subcat[21] = new Array("Traffic Study","5","Traffic Study");

subcat[22] = new Array("TTA","5","TTA");

subcat[23] = new Array("TIA","5","TIA");

subcat[24] = new Array("Traffic Engineering","6","Traffic Engineering");

subcat[25] = new Array("Traffic Engineeering - GBP","6","Traffic Engineeering - GBP");

subcat[26] = new Array("Traffic Study","6","Traffic Study");

subcat[27] = new Array("Traffic Engine Lease","6","Traffic Engine Lease");

subcat[28] = new Array("TTA","6","TTA");

subcat[29] = new Array("TIA","6","TIA");

subcat[30] = new Array("Traffic Engineeering - GBP","7","Traffic Engineeering - GBP");

subcat[31] = new Array("Traffic Study","7","Traffic Study");

subcat[32] = new Array("TIA","7","TIA");

subcat[33] = new Array("Traffic Engineering","8","Traffic Engineering");

subcat[34] = new Array("Traffic Engineeering - GBP","8","Traffic Engineeering - GBP");

subcat[35] = new Array("Traffic Study","8","Traffic Study");

subcat[36] = new Array("TIA","8","TIA");

subcat[37] = new Array("Traffic Engineering","9","Traffic Engineering");

subcat[38] = new Array("Traffic Engineeering - GBP","9","Traffic Engineeering - GBP");

subcat[39] = new Array("Traffic Study","9","Traffic Study");

subcat[40] = new Array("TIA","9","TIA");

subcat[41] = new Array("Traffic Engineering","10","Traffic Engineering");

subcat[42] = new Array("Traffic Engineeering - GBP","10","Traffic Engineeering - GBP");

subcat[43] = new Array("Traffic Survey","10","Traffic Survey");

subcat[44] = new Array("TIA","10","TIA");

subcat[45] = new Array("Traffic Engineering","11","Traffic Engineering");

subcat[46] = new Array("Traffic Engineering","12","Traffic Engineering");

subcat[47] = new Array("Traffic Engineeering - GBP","12","Traffic Engineeering - GBP");

subcat[48] = new Array("TIA","12","TIA");

subcat[49] = new Array("Traffic Engineeering - GBP","13","Traffic Engineeering - GBP");

subcat[50] = new Array("Traffic Engineering","14","Traffic Engineering");

subcat[51] = new Array("Traffic Study","14","Traffic Study");

subcat[52] = new Array("TTA","14","TTA");

subcat[53] = new Array("Traffic Engineering","15","Traffic Engineering");

subcat[54] = new Array("Traffic Engineeering - GBP","15","Traffic Engineeering - GBP");

subcat[55] = new Array("Traffic Study","15","Traffic Study");

subcat[56] = new Array("TIA","15","TIA");

subcat[57] = new Array("Traffic Engineering","16","Traffic Engineering");

subcat[58] = new Array("Traffic Engineeering - GBP","16","Traffic Engineeering - GBP");

subcat[59] = new Array("Traffic Study","16","Traffic Study");

subcat[60] = new Array("TIA","16","TIA");

subcat[61] = new Array("Traffic Engineering","17","Traffic Engineering");

subcat[62] = new Array("Traffic Survey","17","Traffic Survey");
subcat[63] = new Array("TTA","17","TTA");

subcat[64] = new Array("TIA","17","TIA");

subcat[65] = new Array("Traffic Engineering","18","Traffic Engineering");

subcat[66] = new Array("Traffic Engineeering - GBP","18","Traffic Engineeering - GBP");

subcat[67] = new Array("Traffic Engine Lease","18","Traffic Engine Lease");
subcat[68] = new Array("Traffic Study","18","Traffic Study");

subcat[69] = new Array("TIA","18","TIA");

subcat[70] = new Array("Traffic Engineering","19","Traffic Engineering");

subcat[71] = new Array("TIA","19","TIA");



onecount=72;

function changelocation(locationid)
{
document.form1.areaid.options[0]=new Option("-请选择-","");
document.form1.areaid.length = 1;

var locationid=locationid;
var i;
for (i=0;i < onecount; i++)
{
if (subcat[i][1] == locationid)
{
document.form1.areaid.options[document.form1.areaid.length] = new Option(subcat[i][0], subcat[i][2]);
}
}

}
</script>
<td><select name="rootid" id="rootid" onChange="changelocation(document.form1.rootid.options[document.form1.rootid.selectedIndex].value)">
<option value="" selected>- 请选择 -</option>
<option value="HK Island East">HK Island East</option>
<option value="2">Yuen Long</option>
<option value="3">Central and Western</option>
<option value="4">Kwun Tong</option>
<option value="5">HK Island South</option>
<option value="6">Yau Tsim Mong</option>
<option value="7">Tsuen Wan</option>
<option value="8">Sham Shui Po</option>
<option value="9">Wan Chai</option>
<option value="10">Kowloon City</option>
<option value="11">Tai Po</option>
<option value="12">NT North</option>
<option value="13">Remote Island</option>
<option value="14">Sai Kung</option>
<option value="15">Shatin</option>
<option value="16">Sham Shui Po</option>
<option value="17">Tseung Kwan O</option>
<option value="18">Kwai Tsing</option>
<option value="19">Tuen Mun</option>

</select></td>
<td>

Type :</td>
<td><select name="areaid" id="areaid">
<option value="" selected>-- 请选择 --</option>
</select></td>
</tr>
<tr>
<td colspan="4"><div align="right"></div>
<div align="right">
<input type="submit" name="Submit" value="提交">
</div></td>
</tr>
</table>
</form></td>
</tr>
</table>






<?php
$conn=mysql_connect('localhost','root','');

if (!$conn)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("project",$conn)or die(mysql_error());

mysql_query('set names UTF-8');
$rootid=$_POST['rootid'];
$result = mysql_query("SELECT * FROM job where District=$rootid ");

while($row = mysql_fetch_array($result))
{


echo"<tr>";
echo"<th>" . $row['Job No'] . "</th>";
echo"<th>" . $row['Project Type'] . "</th>";
echo"<th>" . $row['District'] . "</th>";
echo"<th>" . $row['Title'] . "</th>";
echo"<th>" . $row['Google Map label'] . "</th>";

echo"</tr>";
}



/*var_dump($_POST['rootid']);
var_dump($_POST['areaid']);
*/
mysql_close($conn);
?>


数据表



= - 求助
傲雪星枫 2015-06-09
  • 打赏
  • 举报
回复
为什么其他value都是数字
而<option value="HK Island East">HK Island East</option> 这个是字符串呢?

你的程序不完整,改成这样就可以提交了
html

<meta http-equiv="content-type" content="text/html;charset=utf-8">
<form name="form1" id="form1" method="post" action="server.php">
<select name="rootid" id="rootid" onChange="changelocation()">
<option value="" selected>- 请选择 -</option>
<option value="HK Island East">HK Island East</option>
<option value="2">Yuen Long</option>
<option value="3">Central and Western</option>
<option value="4">Kwun Tong</option>
<option value="5">HK Island South</option>
<option value="6">Yau Tsim Mong</option>
<option value="7">Tsuen Wan</option>
<option value="8">Sham Shui Po</option>
<option value="9">Wan Chai</option>
<option value="10">Kowloon City</option>
<option value="11">Tai Po</option>
<option value="12">NT North</option>
<option value="13">Remote Island</option>
<option value="14">Sai Kung</option>
<option value="15">Shatin</option>
<option value="16">Sham Shui Po</option>
<option value="17">Tseung Kwan O</option>
<option value="18">Kwai Tsing</option>
<option value="19">Tuen Mun</option>
</select>
<script type="text/javascript">
function changelocation(){
document.getElementById('form1').submit();
}
</script>


server.php

<?php
$conn=mysql_connect('localhost','root','');
mysql_select_db('project');
if (!$conn)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("project",$conn)or die(mysql_error());

mysql_query('set names UTF-8');
var_dump($_POST['rootid']);
$rootid = $_POST['rootid'];
$result = mysql_query("SELECT * FROM job where rootid='$rootid'");

while($row = mysql_fetch_array($result))
{


echo"<tr>";
echo"<th>" . $row['Job No'] . "</th>";
echo"<th>" . $row['Project Type'] . "</th>";
echo"<th>" . $row['District'] . "</th>";
echo"<th>" . $row['Title'] . "</th>";
echo"<th>" . $row['Google Map label'] . "</th>";

echo"</tr>";
}



/*var_dump($_POST['rootid']);
var_dump($_POST['areaid']);
*/
mysql_close($conn);
?>
一起混吧 2015-06-09
  • 打赏
  • 举报
回复
代码也不全,changelocation()函数是如何写的? 你的form提交成功了吗? print_r($_POST); 贴出结果看看。
小菜鸟czh 2015-06-09
  • 打赏
  • 举报
回复
$result = mysql_query("SELECT * FROM job where 'rootid'=$rootid");你这里的$rootid没有定义啊,你可以打印sql语句看看 是不是正确的
蓝色海丶 2015-06-09
  • 打赏
  • 举报
回复
引用 1 楼 xuzuning 的回复:
'rootid' 包裹 rootid 的是单引号吗? 那不变成了字符串了吗?一个字符串怎么和一个大于 0 的数相等呢? 既然不会出现歧义,为何要转义呢?何况转义符还写错了。是 ` 不是 ' 是 Esc 键下面,1 键左边,Tab 键上面的那个
= - 我不会弄 求教
蓝色海丶 2015-06-08
  • 打赏
  • 举报
回复
= - 我改了也打印不出来呢, 求教
xuzuning 2015-06-08
  • 打赏
  • 举报
回复
'rootid' 包裹 rootid 的是单引号吗? 那不变成了字符串了吗?一个字符串怎么和一个大于 0 的数相等呢? 既然不会出现歧义,为何要转义呢?何况转义符还写错了。是 ` 不是 ' 是 Esc 键下面,1 键左边,Tab 键上面的那个
大家好,2009年9月份注册以来,在论坛上学到了许多东西,得得许多会员和版主及管理的帮助和关爱,真的很感谢大家,正是因为,正是因为大家都是无私且乐于助人,分享自己的宝贵的技术和心得,且使我对EXCEL充满着激情,在我的脑海里总是浮现: 1. 我是ExcelHome论坛的会员,我很荣幸 2. 工作空余时间我会情不自禁来到ExcelHome之家,看看家,学习一些别人的的心得与帮助一些新会员 3. 那里有太多太多的宝贝,有意外的收获和惊喜(众里寻“她”千百度;踏破铁鞋无觅处,在EH得来全不费功夫) 4. 遇到问题我会在论坛和百度找,再找不到我就会发贴提问。呵呵,这里一定会得到帮助的 正是因为这些,因为大家的无私,所以我也不能自私,呵呵,分享一下打造“自己2010选项卡”,2010选项卡的修改比2003版的菜单修改复杂了,希望能帮到一些对这方面感兴趣的朋友,由于水平够,里面有许多不足,欢迎大家指正 ,呵呵,我八婆了一大堆,进入主题 对于Excel2007和2010,你注意到的第一件事可能就是它新外观,沿用多年的菜单与工具栏的用户界面已被抛弃了,取而代之的是选项卡和功能区的新界面,现在我们一步步来制作一个自己的选项卡(首先申明,有些代码和方法来自ExcelHome论坛和网络,在这里谢谢这些提供代码的朋友 ,俗话说的好“前人载树,后人乘凉”,并非个人所写) 第一步:在桌面上创建一个名为customUI的文件夹 第二步:步骤2 打开记事本,在其中复制下面的XML代码:文件名为CustomUI.xml,编码为UTF-8 保存到桌面customUI文件夹中
整理的高性能高并发服务器架构文章,内容预览:  初创网站与开源软件 6  谈谈大型高负载网站服务器的优化心得! 8  Lighttpd+Squid+Apache搭建高效率Web服务器 9  浏览量比较大的网站应该从哪几个方面入手? 17  用负载均衡技术建设高负载站点 20  大型网站的架构设计问题 25  开源平台的高并发集群思考 26  大型、高负载网站架构和应用初探 时间:30-45分钟 27  说说大型高并发高负载网站的系统架构 28  mixi技术架构 51 mixi.jp:使用开源软件搭建的可扩展SNS网站 51 总概关键点: 51 1,Mysql 切分,采用Innodb运行 52 2,动态Cache 服务器 -- 52 美国Facebok.com,中国Yeejee.com,日本mixi.jp均采用开源分布式缓存服务器Memcache 52 3,图片缓存和加 52  memcached+squid+apache deflate解决网站大访问量问题 52  FeedBurner:基于MySQL和JAVA的可扩展Web应用 53  YouTube 的架构扩展 55  了解一下 Technorati 的后台数据库架构 57  Myspace架构历程 58  eBay 的数据量 64  eBay 的应用服务器规模 67  eBay 的数据库分布扩展架构 68  从LiveJournal后台发展看大规模网站性能优化方法 70 一、LiveJournal发展历程 70 二、LiveJournal架构现状概况 70 三、从LiveJournal发展中学习 71 1、一台服务器 71 2、两台服务器 72 3、四台服务器 73 4、五台服务器 73 5、更多服务器 74 6、现在我们在哪里: 75 7、现在我们在哪里 78 8、现在我们在哪里 79 9、缓存 80 10、Web访问负载均衡 80 11、MogileFS 81  Craigslist 的数据库架构 81  Second Life 的数据拾零 82  eBay架构的思想金矿 84  一天十亿次的访问-eBay架构(一) 85  七种缓存使用武器 为网站应用和访问加速发布时间: 92  可缓存的CMS系统设计 93  开发大型高负载类网站应用的几个要点 105  Memcached和Lucene笔记 110  使用开源软件,设计高性能可扩展网站 110  面向高负载的架构Lighttpd+PHP(FastCGI)+Memcached+Squid 113  思考高并发高负载网站的系统架构 113  "我在SOHU这几年做的一些门户级别的程序系统(C/C++开发)" 115  中国顶级门户网站架构分析1 116  中国顶级门户网站架构分析 2 118  服务器的大用户量的承载方案 120  YouTube Scalability Talk 121  High Performance Web Sites by Nate Koechley 123 One dozen rules for faster pages 123 Why talk about performance? 123 Case Studies 124 Conclusion 124  Rules for High Performance Web Sites 124  对于应用高并发,DB千万级数量该如何设计系统哪? 125  高性能服务器设计 130  优势与应用:再谈CDN镜像加速技术 131  除了程序设计优化,zend+ eacc(memcached)外,有什么办法能提高服务器的负载能力呢? 135  如何规划您的大型JAVA多并发服务器程序 139  如何架构一个“Just so so”的网站? 148  最便宜的高负载网站架构 152  负载均衡技术全攻略 154  海量数据处理分析 164  一个很有意义的SQL的优化过程(一个电子化支局中的大数据量的统计SQL) 166  如何优化大数据量模糊查询(架构,数据库设置,SQL..) 168  求助:海量数据处理方法 169 # re: 求助:海量数据处理方法 回复 更多评论 169  海量数据库查询方略 169  SQL Server 2005对海量数据处理 170  分表处理设计思想和实现 174  Linux系统高负载 MySQL数据库彻底优化(1) 179  大型数据库的设计与编程技巧 本人最近开发一个访问统计系统,日志非常的大,都保存在数据库里面。 我现在按照常规的设计方法对表进行设计,已经出现了查询非常缓慢地情形。 大家对于这种情况如何来设计数据库呢?把一个表分成多个表么?那么查询和插入数据库又有什么技巧呢? 谢谢,村里面的兄弟们! 183  方案探讨,关于工程中数据库的问题. 184  web软件设计时考虑你的性能解决方案 190  大型Java Web系统服务器选型问题探讨 193  高并发高流量网站架构 210 1.1 互联网的发展 210 1.2 互联网网站建设的新趋势 210 1.3 新浪播客的简介 211 2.1 镜像网站技术 211 2.2 CDN内容分发网络 213 2.3 应用层分布式设计 214 2.4 网络层架构小结 214 3.1 第四层交换简介 214 3.2 硬件实现 215 3.3 软件实现 215  网站架构的高性能和可扩展性 233  资料收集:高并发 高性能 高扩展性 Web 2.0 站点架构设计及优化策略 243  CommunityServer性能问题浅析 250 鸡肋式的多站点支持 250 内容数据的集中式存储 250 过于依赖缓存 250 CCS的雪上加霜 250 如何解决? 251  Digg PHP's Scalability and Performance 251  YouTube Architecture 253 Information Sources 254 Platform 254 What's Inside? 254 The Stats 254 Recipe for handling rapid growth 255 Web Servers 255 Video Serving 256 Serving Video Key Points 257 Serving Thumbnails 257 Databases 258 Data Center Strategy 259 Lessons Learned 260 1. Jesse • Comments (78) • April 10th 261 Library 266 Friendster Architecture 273 Information Sources 274 Platform 274 What's Inside? 274 Lessons Learned 274  Feedblendr Architecture - Using EC2 to Scale 275 The Platform 276 The Stats 276 The Architecture 276 Lesson Learned 277 Related Articles 278 Comments 279 Re: Feedblendr Architecture - Using EC2 to Scale 279 Re: Feedblendr Architecture - Using EC2 to Scale 279 Re: Feedblendr Architecture - Using EC2 to Scale 280  PlentyOfFish Architecture 281 Information Sources 282 The Platform 282 The Stats 282 What's Inside 283 Lessons Learned 286  Wikimedia architecture 288 Information Sources 288 Platform 288 The Stats 289 The Architecture 289 Lessons Learned 291  Scaling Early Stage Startups 292 Information Sources 293 The Platform 293 The Architecture 293 Lessons Learned 294  Database parallelism choices greatly impact scalability 295  Introduction to Distributed System Design 297 Table of Contents 297 Audience and Pre-Requisites 298 The Basics 298 So How Is It Done? 301 Remote Procedure Calls 305 Some Distributed Design Principles 307 Exercises 308 References 309  Flickr Architecture 309 Information Sources 309 Platform 310 The Stats 310 The Architecture 311 Lessons Learned 316 Comments 318 How to store images? 318 RE: How to store images? 318  Amazon Architecture 319 Information Sources 319 Platform 320 The Stats 320 The Architecture 320 Lessons Learned 324 Comments 329 Jeff.. Bazos? 329 Werner Vogels, the CTO of 329 Re: Amazon Architecture 330 Re: Amazon Architecture 330 Re: Amazon Architecture 330 It's WSDL 330 Re: It's WSDL 331 Re: Amazon Architecture 331  Scaling Twitter: Making Twitter 10000 Percent Faster 331 Information Sources 332 The Platform 332 The Stats 333 The Architecture 333 L
最近一直在研究爬虫和Lucene,虽然开始决定选用Heritrix来执行爬虫操作,但是后来发现用它来做还是存在一定的问题,比如需要程序生成相应的XML文件,对于同一个Job,怎样才能保证重复运行该Job时文件夹始终是同一个(Heritrix为Job创建文件夹的规则是“Job名称-时间戳”)等等,都是需要考虑的问题,最终还是将其搁浅。    后来google了一下,找到了一个简单爬虫的程序代码(http://www.blogjava.net/Jack2007/archive/2008/03/24/188138.html),随即试验了一下,发现确实能得到网页的内容,在这里还是要谢谢代码的提供者——Jack.Wang。    虽然试验成功,但是在随后的大数据量试验时,还是出现了问题。最初试验时,我只是让程序去抓取10个URL链接,当我将URL链接数改为100个时,问题出现了——URL中存在重复,而且非常容易的就变成死循环。举个例子来说,比如我首先爬的是A.html,在A.html中有两个链接:B.html,C.html,等爬完A.html以后,程序会爬B.html,这时如果B.html中的所有链接中有A.html这个页面的链接,那么程序又会去爬A.html这个页面,如此一来就形成了一个死循环,永远也不能停止。    跟踪程序发现,原来是在添加要抓取的网页的链接列表中,没有将已经抓取过的URL去除,所以才造成了死循环。现在虽然加上了这个判断,但是从我运行程序的效果来看,也不是很理想,总是感觉有些慢,800个页面要一两分钟才能爬完,这个我觉得有点说不过去。    这个产品,做到现在,我遇到了这么几个情况,有和大家分享的,也有向大家请教,求助的。    1.关于对应关系数据的保存方式    在创建索引的时候,需要将网页的URL和网页的内容传到相应的方法中,当然URL和内容是要对应的,也许是经验太少吧,我采取的是通过构建一个JavaBean的方式来传递的,不知道大家有没有更好的方法       2.关于要创建索引的内容的保存方式    最初的想法是不创建文件,直接将内容保存到变量中,然后创建索引,即先抓取网页的内容,然后将网页的内容和URL保存到自己构建的JavaBean对象中,接着将这个对象放到一个list列表中,等所有网页抓取完毕以后,将这个列表传到创建索引的方法中。这种做法看似不错,可是当URL数量很大时,会导致内存不够用,所以还是创建文件比较稳妥。    3.关于网页编码问题    遇到这个问题也是一个巧合,本来我抓取的是客户的一个网站,后来同事说如果客户看访问日志,这个月的数据会和平常的数据不一样,所以我就抓取公司的网站,结果,问题出现了。原先公司的网站是用GB2312编码做的页面,现在采用的是UTF-8的编码,虽然我已经判断了页面的编码,可是依然不能解决保存的文件中文乱码的问题,不知道大家有什么好办法没有。错误信息为:java.io.UnsupportedEncodingException    附件为爬虫代码 本文出自 “徘徊在c#,java,php之间” 博客,请务必保留此出处http://jerrysun.blog.51cto.com/745955/221879

21,893

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧