Click to See Complete Forum and Search --> : how to pull out from one category only, rather than all


karen987
11-08-2007, 06:20 PM
The code below is for an asp page (author.asp) that pulls out a list of authors in a given category, from a news weblog. In this case, the category id (CID) is "37" . So the page should list all authors from category "37"

However it seems to pull out authors from all the categories. I think the code may be misplaced a bit, can anyone see what is wrong with it? It needs to be tweaked so that it only draws out from category "37"

i have tried the top bit so that it is
<!--#include file="inc_header.asp"-->


<%
Dim CID
CID = Trim(Request.QueryString("CID=37"))
%>
but it still pulls out all the authors

Thanks in advance

<!--#include file="inc_header.asp"-->


<%
Dim CID
CID = Trim(Request.QueryString("CID"))
%>


<table width="600" align="center" cellpadding="2" cellspacing="0" border="0">
<td width="600" align="center" valign="top">
<table width="600" border="0" align="center">
<tr>
<th width="189" valign="top" scope="col"> </th>
</tr>
</table><br />
<table width="600" height="116" border="0" align="center" cellpadding="0" cellspacing="0" valign="top">


<% Dim I

IF IS_VALID_ID(CID) THEN
CID_SQL = " WHERE ID IN (SELECT fldAID FROM nm_tbl_news WHERE ID IN (SELECT fldNEWS_ID FROM nm_tbl_news_cate WHERE fldCATE_ID = " & CID & "))"
END IF


Call OPEN_DB()

I = 1
SQL = "SELECT ID, fldNAME, fldEMAIL, fldWEB, fldIMAGE, fldBIO FROM nm_tbl_agent " & CID_SQL & " ORDER BY fldNAME ASC"

Set RS = Server.CreateObject("ADODB.Recordset")
RS.LockType = 1
RS.CursorType = 0
RS.Open SQL, MyConn
WHILE NOT RS.EOF
ID = RS("ID")
NAME = RS("fldNAME")
EMAIL = RS("fldEMAIL")
WEB = RS("fldWEB")
IMAGE = RS("fldIMAGE") & ""
BIO = RS("fldBIO")
%>
<%IF I = 1 THEN%>

<tr><td width="33%" align="left" valign="top" bordercolor="#E5E5E5" style="padding: 5px;"><div align="justify">
<%IF NOT (IMAGE = "" OR IsNull(IMAGE)) THEN%>
<img src="<%=IMAGE%>" width="70" height="80" border="0" align="left" />
<%END IF%>

<a href="articles.asp?AID=<%=ID%>&NAME=<%=Server.URLEncode(NAME)%>" class="MainMenuLNK"><%=NAME%></a><%=BIO%></div><hr width="100%" size="1" style="color: #4169E1;height: 1px;width: 100%;" /></td>
<%END IF%>
<%IF I = 2 THEN%>
<td width="34%" align="left" valign="top" bordercolor="#E5E5E5" style="padding: 5px;"><div align="justify">
<%IF NOT (IMAGE = "" OR IsNull(IMAGE)) THEN%>
<img src="<%=IMAGE%>" width="70" height="80" border="0" align="left" />
<%END IF%>
<a href="articles.asp?AID=<%=ID%>&NAME=<%=Server.URLEncode(NAME)%>" class="MainMenuLNK"><%=NAME%></a> <%=BIO%></div><hr width="100%" size="1" style="color: #ffa626;height: 1px;width: 100%;" /></td>
<%END IF%>
<%IF I = 3 THEN%>
<td width="33%" align="left" valign="top" bordercolor="#E5E5E5" style="padding: 5px;"><div align="justify">
<%IF NOT (IMAGE = "" OR IsNull(IMAGE)) THEN%>
<img src="<%=IMAGE%>" width="70" height="80" border="0" align="left" />
<%END IF%>
<a href="articles.asp?AID=<%=ID%>&NAME=<%=Server.URLEncode(NAME)%>" class="MainMenuLNK"><%=NAME%></a> <%=BIO%></div><hr width="100%" size="1" style="color: #4169E1;height: 1px;width: 100%;" /></td>
</tr>



<%END IF%>
<%
I = I + 1
IF I > 3 THEN I = 1
RS.MoveNext
WEND
RS.Close
Set RS = Nothing

MyConn.Close
Set MyConn = Nothing

%>

</TR>
</TABLE>
<!--#include file="inc_footerAuthors.asp"-->

edborva
11-09-2007, 07:27 PM
CID_SQL one variable and so much informaton. Post this on the webdeveloper.com sql forum. They love this kind of challange.

hope this is helpfull

ed