PDA

View Full Version : MYSQL ASP query: User post to disply based on the image selected Please help


mimitaro
03-18-2009, 06:43 PM
Hi some ones help will be highly appreciated. Please.

-----------------------------------------
> Admin Table (viewdatadb)
> User Table (userpoststbl)

Admin Table (viewdatatbl) Auto no id = User Table (userpoststbl) field "storeviewdatatblid" ID a integer taken from table (viewdatatbl)
-----------------------------------------

Using a hidden value I have taken the viewdatatbl Auto ID and made to
enter the Users Table (userpoststbl) to the field "storeviewdatatblid" as an Integer.
Now the Table IDS are having matching no.

I am stuck with the query, can some one help me with that please.

Users post should display based on the image selected, and the posts
should list eg: like in youtube.

This is my query:

q1 = "SELECT COUNT(*) FROM userpoststbl "
q2 = "SELECT * FROM userpoststbl, viewdatatbl Where viewdatatbl.id=userpoststbl.storeviewdatatblid ORDER BY storeviewdatatblid ASC LIMIT " & (currentPage - 1) * pageSize & ", " & pageSize

Still this is showing all.



This is the complete code:


<html>

<head>

</head>

<body>

<%
Dim connStrdis
connStrdis = "Driver={MySQL ODBC 5.1 Driver}; Server=localhost;Database=viewdatadb;UID=root;PWD=123456"
set dbConndisplay = server.createObject("ADODB.connection")
dbConndisplay.Open(connStrdis)

%>

<%

Dim rsUserdisplay

Set connCount = Server.Createobject("ADODB.Connection")
connCount.open dbConndisplay

Function excess(argValue)
if not (int(argValue) = argValue) then argValue = int(argValue)+1
excess = argValue
end Function

pageSize = 1

if(len(Request.QueryString("pagina"))=0)then
currentPage = 1
else
currentPage = CInt(Request.QueryString("pagina"))
end if

q1 = "SELECT COUNT(*) FROM userpoststbl "
q2 = "SELECT * FROM userpoststbl, viewdatatbl Where viewdatatbl.id=userpoststbl.storeviewdatatblid ORDER BY storeviewdatatblid ASC LIMIT " & (currentPage - 1) * pageSize & ", " & pageSize

recordCount = connCount.Execute(q1).Fields(0)

Set rsUserdisplay = Server.CreateObject("ADODB.Recordset")
rsUserdisplay.Open q2, connCount

If Not rsUserdisplay.eof Then
Do while not rsUserdisplay.eof

%>

<p><span style="font-family:Tahoma; font-weight:700"><font size="4"><font color="#FF0000"><u>User post data View</u></font> (Based On ID of viewdatatbl Picture)</font></span></p>

<table border="1" width="700" cellspacing="1" bordercolorlight="#E8E6E6" bordercolor="#E8E6E6">
<tr>
<td width="183" bgcolor="#E8E6E6">User name</td>
<td width="152" bgcolor="#E8E6E6">User email</td>
<td bgcolor="#E8E6E6">User comment</td>
<td bgcolor="#E8E6E6" width="183" colspan="2">&nbsp;</td>
</tr>
<tr>
<td width="183" height="19"><%=rsUserdisplay("username")%></td>
<td width="152" height="19"><%=rsUserdisplay("useremail")%></td>
<td height="19"><%=rsUserdisplay("usercomment")%></td>
<td height="19" width="92" align="center"><a href="usererase.asp?ID=<%=rsUserdisplay("userpostid")%>"onClick="return elimina();"><img border="0" src="images/del.gif" width="19" height="19">Delete</a></td>
<td height="19" width="91" align="center"><a href="useredit.asp?ID=<%=rsUserdisplay("userpostid")%>"><img border="0" src="images/edit.gif" width="19" height="19">Edit</a></td>
</tr>
</table>

<br><br>

<%
rsUserdisplay.movenext()
Loop

pageCount = excess(clng(recordCount) / clng(pageSize))

