我的SELECT有问题 [英] Problem with my SELECT

查看:68
本文介绍了我的SELECT有问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我有一个带链接的页面


< a href =" Contributor.php?action =& ; SubCat =<?php echo $ row [" writer"];

?>"><?php echo $ row [" writer"];?>< ; / a>


对带有SELECT的页面执行


$ query =" SELECT * FROM news WHERE writer ='' $ SubCat''" ;;


但它没有从数据库中提取任何数据。如果我这样做

$ query =" SELECT * FROM news WHERE writer =''Bob Smith''" ;;

效果很好??




ULR读取 -

Contributor.php?action =& SubCat = Bob%20Smith

so我知道这个链接是正确的....


但是对于我的生活,我不知道SELECT

语句有什么问题?


如果有人能帮我这个,我会永远在你的债务中。


谢谢


这里是完整的Contributor.php脚本。


<!DOCTYPE html

PUBLIC" - // W3C // DTD XHTML 1.0 Strict / / EN"

" http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

< html xmlns = " HTTP://www.w3.org/1999/xhtml" XML:朗= QUOT;恩" lang =" en"><! -

#BeginTemplate" /Templates/journ.dwt" - >

< head>

< meta http-equiv =" content-type" content =" text / html;

charset = ISO-8859-1" />

<! - #BeginEditable" doctitle" - >

< title> paper< / title>

<! - #EndEditable - >

< link rel =" stylesheet" HREF ="样式/ template.css"类型= QUOT;文本/ CSS" />

< / head>

< body>


< div id =" container"> ;

< div id =" logo">< img src =" Images / logo.jpg" border =" 0"

alt =" logo">< / div>

< div id = bar>< form action =" a .PHP" method =" POST">

< label for =" searchtxt">搜索我们的档案:< / label>

< input id =" ; searchtxt"类型= QUOT;文本"名称= QUOT; searchtxt"值= QUOT;" />

