This topic is locked

CREATE CUSTOM REFERENCE NUMBER

11/26/2010 8:04:56 AM
PHPRunner General questions
C
ckapote author

HI ,
I HAVE A FIELD CALLED REF AND I NEED WHEN A NEW ENTRY IS MADE TO RELEVANT TABLE

THE FIELD 'REF' TO BE AUTOMATICALLY CREATED BEFORE SAVING THE NEW ENTRY .

THE FILED 'REF' TO BE COMPLETED LOOKING TO A TABLE CALLED NAMES FIELD ID PLUS TO ADD

A NUMBER AUTOMATICALLY A NUMBER FROM TABLE CALLED TAPES .

FOR EXAMPLE

TABLE / NAMES / ID = CHR

TABLE / TAPES/ FIELD = 3
REF TO SAVED = CHR/4
IS IT POSSIBLY TO HELP?
RGDS

kujox 11/27/2010



HI ,
I HAVE A FIELD CALLED REF AND I NEED WHEN A NEW ENTRY IS MADE TO RELEVANT TABLE

THE FIELD 'REF' TO BE AUTOMATICALLY CREATED BEFORE SAVING THE NEW ENTRY .

THE FILED 'REF' TO BE COMPLETED LOOKING TO A TABLE CALLED NAMES FIELD ID PLUS TO ADD

A NUMBER AUTOMATICALLY A NUMBER FROM TABLE CALLED TAPES .

FOR EXAMPLE

TABLE / NAMES / ID = CHR

TABLE / TAPES/ FIELD = 3
REF TO SAVED = CHR/4
IS IT POSSIBLY TO HELP?
RGDS


I think it's possible, is this what you're asking?:



global $conn;
$sql = "SELECT * FROM TABLE.NAMES WHERE id='chr'";# change the table name and where statement to your table with the id=chr in it

$result= db_query($sql,$conn);

$table_name=db_fetch_array($result);
$sql = "SELECT MAX(FIELD) AS max_tape FROM table.tapes";# change this to select the tape table

$result= db_query($sql,$conn);

$table_tapes = db_fetch_array($result);
$table_tapes['max_tape'] ++;# increase the number of tapes in the TABLE TAPES by 1
$values['ref'] = $table_name['id'] . "/" . $table_tapes['max_tape'];# combine the values and place in the field ref
C
ckapote author 11/29/2010



I think it's possible, is this what you're asking?:



global $conn;
$sql = "SELECT * FROM TABLE.NAMES WHERE id='chr'";# change the table name and where statement to your table with the id=chr in it

$result= db_query($sql,$conn);

$table_name=db_fetch_array($result);
$sql = "SELECT MAX(FIELD) AS max_tape FROM table.tapes";# change this to select the tape table

$result= db_query($sql,$conn);

$table_tapes = db_fetch_array($result);
$table_tapes['max_tape'] ++;# increase the number of tapes in the TABLE TAPES by 1
$values['ref'] = $table_name['id'] . "/" . $table_tapes['max_tape'];# combine the values and place in the field ref



Thank You Very Much I will test and revert .