List Info

Thread: The reapeating dilema




The reapeating dilema
user name
2006-05-01 09:58:45
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. If I logout first there is no problem. But when I
add new
record without logout first it does repeating. I meant when
the first
time I entry the data the number is 1, the second time I
doing it
without log out 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("surat.php");
session_start();
$t_now=date("Y");
$r_tahun=mysql_query("Select Nomer,Tahun from tbltahun
where
Tahun='$t_now'");
if (mysql_num_rows($r_tahun)!=1)
{
//if there is no number create new
$new_angka=1;
}

else
{
$new_angka=mysql_result($r_tahun,0)+1;
$r_new_angka=mysql_query("UPDATE tbltahun SET
Nomer='$new_angka' WHERE
Tahun='$t_now'");
}

-
-
$new_number="$new_angka/$new_perusahaan/$new_lokasi/$n
ew_bulan/$new_year";
-
-
-
$s_query_simpan="insert into tblsurat values
('','$new_number','$perihal','$lampiran','$tujuan'
,'$up','$tanggal','$NamaUser','$divisi','$modif',
'')";
$r_new_number=mysql_query($s_query_simpan);

if (!$r_new_number)
{
// some code to tell there is something wrong
exit;
}

else
{

echo "$new_number";


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "PHP & MySQL" group.
To post to this group, send email to phpmysqlgooglegroups.com
To unsubscribe from this group, send email to
phpmysql-unsubscribegooglegroups.com
For more options, visit this group at http://groups
.google.com/group/phpmysql
-~----------~----~----~----~------~----~------~--~---

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )