CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 Editable grid and limits

Print topic Send  topic

Author Message
songohan

Posts: 89
Posted: 04/15/2008, 7:19 AM

Hi all!

Situation is like this. On one page user should be able to give answers to a question (eg. what are your favourite websites?). I plan to use editable grid for answers.

Now thing is, I would like to control max number of answers. Also, user should be able to change his mind (that is why I use editable grid) .

I thought about hiding new record input field if record count is greater than decided limit but how to do that?

Many thanks,

Andrej
View profile  Send private message
DonP
Posted: 04/15/2008, 4:25 PM

If visitors are not logging in, possibly you can set a numeric session
value when someone enters the site that will act as a user ID of sorts.
Maybe it can be a randomly-generated number which, when used in
combination with their IP address, should prevent anyone else from
having the same combination and will allow them to edit the entries for
as long as they are on the site or until the session expires.

If you want them to be able to come back at a later time and still be
able to edit, a cookie would be better but the visitor would need to
have cookies enabled. Using cookies would also prevent (or minimize) the
possibly of them coming back to the site a little while later and adding
more entries.

These values could be added to their entries, then CCS settings to allow
for only four blank fields, and Before Show event to dynamically change
that value if they already have entries so that no more than four would
show whether populated or not.

The Before Show event could have something like this, presuming that a
session value was set for VisitorID and VisitorIP:

$EntryCount =
CCDLookUp("COUNT(ID)","tablename","VisitorID=".CCGetSession("VisitorID")."
AND VisitorIP=".CCGetSession("VisitorID"), $DBconn);

$MaxCount = 4;
$GridName->EmptyRows = ($MaxCount - $EntryCount);

If it gives at error when EmptyRows = 0, you'll have to add a
conditional to prevent it.

Don (DonP)

songohan wrote:
> Hi all!
>
> Situation is like this. On one page user should be able to give answers to a
> question (eg. what are your favourite websites?). I plan to use editable grid
> for answers.
>
> Now thing is, I would like to control max number of answers. Also, user should
> be able to change his mind (that is why I use editable grid) .
>
> I thought about hiding new record input field if record count is greater than
> decided limit but how to do that?
>
> Many thanks,
>
> Andrej
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.yessoftware.com/
>
songohan

Posts: 89
Posted: 04/15/2008, 11:57 PM

Thnaks!

Exactly what I had on my mind. Well I thought about using current datetime + random number to identify users (there is no registration).

Would it be ok to use sessionID to identfy users? What are chances that two users have same sesionID in time?

Regards,

Andrej
View profile  Send private message
DonP
Posted: 04/16/2008, 8:57 AM

First, there was a typo in my original code. This line:

$EntryCount =
CCDLookUp("COUNT(ID)","tablename","VisitorID=".CCGetSession("VisitorID")."
AND VisitorIP=".CCGetSession("VisitorID"), $DBconn);

should be:

$EntryCount =
CCDLookUp("COUNT(ID)","tablename","VisitorID=".CCGetSession("VisitorID")."
AND VisitorIP=".CCGetSession("VisitorIP"), $DBconn);

You could use the SessionID as it would be unique to each visitor but
it's an awfully long string. I use a little function that I found
somewhere (possibly on the php.net site) that does a good job. I have it
in an external file that is included in at the bottom of Common.php but
you can paste the code there directly too.

// Generates random non-integer characters
// Usage: randchar(2) for two characters, up to 36 characters

function randchr( $length ) {
if ( $length > 36 ) {
return "ERROR";
} else {
$str = md5(mktime());
$cutoff = 31 - $length;
$start = rand(0, $cutoff);
return substr($str, $start, $length);
}
}

You can call it by using randchar(10) where 10 is the length of the
string, which should be long enough to sufficiently randomize it.

Don (DonP)

songohan wrote:
> Hi all!
>
> Situation is like this. On one page user should be able to give answers to a
> question (eg. what are your favourite websites?). I plan to use editable grid
> for answers.
>
> Now thing is, I would like to control max number of answers. Also, user should
> be able to change his mind (that is why I use editable grid) .
>
> I thought about hiding new record input field if record count is greater than
> decided limit but how to do that?
>
> Many thanks,
>
> Andrej
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.yessoftware.com/
>

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.