文章目录:
谁有城市公交线路查询系统换乘的源代码,急求。(数据库是SQL. SERVER 工具是vs200
1、config.php(功能说明:存储一些在整个程序中要用到全局变量。)
?
$hostname="localhost";
$db_user="root";
$db_password="faleier2046007";
$db_name="bus";
$table_Stop="bus_stop";
$table_Route="bus_route";
$table_Stop_Route="bus_stop_route";
$table_RouteT0="bus_routet0";
$table_GRouteT0="bus_groutet0";
$table_nochange="temp_nochange";
$table_once="temp_once";
$table_twice="temp_twice";
?
2、conn.php(功能说明:实现与数据库的连接。)
?php
require_once "config.php";
@mysql_connect($hostname,$db_user,$db_password)
or die("could not connect to mysql server");
@mysql_select_db("$db_name") or die("could not select database");
13/22页
mysql_query("set character set gb2312");
?
3、index.php(功能说明:程序首页,查询输入界面。) !DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" HTML
HEAD
meta http-equiv="Content-Type" content="text/html; charset=gb2312" TITLE 六安公交查询系统 /TITLE
META NAME="Generator" CONTENT="EditPlus"
META NAME="Author" CONTENT=""
META NAME="Keywords" CONTENT=""
META NAME="Description" CONTENT=""
/HEAD
BODY background="images/bj.gif"
script type="text/javascript" src="js/main.js"/script
link href="css/bus.css" rel="stylesheet" type="text/css"
media="screen" /link href="css/bus1.css" rel="stylesheet" type="text/css" media="screen" /
table border=0 align=center
tr
td height=100
/td
/tr
tr
td
TABLE border=0 align=center height=300 width=630 bgcolor="#EDF3CD" tr
td colspan=3 align=center height=25%
img border="0" src="images/banner.jpg" width="400" height="75"/td /tr
tr
td width=231 rowspan="3"
table border=0
tr
td
?php
require "conn.php";
$query_all_path="select distinct(RouteGenName) from $table_Route"; $info=mysql_query($query_all_path);
while($it=mysql_fetch_array($info))
{
echo "a
14/22页
href=searchpath.php?path=$it[RouteGenName]".$it['RouteGenName']."/a"." ";
}
?
/table
/td
td width=4 height="19"
/td
td width="381" rowspan="3"
div class="fdae-908c-0a25-01ae headRi"
div class="908c-0a25-01ae-5c9a headMenu"
span id="it_1" onclick="ishow('it',3,1,'open','')" class=
[急求]公交线路查询系统
邹老大的书。
CREATE TABLE T_Line(
ID nvarchar(10), --公交线路号
Station nvarchar(10), --站点名称
Orders int) --行车方向(通过它反应每个站的上一个、下一个站)
INSERT T_Line
SELECT N'8路' ,N'站A',1 UNION ALL
SELECT N'8路' ,N'站B',2 UNION ALL
SELECT N'8路' ,N'站C',3 UNION ALL
SELECT N'8路' ,N'站D',4 UNION ALL
SELECT N'8路' ,N'站J',5 UNION ALL
SELECT N'8路' ,N'站L',6 UNION ALL
SELECT N'8路' ,N'站M',7 UNION ALL
SELECT N'20路' ,N'站G',1 UNION ALL
SELECT N'20路' ,N'站H',2 UNION ALL
SELECT N'20路' ,N'站I',3 UNION ALL
SELECT N'20路' ,N'站J',4 UNION ALL
SELECT N'20路' ,N'站L',5 UNION ALL
SELECT N'20路' ,N'站M',6 UNION ALL
SELECT N'255路',N'站N',1 UNION ALL
SELECT N'255路',N'站O',2 UNION ALL
SELECT N'255路',N'站P',3 UNION ALL
SELECT N'255路',N'站Q',4 UNION ALL
SELECT N'255路',N'站J',5 UNION ALL
SELECT N'255路',N'站D',6 UNION ALL
SELECT N'255路',N'站E',7 UNION ALL
SELECT N'255路',N'站F',8
GO
--乘车线路查询存储过程
CREATE PROC p_qry
@Station_Start nvarchar(10),
@Station_Stop nvarchar(10)
AS
SET NOCOUNT ON
DECLARE @l int
SET @l=0
SELECT ID,Station,
Line=CAST('('+RTRIM(ID)+': '+RTRIM(Station) as nvarchar(4000)),
Orders=Orders,
[Level]=@l
INTO # FROM T_Line
WHERE Station=@Station_Start
WHILE @@ROWCOUNT0
AND NOT EXISTS(SELECT * FROM # WHERE Station=@Station_Stop)
BEGIN
SET @l=@l+1
INSERT #(Line,ID,Station,Orders,[Level])
SELECT
Line=a.Line+CASE
WHEN a.ID=b.ID THEN N'-'+RTRIM(b.Station)
ELSE N') ∝ ('+RTRIM(b.ID)
+N': '+RTRIM(b.Station) END,
b.ID,b.Station,b.Orders,@l
FROM # a,T_Line b
WHERE a.[Level]=@l-1
AND(a.Station=b.Station AND a.IDb.ID
OR a.ID=b.ID AND(
a.Orders=b.Orders+1
OR
a.Orders=b.Orders-1))
AND LEN(a.Line)4000
AND PATINDEX('%[ ]'+b.Station+'[-)]%',a.Line)=0
END
SELECT N'起点站'=@Station_Start
,N'终点站'=@Station_Stop
,N'乘车线路'=Line+N')'
FROM #
WHERE [Level]=@l
AND Station=@Station_Stop
IF @@ROWCOUNT =0 --如果未有可以到达的线路,则显示处理结果表备查
SELECT * FROM #
GO
--调用
EXEC p_qry N'站A',N'站L'
/*--结果
起点站 终点站 乘车线路
---------- ------------ -----------------------------------------------------------
站A 站L (8路: 站A-站B-站C-站D-站J-站L)
--*/
c#公交车路线查询源代码
第一需要数据库,第二查询可能也是比较复杂的,可能用到分词,模糊搜索,换乘查询.
邹老大的书。CREATE TABLE T_Line(ID nvarchar(10), --公交线路号Station nvarchar(10), --站点名称Orders int) --行车方向(通过它反应每个站的上一个、下一个站
er2046007";$db_name="bus";$table_Stop="bus_stop";$table_Route="bus_route";$table_Stop_Route="bus_stop_route";$ta