ASP显示不正常

来源:百度知道 编辑:UC知道 时间:2024/05/28 10:54:08
<!--#include file="conn.asp"-->
<% set rs=server.createobject("adodb.recordset")
sql="select*from carinfromation,userlist"
rs.open sql,conn,1,1 %>
<%if rs.eof then
response.write"没有车辆信息。"
if session("m")=1 then
response.write"<a href=carinformation.asp>添加车辆信息</A>"
end if
else %>
<table width="1200" border="1" cellpadding="0" cellspacing="0" bgcolor="#bbffff" class="font2">
<th height="25" colspan="11">车辆基本信息</th>
<%if session("m")=1 then %>
<td width="90"><a href="carinformation.asp">添加车辆信息</A></td>
<%end if%>

<tr>
<div align=left><TD height="25" ><font color="

sql="select * from carinfromation,userlist":

你在sql-server里测试过这条sql语句的查询结果吗,你这样查的话,他结果是这样组合的:
依次拿carinformation表里的每一条信息和userlist表里的所有信息组合,如果carinformation表里有3条数据,userlist表里有4条数据的话,那么结果就是:3*4=12条数据了。
具体在你这里说,你在carinformation表里添加了一条信息,而查询结果是8条相同的信息,那么你的userlist表中一定有8条信息,结果才会是象你说的那样.
你应该可以这样改:这两张表肯定有一列是相互联系或者相互对应的吧<我这里假设有id这一列是相互联系的>,那么:
sql="select * from carinfromation as a,userlist as b where a.id=b.id"
也就是说,每一个用户user都只有一条carinfo跟他对应,这个查询是有条件的
你自己再试试看吧。

判断记录集是否为空应当用if rs.bof and rs.eof then
还有,应当在else后循环语句前添加rs.movefirst语句来移动到第一条记录,而每次显示完后loop前再添加rs.movenext来移动下一条记录,判断时使用do while not rs.eof。
应该没有问题了吧?

当然 你的表单<%do while not rs.eof%> 循环着 你这样子写 有多少数据就有多少表单,因为都在里面循环着 自己设计下吧!