主题:我的这段代码麻烦大家给看看
我做的新闻系统,截取了一小段,我的这段代码麻烦谁给修改一下,它运行不准确
<?php
/*********
xin wen
*********/
$lnk = mysql_connect('localhost', 'root')
or die ('连接失败 : ' . mysql_error());
if (mysql_select_db('aaa', $lnk));
//echo "已经选择数据库aaa<br>";
else
echo ('数据库选择失败 : ' . mysql_error());
{
$result = mysql_query("select title from news")
or die("<br>查询表news失败: " . mysql_error());
//$note = mysql_query("select note from news")
//or die("<br>查询表news失败: " . mysql_error());
$i = 0;
$cnt = mysql_num_rows($result);
while ($i < $cnt)
{
$vor = mysql_result($result, $i) . "\n<br>";
$j[] = mysql_query("select * from news where id = '$result.id'");
//echo mysql_result($note, $i) . "\n<br>";
// echo mysql_result($note, $i)."\n";
?>
<a href="mmm.php?id<? $j["id"] ?>"><? echo $vor ?></a>
<?
$i++;
}
}
?>
<?php
/*********
*** mmm.php****
**************/<?php
session_start();
@$id =$_SESSION[ trim($j['id'])];
$lnk = mysql_connect('localhost', 'root')
or die ('连接失败 : ' . mysql_error());
if (mysql_select_db('aaa', $lnk));
//echo "已经选择数据库aaa<br>"
else
echo ('数据库选择失败 : ' . mysql_error());
$note =mysql_query("select note from news where id = '$id' ")
or die("<br>查询表news失败: " . mysql_error());
echo mysql_result($note, $id)."\n";
/*?>
[em10][em10][em10][em10][em10][em10][em10]
<?php
/*********
xin wen
*********/
$lnk = mysql_connect('localhost', 'root')
or die ('连接失败 : ' . mysql_error());
if (mysql_select_db('aaa', $lnk));
//echo "已经选择数据库aaa<br>";
else
echo ('数据库选择失败 : ' . mysql_error());
{
$result = mysql_query("select title from news")
or die("<br>查询表news失败: " . mysql_error());
//$note = mysql_query("select note from news")
//or die("<br>查询表news失败: " . mysql_error());
$i = 0;
$cnt = mysql_num_rows($result);
while ($i < $cnt)
{
$vor = mysql_result($result, $i) . "\n<br>";
$j[] = mysql_query("select * from news where id = '$result.id'");
//echo mysql_result($note, $i) . "\n<br>";
// echo mysql_result($note, $i)."\n";
?>
<a href="mmm.php?id<? $j["id"] ?>"><? echo $vor ?></a>
<?
$i++;
}
}
?>
<?php
/*********
*** mmm.php****
**************/<?php
session_start();
@$id =$_SESSION[ trim($j['id'])];
$lnk = mysql_connect('localhost', 'root')
or die ('连接失败 : ' . mysql_error());
if (mysql_select_db('aaa', $lnk));
//echo "已经选择数据库aaa<br>"
else
echo ('数据库选择失败 : ' . mysql_error());
$note =mysql_query("select note from news where id = '$id' ")
or die("<br>查询表news失败: " . mysql_error());
echo mysql_result($note, $id)."\n";
/*?>
[em10][em10][em10][em10][em10][em10][em10]