You are here: The reapeating dilema « All PHP « IT news, forums, messages
The reapeating dilema

Posted by Lemune on 09/28/88 11:46

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("surat.php");
session_start();
$year_now=date("Y");
$r_year=mysql_query("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=mysql_result($r_year,0)+1;
$r_new_digit=mysql_query("UPDATE tblyear SET Number='$new_digit' WHERE
Year='$year_now'");
}
-
-
$new_number="$new_digit/$new_company/$new_location/$new_month/$new_year";

-
-
-
$s_query_save="insert into tblmail values
('','$new_number','$topic','$attach','$destination','$up','$date','$UserName','$division
','$modif','')";
$r_new_number=mysql_query($s_query_save);
if (!$r_new_number)
{
// some code to tell there is something wrong
exit;
}
else
{
echo "$new_number";

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация