The reapeating dilema

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Lemune

    #1

    The reapeating dilema

    Sorry if I have many question. This is because I just new to html stuff

    including php and mysql. My new problem is about php that connect to
    mysql. I have this idea about updating record about document tracking.
    But when I run my script for the first time in one session, there is no

    problem, but when I add new record it does repeating. I meant when the
    first
    time I entry the data the number is 1, the second time I doing it
    the number became 3. I checked the database; I got
    confused because it has the record between number 1 and number 3. Use 2

    table tbltahun and tblsurat This is my script:
    require_once("s urat.php");
    session_start() ;
    $year_now=date( "Y");
    $r_year=mysql_q uery("Select Number,Year from tblyear where
    Year='$year_now '");
    if (mysql_num_rows ($r_year)!=1)
    {
    //if there is no number create new
    $new_digit=1;
    }
    else
    {
    $new_digit=mysq l_result($r_yea r,0)+1;
    $r_new_digit=my sql_query("UPDA TE tblyear SET Number='$new_di git' WHERE
    Year='$year_now '");
    }
    -
    -
    $new_number="$n ew_digit/$new_company/$new_location/$new_month/$new_year";

    -
    -
    -
    $s_query_save=" insert into tblmail values
    ('','$new_numbe r','$topic','$a ttach','$destin ation','$up','$ date','$UserNam e','$division
    ','$modif','')" ;
    $r_new_number=m ysql_query($s_q uery_save);
    if (!$r_new_number )
    {
    // some code to tell there is something wrong
    exit;
    }
    else
    {
    echo "$new_numbe r";

Working...