自动提取网页表格数据库数据库数据库
㈠ 如何把mysql数据库表中的数据提取到一个html表格中
html是静态页面,提取不到数据库数据库数据的,你应该用动态页面提取,比如jsp页面,提取之后在转换成静态页面即可。
㈡ 如何获取数据库中的表,生成html页面的table
html只能通过ajax接口跟后台数据库接口通信,然后取出来的数据在页面上显示。
以下是一个例子:
html文件suggest.html:
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script language="JavaScript" type="text/javascript" src="ajax_search.js"></script>
<style type="text/css" media="screen">
body {
font: 11px arial;
}
.suggest_link {
background-color: #FFFFFF;
padding: 2px 6px 2px 6px;
cursor:hand;
}
.suggest_link_over {
background-color: #E8F2FE;
padding: 2px 6px 2px 6px;
}
#search_suggest {
position:relative;
background-color: #FFFFFF;
text-align: left;
border: 1px solid #000000;
left: -12px;
top: 1px;
height: 74px;
width: 170px;
display:none;
}
</style>
</head>
<body background="bg.gif">
<center>
<h3>实现搜索提示</h3>
<div style="width: 500px;">
<input type="text" id="txtSearch" name="txtSearch" onKeyUp="searchSuggest();" autocomplete="off" />
<input type="submit" id="cmdSearch" name="cmdSearch" value="搜索"/><br />
<div id="search_suggest"></div>
</div>
</center>
</body>
</html>
ajax_search.js:
var searchReq = createAjaxObj();
function createAjaxObj()
{
var httprequest=false;
if (window.XMLHttpRequest) //为非IE浏览器生成XmlHttpRequest对象
{
httprequest=new XMLHttpRequest()
if (httprequest.overrideMimeType) httprequest.overrideMimeType('text/xml')
}
else if (window.ActiveXObject) //为IE浏览器生成XmlHttpRequest对象
{
try
{
httprequest=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
httprequest=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e){}
}
}
return httprequest
}
function searchSuggest()
{
if (searchReq.readyState == 4 || searchReq.readyState == 0)
{
var str = escape(document.getElementById('txtSearch').value);
searchReq.open("GET", 'search?search=' + str, true);//向服务器端发送请求
searchReq.onreadystatechange = handleSearchSuggest; //设置回调函数
searchReq.send(null);
}
}
function handleSearchSuggest()
{ //这是回调函数,处理从服务器端返回的信息
if (searchReq.readyState == 4)
{
var ss = document.getElementById('search_suggest')
ss.innerHTML = '';
var str = searchReq.responseText.split("\n");
for(i=0; i < str.length - 1; i++)
{
var suggest = '<div onmouseover="javascript:suggestOver(this);" ';
suggest += 'onmouseout="javascript:suggestOut(this);" ';
suggest += 'onclick="javascript:setSearch(this.innerHTML);" ';
suggest += 'class="suggest_link">' + str[i] + '</div>';
ss.innerHTML += suggest;
ss.style.display="block";
}
}
}
function suggestOver(div_value)
{
div_value.className = 'suggest_link_over';
}
function suggestOut(div_value)
{
div_value.className = 'suggest_link';
}
function setSearch(value)
{
document.getElementById('txtSearch').value = value;
document.getElementById('search_suggest').innerHTML = '';
document.getElementById('search_suggest').style.display="none";
}
servlet文件SearchSuggest.java:
package com;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class SearchSuggest extends HttpServlet
{
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, java.io.IOException
{
response.setCharacterEncoding("UTF-8");
String search = request.getParameter("search"); //接受参数值
String sql = "select GoodsName from Goods where GoodsName like '"+search+"%' order by GoodsName";//设置查询语句
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
ArrayList vData = new ArrayList();
java.io.PrintWriter out = response.getWriter();
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); //注册数据库连接驱动
String MdbPath = "F:/sneaker/Tomcat/webapps/search/database/#costume.mdb";
String url= "jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=" + MdbPath ;
conn = DriverManager.getConnection(url);
stmt = conn.createStatement();
rs = stmt.executeQuery(sql); //执行查询
while (rs.next())
{
vData.add(rs.getString("GoodsName"));
}
StringBuilder buf = new StringBuilder();
for (int i=0;i<vData.size();i++)
{
String keyword = (String)vData.get(i);
buf.append(keyword+"\n");
}
out.print(buf.toString());//向客户端输出信息
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (stmt != null)
stmt.close();
if (conn != null)
conn.close();
} catch (SQLException sqle) {
}
}
}
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, java.io.IOException
{
doPost(request, response);
㈢ 如何实现EXCEL实时提取SQL中表的数据
用VBA实现
Sub 连接数据库1()
Set Cnn = CreateObject("ADODB.Connection")
Set rt = CreateObject("ADODB.Recordset")
ID = "localhost"
Cnn.ConnectionString = "Provider = SQLOLEDB;server=" & ID & ";User ID= sa;password=sa;Data Source=" & test & ";" & "Initial Catalog = test"
Cnn.Open
SQL = "select * from 成绩表 "
Set rt = Cnn.Execute(SQL)
With Sheet1
For i = 0 To rt.Fields.Count - 1
.Cells(1, i + 1) = rt.Fields(i).Name
Next i
.Range("a2").CopyFromRecordset rt
.Cells.EntireColumn.AutoFit
End With
Set Cnn = Nothing
Set rt = Nothing
End Sub
㈣ 怎样从HTML网页中获取SQL数据库里的数据
1、sudo su postgres指令进入postgres。
㈤ php连接了数据库 从数据库中提取一系列的数据 怎么样在网页中能自动形成表格形式
直接遍历取出的数版组权
<table>
<?php
$array = array(1, 2, 3, 4, 5, 6, 7);
foreach ($array as $value) {
?>
<tr>
<td><?php echo $value; ?></td>
</tr>
<?php
}
?>
</table>
㈥ SQL每天自动提取上一天数据更新表格
这个实现方法很多要看具体的环境,比如
1、程序开发的话,各种程序语言都有相关的处理
2、ms sqlserver数据库服务器上,有SQL代理的维护计划或job
㈦ 怎样做到使Excel自动读取网页上的数据,然后制表高分!
在获取之前先复制好网站地址,下面是我的一个演示,希望能够帮到你。加载有些慢请耐版心等待之后权,点击观看。
如果网站的数据每天有更新,你可以在查询到的表格中右击鼠标,刷新数据,这样excel就可以在后台进行查询更新。
㈧ 用java实现提取指定网页中的表格数据
把下面代码复制到文本文档中,然后将文本文档改成".html"形式
这个是提取表格中的数据的方法,看看是你想要的不
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!--
//获得table的tr td等属性
function getTableAtt(){
alert('该table有'+document.all.oTabless.rows.length+'个tr')
for (i=0; i < document.all.oTabless.rows.length; i++) {
//循环每个tr里的td
for (j=0; j < document.all.oTabless.rows(i).cells.length; j++) {
alert('第'+(i+1)+'个tr中的第'+(j+1)+'个td的值为:'+document.all.oTabless.rows(i).cells(j).innerText)
}
}
}
//-->
</SCRIPT>
<BODY>
<FORM METHOD=POST ACTION="" name="myform">
<hr>
<TABLE ID=oTabless border = "1">
<TR><TD>1</TD><TD>2</TD><TD>3</TD><TD>4</TD></TR>
<TR><TD>5</TD><TD>6</TD><TD>7</TD><TD>8</TD></TR>
</TABLE>
<INPUT TYPE="button" VALUE="Table" onclick="getTableAtt()">
<hr>
</FORM>
</BODY>
</HTML>
㈨ 网页上做程序(ASP.net)提取数据库的表单数据进行处理
<table width=180 border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#add3ef">
<form action="" method="post">
<input type="submit" name="submit" value="显示出来" />
</form>
<?php
if($_POST['submit']){
$sql="select * from test";
$query=mysql_query($sql);
$row=mysql_fetch_array($query);
}
?>
<tr bgcolor="#eff3ff">
<td>姓名:<?php echo $row[name]?> 生日:<?php echo $row[Birthday]?></td>
</tr>
</table>
点击按钮就显示出 姓名: XXX 生日:XXX
想必怎么添加姓名生日的专值进数据库的字段里你知道了属吧,然后写个判断就可以了呀,
asp.net 也一样吧,这只是我一个简单的思路用PHP表达给你。
㈩ 如何用js脚本实现根据表单输入框的数据自动提取数据库中的其他数据回填到表单中其他文本框,谢谢!
只能给你给步骤:
1.资产编号文本框的onblur()鼠标焦点离开时,发送ajax请求到后台的php页面
2.后台php操作数据库,将结果返回到前台,用js解析返回结果,并将数据显示到相应的文本框中