473,394 Members | 1,878 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

appear time onclick a button and save the time in a database

i want to make a button in an attendance table when the user click on this button the current time appears as a departure time for customer and how to save this time in my database. here's my code.
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $con=mysql_connect("localhost","root","admin");
  3. mysql_query("set character_set_server='utf8'");
  4. mysql_query("set names 'utf8'");
  5. if(!$con)
  6. {
  7.     die('couldnot connect:');
  8. }
  9.  
  10. mysql_select_db("santirino",$con);
  11. @$user_id = $_POST['ID'];
  12. echo "
  13. <table class='bordered' align='center'> <thead> <tr> <th style='text-align:center;' nowrap='nowrap'> وقت الأنصراف </th> <th style='text-align:center;' nowrap='nowrap'> وقت الحضور </th> <th style='text-align:center;' nowrap='nowrap'> التاريخ </th> <th style='text-align:center;' nowrap='nowrap'> اسم العضو </th> <th style='text-align:center;' nowrap='nowrap'> رقم العضو </th> <th style='text-align:center; height='10px';' nowrap='nowrap'> المسلسل </th> </tr> </thead>
  14.     ";
  15. echo $today = date("20y-m-d"). "   ";
  16. $todayDate = date("Y-m-d g:i a");// current date
  17. $currentTime = time($todayDate); //Change date into time
  18. $timeAfterOneHour = $currentTime+60*60;
  19.  
  20. echo $time = date("H:i:s",$timeAfterOneHour);
  21.  
  22. if($time >= "16:00:00")
  23. {
  24.     $sql="select * from members where id = '$user_id'";
  25.     $result = mysql_query($sql);
  26.  
  27.     $get_all="select * from attendance where date = '$today'";//select all members in current date
  28.     $result_getall = mysql_query($get_all);
  29.     $i;
  30.     echo "<br />";
  31.     while($row = mysql_fetch_array($result))
  32.     {
  33.         @$i++;
  34.         mysql_query("set character_set_server='utf8'");
  35.         mysql_query("set names 'utf8'");
  36.         $query_sql = "INSERT INTO attendance (id,date,name,time) VALUES ('$user_id','$today','$row[name]','$time')";
  37.         $res = mysql_query($query_sql);
  38.          echo "<tr>"
  39.          ."<td style='text-align:center;'><form><button>انصرف</button></form></td>"
  40.          ."<td style='text-align:center;'>".$time."</td>"
  41.          ."<td style='text-align:center;'>".$today."</td>"
  42.          ."<td style='text-align:center;' nowrap='nowrap'>".$row['name']."</td>"
  43.          ."<td style='text-align:center;' nowrap='nowrap'>".$row['id']."</td>"
  44.          ."<td style='text-align:center;' nowrap='nowrap'>".$i."</td>"
  45.          ."</tr>";
  46.     }
  47.     while($row = mysql_fetch_array($result_getall))
  48.     {
  49.         if($row['id'] == $user_id)
  50.         {
  51.             echo "<script> alert('العضو مسجل بالفعل') </script>";
  52.         }
  53.         else
  54.         {
  55.             @$i++;
  56.                  echo "<tr>"
  57.                  ."<td style='text-align:center;'><form><button>انصرف</button></form></td>"
  58.                  ."<td style='text-align:center;' nowrap='nowrap'>".$row['time']."</td>"
  59.                  ."<td style='text-align:center;' nowrap='nowrap'>".$row['date']."</td>"
  60.                  ."<td style='text-align:center;' nowrap='nowrap'>".$row['name']."</td>"
  61.                  ."<td style='text-align:center;' nowrap='nowrap'>".$row['id']."</td>"
  62.                  ."<td style='text-align:center;' nowrap='nowrap'>".$i."</td>"
  63.                  ."</tr>";
  64.         }
  65.     }
  66. }
Nov 28 '12 #1
1 4307
Rabbit
12,516 Expert Mod 8TB
There's a lot of code there. Which part are you having trouble with? I see code in there already to insert data into the database so I'm not sure what it is you're struggling with.
Nov 28 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: DAVID | last post by:
Hello, With regards to the Connect dialog on Oracle forms 6i via which we can connect to Oracle database, should we use the same functionality on forms run time again? I mean, I want to make a...
1
by: softengine | last post by:
What are the pros and cons of Design-Time binding versus Run-Time binding controls? Our senior engineer is adamant about not binding control during design-time. Are there differences in...
5
by: Raziq Shekha | last post by:
Hello all, Is there a way to figure out when was the last time someone connected to a database? SQL 2000 environment. Thanks, Raziq.
4
by: Hazzard | last post by:
What is the best way to do this? Binary with 0 representing off and 1 on? Int16 with 1 representing first button, 2 the second, 3 ... varchar with a character values at certain positions in the...
2
by: Salim Afsar | last post by:
Hi, My web server is not my country, so server's time and my country time is different. So code runs on server, for example when I run DateTime.Now() function it returns server time but I want...
2
by: kiju8 | last post by:
what are the ways of inserting radio button into the database, is there a way to put it in textual form just like making the path to the images.
2
by: idealfellow | last post by:
I am using the following to get the time: puts Time.now --> starting of my script <MY CODE> puts Time.now --> end of my script I want to get the Time difference between two Time.now...
4
by: JuAn2226 | last post by:
Hi, can anyone help me . when my program starts there is numbers and time will be display in the form of visual basic. it will run continuesly .My problem here is i dont know how to display the data...
10
by: orajat | last post by:
hi, how do i setup a command button on a page form that when clicked, saves system time in a particular field of a table ?
0
by: roy madimutsa | last post by:
I have a problem linking VB6.0 login button and the database were the names and passwords are kept.It would be great if you tell me how to link the VB6 application and database
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.