< input class =" button"类型= [提交"值= [搜寻" />< / form>

< / div>

< div id =" header">

< ! - #BeginEditable" Adds" - >< div

id =" athlete">< img

src =" ../ Images / Athlete.gif"边界=" 0" alt =" AthleteMonth"

< img src =" ../ Images / AthleteMonth.jpg"

border =" 0"

alt =" AthleteMonth">< br>

Susan smith< / div>

< br>

< ;? include(" Ads.php")?><! -

#EndEditable - >

< / div>

< div id =" sidebar">


< div id = writer>您的新闻< / div>

< div id =" navcontainer">


< ul id =" navlist">

< table>

< ;?

$ query =" SELECT DISTINCT cat FROM news" ;;

$ result = mysql_query($ query)

或die( 不能做。;

while($ row = mysql_fetch_array($ result))

{

?>

< tr>

< td>

< li>< a href =" ../& lt;?php echo $ row [" cat"];?>"><?php echo

$ row [" cat"];?>< / a>< / li> ;

< / td>

< / tr>

<?php

}

?>

< / table>

-------------------- ----

< li>< a href =" Classified.php& >分类广告< / a>< / li>

< li>< a href =" Advertise.php">刊登广告< / a>< / li>

< li>< a href =" About.php">关于我们< / a>< / li>

< li> < a href =" FindUs.php">联系我们< / a>< / li>

< / ul>

< / div>

< div id = writer>访问我们的赞助商< / div>

<! - #BeginEditable" Left" - > {Left}<! -

#EndEditable - >

< / div>

<! - #BeginEditable" middle" - >

<! -

------------------------- - - - - - - - - 新闻 - - - - - - - - - - - - - - - - - ----------------------------

- >

< div id =" content">

< div id =" bodymenu"> News< / div>

< table>

< ;?

$ query =" SELECT * FROM news WHERE writer =''$ SubCat''" ;;

$ result = mysql_query($ query )

或死(不能做。);

while($ row = mysql_fetch_array($ result))

{

?>

< tr>

< td>

< div id =" bodyhead"><?php echo $ row [" heading"];?>< / div>

< / td>

< td> ;

问题:< a href ="#"><?php echo $ row [" date"];?>< / a>

< / td>

< / tr>

< tr>

< / tr>

< tr>

< td colspan = 2&g t;

< div id = bodywords>

<?php

$ abc =($ row [" article"]) ;

$ abc = substr($ abc,0,400);

echo $ abc;

?>

......< span class =" class1">< a href ="#">阅读文章< / a>< / span>

< / div>

< / td>

< / tr>

<?php

}

?>

< / table>

< / div>

<! - #EndEditable - < / div>


< / body>

<! - #EndTemplate - >< / html>

Hi,

I have a page with a link

<a href="Contributor.php?action=&SubCat=<?php echo $row["writer"];
?>"><?php echo $row["writer"];?></a>

that does to a page with a SELECT

$query = "SELECT * FROM news WHERE writer=''$SubCat'' ";

But it is not pulling any data from the database. If I do this
$query = "SELECT * FROM news WHERE writer=''Bob Smith'' ";
works great??

also
the ULR reads -
Contributor.php?action=&SubCat=Bob%20Smith
so I know the link is correct ....

but for the life of me I can''t figure out whats wrong with the SELECT
statement?

If anyone can help me with this I would be forever in your Debt.

Thanks

here is the complete Contributor.php script.

<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><!--
#BeginTemplate "/Templates/journ.dwt" -->
<head>
<meta http-equiv="content-type" content="text/html;
charset=ISO-8859-1" />
<!-- #BeginEditable "doctitle" -->
<title>paper</title>
<!-- #EndEditable -->
<link rel="stylesheet" href="Styles/template.css" type="text/css" />
</head>
<body>

<div id="container">
<div id="logo"><img src="Images/logo.jpg" border="0"
alt="logo"></div>
<div id=bar><form action="a.php" method="POST">
<label for="searchtxt">Search our archives:</label>
<input id="searchtxt" type="text" name="searchtxt" value="" />
<input class="button" type="submit" value="Search" /></form>
</div>
<div id="header">
<!-- #BeginEditable "Adds" --><div
id="athlete"><img
src="../Images/Athlete.gif" border="0" alt="AthleteMonth">
<img src="../Images/AthleteMonth.jpg"
border="0"
alt="AthleteMonth"><br>
Susan smith</div>
<br>
<? include("Ads.php") ?><!--
#EndEditable -->
</div>
<div id="sidebar">

<div id=writer>Your News</div>
<div id="navcontainer">

<ul id="navlist">
<table>
<?
$query = "SELECT DISTINCT cat FROM news";
$result = mysql_query($query)
or die ("no can do.");
while($row = mysql_fetch_array($result))
{
?>
<tr>
<td>
<li><a href="../<?php echo $row["cat"];?>"><?php echo
$row["cat"];?></a></li>
</td>
</tr>
<?php
}
?>
</table>
------------------------
<li><a href="Classified.php">Classified Ads</a></li>
<li><a href="Advertise.php">Advertise With Us</a></li>
<li><a href="About.php">About Us</a></li>
<li><a href="FindUs.php">Contact Us</a></li>
</ul>
</div>
<div id=writer>Visit our Sponsor</div>
<!-- #BeginEditable "Left" -->{Left}<!--
#EndEditable -->
</div>
<!-- #BeginEditable "middle" -->
<!--
-----------------------------------------NEWS-------------------------------------------------------------
-->
<div id="content">
<div id="bodymenu">News</div>
<table>
<?
$query = "SELECT * FROM news WHERE writer=''$SubCat'' ";
$result = mysql_query($query)
or die ("no can do.");
while($row = mysql_fetch_array($result))
{
?>
<tr>
<td>
<div id="bodyhead"><?php echo $row["heading"];?></div>
</td>
<td>
Issue: <a href="#"><?php echo $row["date"];?></a>
</td>
</tr>
<tr>
</tr>
<tr>
<td colspan=2>
<div id=bodywords>
<?php
$abc = ($row["article"]);
$abc=substr($abc,0,400);
echo $abc;
?>
......<span class="class1"><a href="#">Read the article</a></span>
</div>
</td>
</tr>
<?php
}
?>
</table>
</div>
<!-- #EndEditable --</div>

</body>
<!-- #EndTemplate --></html>

推荐答案

row [" writer"];

?>"> <?php echo
row["writer"];
?>"><?php echo


row [" writer"];?>< / a>


对页面执行的操作选择

row["writer"];?></a>

that does to a page with a SELECT


query =" SELECT * FROM news WHERE writer =''
query = "SELECT * FROM news WHERE writer=''


这篇关于我的SELECT有问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