php打开数据库中链接 做成链接吧 用GET传一个参数 然后 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 依次取出记录,然后使用curl即可 至于curl的用法楼主查一下手册吧,也可以使用file或者file_get_contents <input type="button" value="ttt" name='ttt' onclick='window.location="query.php"'/><?php //连接数据库,修改成自己的用户名和密码 $link = mysql_connect('localhost', 'mysql_user', 'mysql_password'); mysql_select_db("数据库名", $link); $result = mysql_query("SELECT url FROM 表名"); while($row = mysql_fetch_row($result)) { file_get_contents($row[0]); } mysql_free_result($result); mysql_close($link);?> 这些是我的代码,已经可以实现把相对应的链接读出来在页面上显示,楼上的大哥麻烦教教小弟怎么改require('../../config.inc.php');require_once('common.php');require_once('builds.inc.php');require_once('results.inc.php');require_once("../../lib/functions/lang_api.php");testlinkInitPage();$arrData = array();$arrBuilds = getBuilds($_SESSION['testPlanId'], " ORDER BY build.name ");// is output is excel?$xls = FALSE;if (isset($_GET['format']) && $_GET['format'] =='excel'){ $xls = TRUE;}// 20050919 - fm$sql = " SELECT mgttcid,url" . " FROM project TP, component COMP, category CAT, testcase TC, mgtcomponent MGTCOMP, mgtcategory MGTCAT " . " WHERE MGTCOMP.id = COMP.mgtcompid " . " AND MGTCAT.id = CAT.mgtcatid " . " AND COMP.projid=TP.id " . " AND CAT.compid=COMP.id " . " AND TC.catid=CAT.id" . " AND TP.id=" . $_SESSION['testPlanId'];$result = do_mysql_query($sql);$bRights = has_rights("tp_execute") && !$xls;while ($myrow = mysql_fetch_assoc($result)){ //Cycle through all of the test cases $container = null; $container[] = htmlspecialchars($myrow['mgttcid'] . ' / ' . $myrow['mgttcid']); $container[] = "<b>" . $myrow['url'] . "</b>:"; ///SCHLUNDUS $arrData[] = $container;}// for excel send headerif ($xls) sendXlsHeader();$smarty = new TLSmarty;$smarty->assign('title', lang_get('title_test_report_all_builds'));$smarty->assign('arrData', $arrData);$smarty->assign('arrBuilds', $arrBuilds);if ($xls) { $smarty->assign('printDate', strftime($g_date_format, time()) ); $smarty->assign('user', $_SESSION['user']);}$smarty->display('urlrun.tpl');urlrun.tpl的代码{include file="inc_head.tpl"}<body>{if $printDate == ''}<h1>{$title|escape}</h1>{else}{* print data to excel *}{/if}<div class="workBack"><table class="simple" style="width: 100%; text-align: center; margin-left: 0px;"> <tr> <th>ID</th> <th>url</th> </tr>{section name=Row loop=$arrData} <tr> {section name=Item loop=$arrData[Row]} <td>{$arrData[Row][Item]}</td> {/section} </tr>{/section}</table></div></body></html> 将url以get方式传递给一个xxx.php,记得传之前要编码一下.在xxx.php里获取,然后file_get_contents这个网址就行了. $sql = " SELECT url" . " FROM project TP, component COMP, category CAT, testcase TC, mgtcomponent MGTCOMP, mgtcategory MGTCAT " . " WHERE MGTCOMP.id = COMP.mgtcompid " . " AND MGTCAT.id = CAT.mgtcatid " . " AND COMP.projid=TP.id " . " AND CAT.compid=COMP.id " . " AND TC.catid=CAT.id" . " AND TP.id=" . $_SESSION['testPlanId'];$result = do_mysql_query($sql);$bRights = has_rights("tp_execute") && !$xls;while ($myrow = mysql_fetch_assoc($result)){ //Cycle through all of the test cases $container = null; $container[] = "<b>" . $myrow['url'] . "</b>:"; $echo $myrow['url'];}上面代码中 $myrow['url'] 已经是表中所有url的集合,怎么能依次执行集合中的url呢? 依次执行是个什么概念?啥叫执行url链接? 我这个数据库中的链接是对应的测试用例,也就是个ie链接,打开后,就会执行,我现在想做的就是把表中的每个url都打开一遍,就ok了。 明白了。直接<script>window.open("http://www.baidu.com")</script>就可以了~~~你可以写在js的for循环里面。 试试改改:$container[] = "<script>window.open('" . $myrow['url'] . "')</script>:"; 为什么运行后会提示缺少对象,高手指点下,帮我找找哪里错了,谢谢。$sql = " SELECT url" . " FROM project TP, component COMP, category CAT, testcase TC, mgtcomponent MGTCOMP, mgtcategory MGTCAT " . " WHERE MGTCOMP.id = COMP.mgtcompid " . " AND MGTCAT.id = CAT.mgtcatid " . " AND COMP.projid=TP.id " . " AND CAT.compid=COMP.id " . " AND TC.catid=CAT.id" . " AND TP.id=" . $_SESSION['testPlanId'];$result = do_mysql_query($sql);$bRights = has_rights("tp_execute") && !$xls;$urls = array();while ($myrow = mysql_fetch_assoc($result)){ //Cycle through all of the test cases $container = null; $container[] = "<b>" . $myrow['url'] . "</b>:"; ///SCHLUNDUS $urls[] = $myrow['url'];}echo '<script type="text/javascript">';echo 'function openURL(){';foreach($urls as $key=>$value){ echo 'window.open("'.$value.'")';}echo '}';echo '</script>';echo '<input type="button" value="ttt" name="ttt" onclick="openUrl()"/>'; 为什么PHP传递参数值为0时,empty()判断参数为真? MYSQL数据库问题:其某个表的某个字段自动填值 今天公司经理给我出了一道正则表达式的题,说看看这段时间学的情况.为了不被他将应届毕业生看扁,于是我来了水源寻道. 关于数组生成树的问题高手解决!!! 很简单的关于empty的问题 本地测试修改可以,放到服务器上就报错 请各位大哥帮帮我,分不多了 为什么fopen函数失效? 开发dz插件后台提示错误 求一php文件,方便管理网站 给个php 能控制上传图片宽高代码 php怎么修改数据库表名
<?php
//连接数据库,修改成自己的用户名和密码
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
mysql_select_db("数据库名", $link);
$result = mysql_query("SELECT url FROM 表名");
while($row = mysql_fetch_row($result))
{
file_get_contents($row[0]);
}
mysql_free_result($result);
mysql_close($link);
?>
require('../../config.inc.php');
require_once('common.php');
require_once('builds.inc.php');
require_once('results.inc.php');
require_once("../../lib/functions/lang_api.php");
testlinkInitPage();$arrData = array();
$arrBuilds = getBuilds($_SESSION['testPlanId'], " ORDER BY build.name ");// is output is excel?
$xls = FALSE;
if (isset($_GET['format']) && $_GET['format'] =='excel'){
$xls = TRUE;
}// 20050919 - fm
$sql = " SELECT mgttcid,url" .
" FROM project TP, component COMP, category CAT, testcase TC, mgtcomponent MGTCOMP, mgtcategory MGTCAT " .
" WHERE MGTCOMP.id = COMP.mgtcompid " .
" AND MGTCAT.id = CAT.mgtcatid " .
" AND COMP.projid=TP.id " .
" AND CAT.compid=COMP.id " .
" AND TC.catid=CAT.id" .
" AND TP.id=" . $_SESSION['testPlanId'];$result = do_mysql_query($sql);
$bRights = has_rights("tp_execute") && !$xls;while ($myrow = mysql_fetch_assoc($result))
{ //Cycle through all of the test cases
$container = null;
$container[] = htmlspecialchars($myrow['mgttcid'] . ' / ' . $myrow['mgttcid']);
$container[] = "<b>" . $myrow['url'] . "</b>:";
///SCHLUNDUS
$arrData[] = $container;
}// for excel send header
if ($xls)
sendXlsHeader();$smarty = new TLSmarty;
$smarty->assign('title', lang_get('title_test_report_all_builds'));
$smarty->assign('arrData', $arrData);
$smarty->assign('arrBuilds', $arrBuilds);
if ($xls) {
$smarty->assign('printDate', strftime($g_date_format, time()) );
$smarty->assign('user', $_SESSION['user']);
}
$smarty->display('urlrun.tpl');urlrun.tpl的代码
{include file="inc_head.tpl"}<body>{if $printDate == ''}
<h1>{$title|escape}</h1>{else}{* print data to excel *}{/if}<div class="workBack">
<table class="simple" style="width: 100%; text-align: center; margin-left: 0px;">
<tr>
<th>ID</th>
<th>url</th>
</tr>
{section name=Row loop=$arrData}
<tr>
{section name=Item loop=$arrData[Row]}
<td>{$arrData[Row][Item]}</td>
{/section}
</tr>
{/section}
</table>
</div></body>
</html>
在xxx.php里获取,然后file_get_contents这个网址就行了.
$sql = " SELECT url" .
" FROM project TP, component COMP, category CAT, testcase TC, mgtcomponent MGTCOMP, mgtcategory MGTCAT " .
" WHERE MGTCOMP.id = COMP.mgtcompid " .
" AND MGTCAT.id = CAT.mgtcatid " .
" AND COMP.projid=TP.id " .
" AND CAT.compid=COMP.id " .
" AND TC.catid=CAT.id" .
" AND TP.id=" . $_SESSION['testPlanId'];$result = do_mysql_query($sql);
$bRights = has_rights("tp_execute") && !$xls;while ($myrow = mysql_fetch_assoc($result))
{ //Cycle through all of the test cases
$container = null;
$container[] = "<b>" . $myrow['url'] . "</b>:";
$echo $myrow['url'];
}
上面代码中 $myrow['url'] 已经是表中所有url的集合,怎么能依次执行集合中的url呢?
你可以写在js的for循环里面。
" FROM project TP, component COMP, category CAT, testcase TC, mgtcomponent MGTCOMP, mgtcategory MGTCAT " .
" WHERE MGTCOMP.id = COMP.mgtcompid " .
" AND MGTCAT.id = CAT.mgtcatid " .
" AND COMP.projid=TP.id " .
" AND CAT.compid=COMP.id " .
" AND TC.catid=CAT.id" .
" AND TP.id=" . $_SESSION['testPlanId'];$result = do_mysql_query($sql);
$bRights = has_rights("tp_execute") && !$xls;
$urls = array();while ($myrow = mysql_fetch_assoc($result))
{ //Cycle through all of the test cases
$container = null;
$container[] = "<b>" . $myrow['url'] . "</b>:"; ///SCHLUNDUS $urls[] = $myrow['url'];}echo '<script type="text/javascript">';
echo 'function openURL(){';foreach($urls as $key=>$value)
{
echo 'window.open("'.$value.'")';
}echo '}';
echo '</script>';echo '<input type="button" value="ttt" name="ttt" onclick="openUrl()"/>';