This topic is locked

Count the Number of ID's

6/13/2006 8:43:07 AM
PHPRunner General questions
D
dieter author

In my Database 'Movies' in the table 'Lent' there is an 'ID' Field with autoincrement and another Field 'Number'.

I'd like to count all entries in a field 'Name' or in 'ID' (e.g. 10 entries in 'ID')

In the add page I would like to have in the field 'Number' the value 11 (10+1), when I load the page.
is this possible ?
(sorry of my bad english)
Dieter

J
Jane 6/14/2006

Hi,
you can do the following:

  1. set $_SESSION["number"] as default value for the Number field on the View format dialog on the Formatting tab.
  2. proceed to the Events tab, select AddOnLoad event and put this code in it:
    function AddOnLoad()

    {

    $strSQL = "select count(ID) from table1";

    $rs = db_query($strSQL,$conn);

    $data=db_fetch_array($rs);

    $_SESSION["number"]=$data["ID"]+1;

    }

D
dieter author 6/15/2006

Hi,

you can do the following:

  1. set $_SESSION["number"] as default value for the Number field on the View format dialog on the Formatting tab.
  2. proceed to the Events tab, select AddOnLoad event and put this code in it:


I think that's it
Thanks