for i = 1 to pageCount
Response.Write("<a href=""userpostdatabyIDpicturepost.asp?pagina=" & i & """>" & i & "</a> ")
next

end if

rsUserdisplay.close
set rsUserdisplay = nothing

connCount.close
set connCount = nothing

%>
</body>

</html>


Still its not showing by Picture and post ID, its displaying all, how should this query be, please help I am a Beginner:

q2 = "SELECT * FROM userpoststbl, viewdatatbl Where viewdatatbl.id=userpoststbl.storeviewdatatblid ORDER BY storeviewdatatblid ASC LIMIT " & (currentPage - 1) * pageSize & ", " & pageSize

Please help.

Thank you.

mimitaro
03-19-2009, 11:34 AM
This is sorted. Anyone wants to make it work add this

sql = "SELECT * FROM userpoststbl, viewdatatbl Where viewdatatbl.id=userpoststbl.storeviewdatatblid AND viewdatatbl.id = " &strIDNum & " ORDER BY storeviewdatatblid "

Also I did add the ID to the back and next button, that was the error that gave not your query. I am sorry.

&id=<%=Request.Querystring("id")%> to the back and next buttons. This worked.

A good gentleman helped me. Thanks to that forum.

Thanks.

Hi some ones help will be highly appreciated. Please.

-----------------------------------------
> Admin Table (viewdatadb)
> User Table (userpoststbl)

Admin Table (viewdatatbl) Auto no id = User Table (userpoststbl) field "storeviewdatatblid" ID a integer taken from table (viewdatatbl)
-----------------------------------------

Using a hidden value I have taken the viewdatatbl Auto ID and made to
enter the Users Table (userpoststbl) to the field "storeviewdatatblid" as an Integer.
Now the Table IDS are having matching no.

I am stuck with the query, can some one help me with that please.

Users post should display based on the image selected, and the posts
should list eg: like in youtube.

This is my query:

q1 = "SELECT COUNT(*) FROM userpoststbl "
q2 = "SELECT * FROM userpoststbl, viewdatatbl Where viewdatatbl.id=userpoststbl.storeviewdatatblid ORDER BY storeviewdatatblid ASC LIMIT " & (currentPage - 1) * pageSize & ", " & pageSize

Still this is showing all.



This is the complete code:


<html>

<head>

</head>

<body>

<%
Dim connStrdis
connStrdis = "Driver={MySQL ODBC 5.1 Driver}; Server=localhost;Database=viewdatadb;UID=root;PWD=123456"
set dbConndisplay = server.createObject("ADODB.connection")
dbConndisplay.Open(connStrdis)

%>

<%

Dim rsUserdisplay

Set connCount = Server.Createobject("ADODB.Connection")
connCount.open dbConndisplay

Function excess(argValue)
if not (int(argValue) = argValue) then argValue = int(argValue)+1
excess = argValue
end Function

pageSize = 1

if(len(Request.QueryString("pagina"))=0)then
currentPage = 1
else
currentPage = CInt(Request.QueryString("pagina"))
end if

q1 = "SELECT COUNT(*) FROM userpoststbl "
q2 = "SELECT * FROM userpoststbl, viewdatatbl Where viewdatatbl.id=userpoststbl.storeviewdatatblid ORDER BY storeviewdatatblid ASC LIMIT " & (currentPage - 1) * pageSize & ", " & pageSize

recordCount = connCount.Execute(q1).Fields(0)

Set rsUserdisplay = Server.CreateObject("ADODB.Recordset")
rsUserdisplay.Open q2, connCount

If Not rsUserdisplay.eof Then
Do while not rsUserdisplay.eof

%>

<p><span style="font-family:Tahoma; font-weight:700"><font size="4"><font color="#FF0000"><u>User post data View</u></font> (Based On ID of viewdatatbl Picture)</font></span></p>

<table border="1" width="700" cellspacing="1" bordercolorlight="#E8E6E6" bordercolor="#E8E6E6">
<tr>
<td width="183" bgcolor="#E8E6E6">User name</td>
<td width="152" bgcolor="#E8E6E6">User email</td>
<td bgcolor="#E8E6E6">User comment</td>
<td bgcolor="#E8E6E6" width="183" colspan="2">&nbsp;</td>
</tr>
<tr>
<td width="183" height="19"><%=rsUserdisplay("username")%></td>
<td width="152" height="19"><%=rsUserdisplay("useremail")%></td>
<td height="19"><%=rsUserdisplay("usercomment")%></td>
<td height="19" width="92" align="center"><a href="usererase.asp?ID=<%=rsUserdisplay("userpostid")%>"onClick="return elimina();"><img border="0" src="images/del.gif" width="19" height="19">Delete</a></td>
<td height="19" width="91" align="center"><a href="useredit.asp?ID=<%=rsUserdisplay("userpostid")%>"><img border="0" src="images/edit.gif" width="19" height="19">Edit</a></td>
</tr>
</table>

<br><br>

<%
rsUserdisplay.movenext()
Loop

pageCount = excess(clng(recordCount) / clng(pageSize))

for i = 1 to pageCount
Response.Write("<a href=""userpostdatabyIDpicturepost.asp?pagina=" & i & """>" & i & "</a> ")
next

end if

rsUserdisplay.close
set rsUserdisplay = nothing

connCount.close
set connCount = nothing

%>
</body>

</html>


Still its not showing by Picture and post ID, its displaying all, how should this query be, please help I am a Beginner:

q2 = "SELECT * FROM userpoststbl, viewdatatbl Where viewdatatbl.id=userpoststbl.storeviewdatatblid ORDER BY storeviewdatatblid ASC LIMIT " & (currentPage - 1) * pageSize & ", " & pageSize

Please help.

Thank you.