Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 21
  1. #1
    New Coder
    Join Date
    Aug 2007
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Max entires HELP??

    Hi,

    I dont know if this is possible, and i know to some it's a little crude what i want to do, but im still learning so bare with me.

    What im aiming to do is limit the ammount of entries a user can put in, the way i want to do it is set a max by using assigning it in the login session which is how i send the account id page to page.


    SELECT data yada yada yada from table where id=12example

    if result count = > "5[provided by session]" then response.write" no more allowed"
    else response.write "click here to add more"

    How do i get the page to count the number of results found based on the query and if it is more than > the number in the session data give an error, i know it shold look similar but i have no experience with restricting queries.

    any guidance appreciated.

    does any of this make sense?

    Chris.

  • #2
    Regular Coder westmatrix99's Avatar
    Join Date
    Dec 2006
    Location
    South Africa
    Posts
    307
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Thumbs up

    This code you put right at the top of your sibmission page.
    Code:
    <%
    Dim postlimit, total
    postlimit = 2 'your lmit that you want
    total = (rsLimit_total) 'your recordset total
    If total => postlimit then
    Response.redirect "error.asp"
    End If
    %>
    Have fun.
    Last edited by westmatrix99; 08-18-2007 at 08:50 AM. Reason: More info...
    Thanks for you support!

  • #3
    New Coder
    Join Date
    Aug 2007
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have done the following

    <%
    Dim postlimit, total
    postlimit = 2 'your lmit that you want
    Set rsLimit = Server.CreateObject("ADODB.Recordset")
    strSQL = "SELECT [id] FROM table WHERE strGroup ='bob"
    rsLimit.Open strSQL, adoCon
    total = (rsLimit_total) 'your recordset total
    If total => postlimit then
    Response.redirect "error.asp"
    End If
    %>

    It does not work, however if i change the vaule to 0 it goes to error.asp, any ideas??

  • #4
    Regular Coder westmatrix99's Avatar
    Join Date
    Dec 2006
    Location
    South Africa
    Posts
    307
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Cool

    Changing the code to that, makes no sense now.

    You have the code on top of page:
    Code:
     
    <%
    Dim postlimit, total
    postlimit = 2 'your lmit that you want
    total = (rs_recordset_total) 'your recordset total
    If total => postlimit then
    Response.redirect "error.asp"
    End If
    %>
    You have your recordset and your recordset name is what you need above.
    Code:
     <%
    Set rs_recordset= Server.CreateObject("ADODB.Recordset")
    rs_recordset.ActiveConnection = conn_STRING
    rs_recordset.Source = "SELECT *  FROM table"
    rs_recordset.CursorType = 0
    rs_recordset.CursorLocation = 2
    rs_recordset.LockType = 1
    rs_recordset.Open()
    %>
    Make sense?
    Thanks for you support!

  • #5
    Regular Coder westmatrix99's Avatar
    Join Date
    Dec 2006
    Location
    South Africa
    Posts
    307
    Thanks
    12
    Thanked 0 Times in 0 Posts
    Post your "select query" not the entire page.
    Thanks for you support!

  • #6
    New Coder
    Join Date
    Aug 2007
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hmm, not really, i open the db connection by using an include in the top of the page:

    <<inside include file>>

    Set adoCon = Server.CreateObject("ADODB.Connection")

    src = Server.MapPath("/users.mdb")
    sConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & src
    adoCon.Open sConnStr

    <<end>>

    Sorry if i appear dumb, im still learning.

  • #7
    Regular Coder westmatrix99's Avatar
    Join Date
    Dec 2006
    Location
    South Africa
    Posts
    307
    Thanks
    12
    Thanked 0 Times in 0 Posts
    Ok so you have this:

    <?'connection.php'?>
    Then
    <? The select statement is what I need ?>
    Then whatever stuff you need
    Then
    <?Close connection?>
    Post the select statement.
    Thanks for you support!

  • #8
    New Coder
    Join Date
    Aug 2007
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts
    "SELECT * FROM posts WHERE strGroup ='bob'" strgroup contains the username

  • #9
    Regular Coder westmatrix99's Avatar
    Join Date
    Dec 2006
    Location
    South Africa
    Posts
    307
    Thanks
    12
    Thanked 0 Times in 0 Posts
    OK, Please Post the entire page that you need this to work on.
    Thanks for you support!

  • #10
    New Coder
    Join Date
    Aug 2007
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts
    <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
    <!--#include file="includes/dbconn.inc"--> Which is contains the above

    <%
    Dim postlimit, total
    postlimit = 2 'your lmit that you want
    Set rsLimit = Server.CreateObject("ADODB.Recordset")
    strSQL = "SELECT * FROM posts WHERE strGroup ='bob'" << this is where i need it to give me the total number of posts from "BOB"
    rsLimit.Open strSQL, adoCon
    total = (rsLimit_total) 'your recordset total
    If total => postlimit then
    Response.redirect "error.asp"
    End If
    %>

    The rest of the page will be a form that allows the user to submit another entry if they have 2 or less posts.

    Confused?

  • #11
    Regular Coder westmatrix99's Avatar
    Join Date
    Dec 2006
    Location
    South Africa
    Posts
    307
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Thumbs up

    Try this, with your recordset name which is "strSQL"
    PHP Code:
    <%
    Dim postlimittotal
    postlimit 
    'your lmit that you want
    total = (strSQL_total) '
    your recordset total
    If total => postlimit then
    Response
    .redirect "error.asp"
    End If
    %>
    <%
    strSQL "SELECT * FROM posts WHERE strGroup = 'bob'"
    rsLimit.Open strSQLadoCon
    strSQL_total should be your total records 
    for that user or select statement.
    %> 
    Thanks for you support!

  • #12
    Regular Coder westmatrix99's Avatar
    Join Date
    Dec 2006
    Location
    South Africa
    Posts
    307
    Thanks
    12
    Thanked 0 Times in 0 Posts
    Working?
    Yes or No would do.
    Thanks for you support!

  • #13
    New Coder
    Join Date
    Aug 2007
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts
    No joy,

    I thought i needed to give the recordset a name

    if i run the code you said it comes back with

    Object required: 'rsLimit'

    If i change it to
    <%
    Dim postlimit, total
    postlimit = 1 'your lmit that you want
    total = (rsLimit_total) 'your recordset total
    If total => postlimit then
    Response.redirect "error.asp"
    End If
    %>

    <%
    Set rsLimit = Server.CreateObject("ADODB.Recordset")
    strSQL = "SELECT * FROM posts WHERE strGroup = 'bob'"
    rsLimit.Open strSQL, adoCon
    'strSQL_total should be your total records.
    %>

    it works it just does not work with the > more than unless i set it to 0 i read somewhere something about recordsets resulting in -1 or something.

    the table looks like

    date entry strGroup
    03/03/03 My name is bob bob
    04/03/03 hello again test bob

    Do i need to loop through them or something?

  • #14
    Regular Coder westmatrix99's Avatar
    Join Date
    Dec 2006
    Location
    South Africa
    Posts
    307
    Thanks
    12
    Thanked 0 Times in 0 Posts
    Copy and paste the code I added your'e code seems wrong.

    You are using Capital letters instead of Dimmed letters which are small letters.

    Look at the code I posted use that first then come back and say YAY or NAY.
    Thanks for you support!

  • #15
    New Coder
    Join Date
    Aug 2007
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Nay


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •