PHP - Attendance Table
Two question? 1. When i click 'Go' , how to fill DATE row all dates of the date range in the two text box
2. how to keep textbox for all IN and OUT row wen i click 'submit' the in out textbox must saved to DB First help for 1st qustn Code: [Select] <?php session_start(); if (!$_SESSION['uname']) { header("Location:login.php"); } ?> <html><head><title>Attendance sheet</title> <link rel="stylesheet" href="att_style.css" type="text/css" > <script src="datetimepicker.js"> </script> <script type="text/javascript"> function IsNumber(strFieldValue, size, strAlert) { for ( var i=0; i < size; i++) { if(strFieldValue.charAt(i)!="" ) { if( strFieldValue.charAt(i) < "0" || strFieldValue.charAt(i) > "9") { if(strAlert != "")alert(strAlert) return false; } } } return true; } function IsValidTime(timeStr) { var timePat = /^(\d{1,2}):(\d{2})(:(\d{2}))?(\s?(AM|am|PM|pm))?$/; var matchArray = timeStr.match(timePat); if (matchArray == null) { alert("Time is not in a valid format."); return false; } hour = matchArray[1]; minute = matchArray[2]; second = matchArray[4]; ampm = matchArray[6]; if (second=="") { second = null; } if (ampm=="") { ampm = null } if (hour < 0 || hour > 23) { alert("Hour must be between 1 and 12. (or 0 and 23 for military time)"); return false; } if (hour <= 12 && ampm == null) { if (confirm("Please indicate which time format you are using. OK = Standard Time, CANCEL = Military Time")) { alert("You must specify AM or PM."); return false; } } if (hour > 12 && ampm != null) { alert("You can't specify AM or PM for military time."); return false; } if (minute<0 || minute > 59) { alert ("Minute must be between 0 and 59."); return false; } if (second != null && (second < 0 || second > 59)) { alert ("Second must be between 0 and 59."); return false; } return false; } </script> </head> <body> <form name="timeform" method="post" action="" > <label for="range_start">Start range:</label> <input name="from" id="frm_date" type="text" > <a href="javascript:NewCal('frm_date','ddmmyyyy')"><img src="cal.gif" alt="pick a date"></a> <label for="range_end">End range:</label> <input name="to" id="dpk" type="text" > <a href="javascript:NewCal('dpk','ddmmyyyy')"><img src="cal.gif" alt="pick a date"></a> <input name="date_but" type="submit" value="Go"> <a style="float:right" href="logout.php">Logout</a> <br/><br/> <?php if (isset($_REQUEST['date_but'])) { $fromDate = $_REQUEST['from']; $toDate = $_REQUEST['to']; $dateMonthYearArr = array(); $fromDateTS = strtotime($fromDate); $toDateTS = strtotime($toDate); for ($currentDateTS = $fromDateTS; $currentDateTS <= $toDateTS; $currentDateTS += (60 * 60 * 24)) { $currentDateStr = date("d-M-Y",$currentDateTS); $dateMonthYearArr[] = $currentDateStr; php } echo "No of days: " . count($dateMonthYearArr); ?> <table border="1" cellspacing="0" cellpadding="5" align="center"> <tr> <th scope="row">DATE</th> <div class="dat_row"> <td><?php print_r($dateMonthYearArr[0]); ?></td> <td><?php echo $dateMonthYearArr[1]; ?></td> <td><?php echo $dateMonthYearArr[2]; ?></td> <td><?php echo $dateMonthYearArr[3]; ?></td> </div> </tr> <tr> <th scope="row">IN</th> <td><input name="time" type="text" ></td> <td><input name="r2_in" type="text" ></td> <td><input name="r2_in" type="text" ></td> </tr> <tr> <th scope="row">OUT</th> <td><input name="time" type="text"></td> <td> </td> <td> </td> </tr> <tr> <th scope="row">Leave</th> <td> </td> <td> </td> <td> </td> </tr> </table><br/><br/> <input name="submit" type="submit" onClick="IsValidTime(document.timeform.time.value);" value="Submit"> <?php } ?> </form> </body> </html> Similar TutorialsHi All,
I want to copy into a table values from another table that partially match a given value, case-insensitively. So far I do as follows but I wonder whether there is a quicker way.
$input_table=array('1'=>'toto','2'=>'tota','3'=>'hello','4'=>'TOTO','5'=>'toto'); $input_table_2 = array_map('strtolower', $input_table); $value_to_look_for='Tot'; $value_to_look_for_2=strtolower($value_to_look_for); $output_table=array(); foreach ($input_table_2 as $k=>$v) { if(false !== strpos($v, $value_to_look_for_2)) { $output_table[]=$input_table[$k]; } }One drawback is that $input_table_2 is 'foreached' whereas there might be no occurrences, which would lead to a loss of time/resources for big arrays. Thanks. Hello, I need some help. Say that I have a list in my MySQL database that contains elements "A", "S", "C", "D" etc... Now, I want to generate an html table where these elements should be distributed in a random and unique way while leaving some entries of the table empty, see the picture below. But, I have no clue how to do this... Any hints? Thanks in advance, Vero hi... i have a table ... i add and remove data in the table...when i add new record , information add to center of the table ! whats problem? i want add data in first of table. please guide me.thanks
Hi
I am very new to PHP & Mysql.
I am trying to insert values into two tables at the same time. One table will insert a single row and the other table will insert multiple records based on user insertion.
Everything is working well, but in my second table, 1st Table ID simply insert one time and rest of the values are inserting from 2nd table itself.
Now I want to insert the first table's ID Field value (auto-incrementing) to a specific column in the second table (only all last inserted rows).
Ripon.
Below is my Code:
<?php $con = mysql_connect("localhost","root","aaa"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("ccc", $con); $PI_No = $_POST['PI_No']; $PO_No = $_POST['PO_No']; $qry = "INSERT INTO wm_order_entry ( Order_No, PI_No, PO_No) VALUES( NULL, '$PI_No', '$PO_No')"; $result = @mysql_query($qry); $val1=$_POST['Size']; $val2=$_POST['Style']; $val3=$_POST['Colour']; $val4=$_POST['Season_Code']; $val5=$_POST['Dept']; $val6=$_POST['Sub_Item']; $val7=$_POST['Item_Desc']; $val8=$_POST['UPC']; $val9=$_POST['Qty']; $N = count($val1); for($i=0; $i < $N; $i++) { $profile_query = "INSERT INTO order_entry(Size, Style, Colour, Season_Code, Dept, Sub_Item, Item_Desc, UPC, Qty, Order_No ) VALUES( '$val1[$i]','$val2[$i]','$val3[$i]','$val4[$i]','$val5[$i]','$val6[$i]','$val7[$i]','$val8[$i]','$val9[$i]',LAST_INSERT_ID())"; $t_query=mysql_query($profile_query); } header("location: WMView.php"); mysql_close($con); ?>Output is attached. Hi All ,
I have a small table with 4 fields namely Day_ID, Dues, Last_Visit, Points. where Day_ID is an auto-increment field. The table would be as follows:
Day_ID -- Dues --- Last_Visit --- Points.
1 --------- 900 -------- 1/12 -------- 6
2 --------- 700 -------- 4/12 -------- 7
3 --------- 600 -------- 7/12 -------- 5
4 --------- 600 -------- 9/12 -------- 6
5 --------- 600 -------- 10/12 ------- 6
6 --------- 600 -------- 14/12 ------- 6
So this is the record of a person's visit to say a club. The last row indicates the last date of his visit to the club. His points on this date are 6. Based on this point value of 6 in the last row I want to retrieve all the previous BUT adjoining all records that have the same Points i.e. 6.
So my query should retrieve for me, based on the column value of Points of the last row (i.e. Day_ID - 6 ), as follows:
4 --------- 600 -------- 9/12 -------- 6
5 --------- 600 -------- 10/12 ------- 6
6 --------- 600 -------- 14/12 ------- 6
This problem stated above had been completely resolved, thanks to a lot of help from Guru Barand by this following query :-
$query = "SELECT cv.day_id, cv.dues, cv.last_visit, cv.points FROM clubvisit cv WHERE last_visit >= ( SELECT MAX(last_visit) FROM clubvisit WHERE points <> ( SELECT points as lastpoints FROM clubvisit JOIN ( SELECT MAX(last_visit) as last_visit FROM clubvisit ) as latest USING (last_visit) ) )";I am using this and it works perfectly except that now there is a slight change in the table because the criteria for points is now dependent on more than one column cv.points and is more like cv.points1, cv.points2, cv.points3 etc. So now I need to make a selection based on each of these cv.points columns. As of now I can still get the results by running the query multiple times for each of the cv.points columns ( seperately for cv.points1, cv.points2, cv.points3) and it works correctly. However I am wondering if there is a better way to do this in just one go. This not only makes the code repetitive but also since the queries are interconnected, involves the use of transactions which I wish to avoid if possible. The values that I require for each of the cv.point columns is 1. day_id of the previous / old day on which the cv.points value changed from the current day value, and 2. cv.points on that old/ previous day. So for example if the table is as below: Day_ID -- Dues --- Last_Visit --- Points1 --- Points2. 1 --------- 900 -------- 1/12 ----------- 9 ------------ 5 2 --------- 600 -------- 4/12 ----------- 6 ------------ 6 3 --------- 400 -------- 7/12 ----------- 4 ------------ 7 4 --------- 500 -------- 9/12 ----------- 5 ------------ 8 5 --------- 600 -------- 10/12 ---------- 6 ------------ 8 6 --------- 600 -------- 11/12 ---------- 6 ------------ 8 7 --------- 600 -------- 13/12 ---------- 6 ------------ 7 8 --------- 500 -------- 15/12 ---------- 5 ------------ 7 9 --------- 500 -------- 19/12 ---------- 5 ------------ 7 Then I need the following set of values : 1. day_id1 -- Day 7, points1 ---- 6, days_diff1 -- (9-7 = 2) . // Difference between the latest day and day_id1 2. day_id2 -- Day 6, points2 ---- 8, days_diff2 -- (9-6 = 3) 3. day_id3 -- .... and so on for other points. Thanks all ! Hello everyone. I need help with the following PHP APP. I am running on (Version PHP 7.2.10) I am trying to have a page table form on table.php pass the input variable of “5-Numbers” to another page called table_results.php I want that variable string of “5-Numbers” to be compared against 4 arrays and output any duplicates found within each of those 4 lists. If nothing is found, I still want some visual output that reads “None found”.
Lets pretend I have the following example .. On table.php, I typed inside my table form the 5-Numbers .. INPUT: 2,15,37,13,28 On table_results.php, the 4 arrays to be compared against my input numbers “ 2,15,37,13,28” are ..
$array_A = array(2,6,8,11,14,18,24); $array_B = array(1,2,9,10,13,14,25,28,); $array_C = array(1,3,7,9,13,15,20,21,24); $array_D = array(4,5,12,22,23,27,28,29);
So my output should read as follows below .. OUTPUT:
TABLE COLUMN 1 COLUMN 2 ROW 1 Matches Found Results .. ROW 2 GROUP A: 2 ROW 3 GROUP B: 2,13,28 ROW 4 GROUP ? 13,15 ROW 5 GROUP ? 28 ROW 6 5#s Input: 2,15,37,13,28
Please let me know if anyone has any suggestions on how to go about it. Thanks. Edited January 1, 2019 by Jayfromsandiego Wanted to include image example Not sure how to do this at all... I'm creating a page with a form to edit existing info in two tables in the database. I need to pre-check some checkboxes and I don't know how. The first query query_selectguest below puts data into the form just fine. query_checked looks in the second table for any rows that match the discount id. Then further down in the form, I have a php snippet that pulls all the classes from a third database. As I'm echoing these out to the page, I want them to be pre-checked if they match a result found in $result_checked here's what I have right now... Code: [Select] $query_selectguest = 'SELECT * FROM tbl_discount WHERE discount_id='.$passedID; $result_guest = mysql_query($query_selectguest); $g_row = mysql_fetch_array($result_guest); $query_checked = 'SELECT * FROM active_discounts WHERE disc_id='.$passedID; $result_checked = mysql_query($query_checked); $h_row = mysql_fetch_array($result_checked); ?> <form name="form1" method="post" action="update_discount.php" onSubmit="return validate_form()"> <input name="discount_name" type="text" class="input" id="subject" size="50" maxlength="100" value="<? print $g_row['discount_name'] ?>"> <input name="discount_amount" type="text" class="input" id="subject" size="5" maxlength="3" value="<? print $g_row['discount_amount'] ?>"> <!-- here's what I'm concerned with --> This discount applies to these classes:<br> <?php $quer4=mysql_query("SELECT workshop_id, workshop_title FROM tbl_workshops order by workshop_title"); while($row4 = mysql_fetch_array($quer4)) { echo "<input type='checkbox' name='workshop_link_1[]' value='".$row4[workshop_id]."'>".$row4[workshop_title]."<BR>"; } ?> This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=317025.0 I know I'm doing it something right, but can someone tell me why only one table is showing up? Can you help me fix the issue? Heres my code: function showcoords() { echo"J3st3r's CoordVision"; $result=dbquery("SELECT alliance, region, coordx, coordy FROM ".DB_COORDFUSION.""); dbarray($result); $fields_num = mysql_num_fields($result); echo "<table border='1'>"; // printing table headers echo "<td>Alliance</td>"; echo "<td>Region</td>"; echo "<td>Coord</td>"; // printing table rows while($row = mysql_fetch_array($result)) { // $row is array... foreach( .. ) puts every element // of $row to $cell variable foreach($row AS $Cell) echo "<tr>"; echo "<td>".$row['alliance']."</td>\n"; echo "<td>".$row['region']."</td>\n"; echo "<td>".$row['coordx'].",".$row['coordy']."</td>\n"; echo "</tr>\n"; } echo "</table>"; mysql_free_result($result); } I have 2 rows inserted into my coords table. Just frustrated and ignorant to php. hello friends I'm dealing with this problem for two days. I put here the screenshot for easier understanding.Sorry about my bad english. Here is the ss http://i61.tinypic.com/2rz5q55.jpg I don't want to inner join or table join. All image links which same sku should displayed in single row where products.resimler colon I can join the tables but i want to one table.Because i can import single csv file for e-commerce script.How can I use a update query for list multiple images in table products. Edited by nogai, 10 October 2014 - 07:01 AM. Simple question but I couldn't find any straight forward answers.
I have a customer details table with: customer ID, name, address, email.
I also have an delivery table with delivery ID, customer ID, order ID.
How can I link the customer ID column from the customer table to the delivery table so that when changes occur on the customer table they subsequently alter all other tables?
I know it might use foreign keys but I couldn't find any online resource that explained how to use them properly.
Cheers
This is a little confusing so please bear with me. I was thinking of using left.join but couldn't figure out how to implement it properly. I am trying to order all of the results from a table names 'clans' based on how many points the clan has. To calculate the points you have to go into another table 'clanteams' and then loop every team in the clan pulling wins and losses from a row in a specific ladder table. Here is the code i have to calculate the points. Code: [Select] $total[wins] = 0; $total[loss] = 0; $members=mysql_query("SELECT id,clanid,teamid,DATE_FORMAT(datejoined,'%M %d, %Y') FROM clanteams WHERE clanid='$member[id]'"); while(list($id,$clanid,$teamid,$joined)=mysql_fetch_row($members)){ $team=mysql_query("SELECT name,ladderid FROM teams WHERE id='$teamid'"); if(mysql_num_rows($team) == 0) continue; $team=mysql_fetch_array($team); $ladder=mysql_query("SELECT name FROM ladders WHERE id='$team[ladderid]'"); $ladder=mysql_fetch_array($ladder); $linfo=mysql_query("SELECT rank,wins,loss FROM ladder_$team[ladderid] WHERE teamid='$teamid'"); $linfo=mysql_fetch_array($linfo); $total[wins] = $total[wins] + $linfo[wins]; $total[loss] = $total[loss] + $linfo[loss]; } $totalpoints = ($total[wins] * 2) - $total[loss]; So now i want to loop through every row in the clans table, and using the above code oder them by $total points. Ive spent hours wrapping my head around it and still cannot figure it out. Please help. How would you retrieve information from one table and enter that informatio to another and the same time get other details from form. Do you retrieve the data and use a form to post this and insert that to another table. Have I confused you??? Hello I have three tables User diysmps usergroup usergroupid is common in the three tables. diysmps is joined on usergroup, so running this sql SELECT diysmps.name, diysmps.email, diysmps.sumbit, diysmps.message, diysmps.ID, usergroup.title FROM diysmps INNER JOIN usergroup ON diysmps.usergroupid = usergroup.usergroupid ORDER BY diysmps.ID DESC see results i get in picture attached. the result (PENDIN REGISTRATION) is what i need to be updated WHEN the user register to the forums. when the user register to the forums, an account with his EMAIL will be created into the (USER) table. So, I need to look out for the email FROM (diysmps TABLE) into the user table _search user table for email from diysmps table_ and if found to update the USERGROUPID in (diysmps TABLE) withe the USERGROUPID from (USER) table (related to the email searched) so, when user registers, status from PENDING REGISTRATION to REGISTERED will be shown I know it looks complex for me, but thats how i can describe Thanks all I am new to php.i want to be able to link echoed out rows from a table to another row in another table so that when users clicked the first row i echoed out it will take them to that SPECIFIC row i linked it to in the second table..JUST LIKE FACEBOOK...Please do i make sense or is there another way to do it. Thanks in advance I have a table like this: http://empirebuildingsestate.com/company.html How can I separate the table values into variables so I can insert them into my mySQL database? I have been trying DOMDocument but i need some help. Hi I have two tables Employer and Job. Emp_ID as PK of Employer and Job_id as PK of Job. I want to put Emp_ID as Foreign key for jobs. and when the employer logs in his empid is being stored as a session and when he creates a job his empid will be entered in the job table. the second database found on the cloud
i try to get JSON data but how to insert and update them to another online database with the same table my php script to return json data <?php include_once('db.php'); $users = array(); $users_data = $db -> prepare('SELECT id, username FROM users'); $users_data -> execute(); while($fetched = $users_data->fetch()) { $users[$fetchedt['id']] = array ( 'id' => $fetched['id'], 'username' => $fetched['name'] ); } echo json_encode($leaders);
i get
{"1":{"id":1,"username":"jeremia"},"2":{"id":2,"username":"Ernest"}} Edited March 24 by mahenda Hi all I am describing my problem below can any body please look into this I have two databases DB1:datain1 DB2:datain2 having the below structure database, table, fields datain1 , student , id,name datain2 , student , id,name the two databases having same structure My query is i want copy all data from datain1 to datain2 on daily process through php script(script will be executed manually on daily) i don't want any duplicate or repeated data in datain2 give me some script to do this kindly help me to solve this its so urgent |