Jump to content

scarface83

Members
  • Posts

    82
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

scarface83's Achievements

Member

Member (2/5)

0

Reputation

  1. Hi i was wondering if anyone could help me with the below code its a form which posts back into itself so i can move on the the next drop down but it doesnt seem to be working and i have been starring at it for ages it used to work and nothing has changed ? thanks <? //echo "Site Down while making improvements -" ,$days; //exit(); session_start(); print_r ($_SESSION); include('sess_vars.php'); if($level >=1){echo "If you are seeing this you dont have sufficent rights to access this program? if not email rob please !!!!";} else { if (isset($none_sel)) // if the loginerror variable is set then continue echo $none_sel; // unset($_SESSION['none_sel']); // unregisters the session for none_sel so it can be reset later in the script @$error = $_GET['error']; if($error=="1") { echo ("Select an option below before submitting."); unset($error); } require ('db_connect.inc'); // includes db connection details if(isset($teams)) { $set_teams = $_POST['teams']; } else { $set_teams="Please_Select";} $team_names = mysql_query("SELECT TeamRef,Teamname FROM a_team WHERE In_use='Y' AND Area='1' ORDER BY Teamname ") or die(mysql_error); if(isset($advisors)) { $set_advisors = $_POST['advisors']; } else { $set_advisors="Please_Select";} $advisor_names = mysql_query("SELECT nick FROM a_users WHERE In_use='Y' AND Level='0' AND TeamRef='$set_teams' ORDER BY nick"); mysql_close(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Absence Managment</title> <link href="style.css" rel="stylesheet" type="text/css" /> </head> <body> <div class="title"> <u>Absence Management</u></div> <div class="back"><a href="../main.php">Back</a></div> <form name="select_advisor" method="post" action="report_absence.php"> <br /> <table width="1395" border="0"> <tr> <td width="865"><b><u>Please Select the team, then the advisor you are reporting the absence for </u></b></td> </tr> </table> </div> </p> <table width="14%" border="1"> <tr> <td width="78%"><div align="left"> <select name="teams" onChange="this.form.submit();"> <option value="Please_Select">Please Select</option> <? while($team_names_row = mysql_fetch_array($team_names)) { extract($team_names_row) ?> <? if($set_teams==$TeamRef) { ?> <option style="color:#FF0000" value="<? echo $TeamRef ?>" selected><? echo $Teamname; ?></option> <? } else { ?> <option value="<? echo $TeamRef ?>"><? echo $Teamname; ?></option> <? } ?> <? } ?> </select> </div> </td> <!-- <td width="22%"><input type="submit" name="Submit" value="Select"></td> --> </tr> <tr> <td><div align="left"> <select name="advisors" onChange="this.form.submit();"> <option value="Please_Select">Please Select</option> <? while($advisor_names_row = mysql_fetch_array($advisor_names)) { extract($advisor_names_row) ?> <? if($set_advisors==$nick) { ?> <option style="color:#FF0000" value="<? echo $nick ?>" selected><? echo $nick; ?></option> <? } else { ?> <option value="<? echo $nick ?>"><? echo $nick; ?></option> <? } ?> <? } ?> </select> <label></label> </div></td> <!-- <td><input type="submit" name="Submit2" value="Select"></td> --> </tr></table> </form> <form name="form2" method="post" action="report_absence2.php"> <br /> <table border="1"> <td width="56"><input type="submit" name="Submit3" value="Submit" /> </table> <input type="hidden" name="whats_sel" value="4" /> <input type="hidden" value="<? echo $set_teams ?>" name="teams" /> <input type="hidden" value="<? echo $set_advisors ?>" name="advisors" /> </form> <p> <div class="footer"> </p> <p> </p> </body>
  2. Hi, any idea how i can get this calendar to go from april 2007 to april 2008 ? Thanks function generate_calender($year, $vtc_login) { global $num_columns_displayed,$month_table_header,$month_row_header,$month_td_tag; $num_of_months = 12; $count_up = 1; echo $month_table_header; while ($count_up<=$num_of_months) { echo $month_row_header; $num_columns = $num_columns_displayed; while (($num_columns>0) && ($count_up<=$num_of_months)) { echo $month_td_tag; echo gen_month($year,$count_up, $vtc_login); echo "</td>"; $count_up++; $num_columns--; } echo "</tr>"; } echo "\n</table>"; } // // Function gen_month($year,$month) will generate a month for // the year and month given. // function gen_month($year,$month,$vtc_login) { global $cal_table_tag,$cal_mon_tr_tag,$cal_dayname_tr_tag,$cal_day_tr_tag; global $cal_event_opentd; $mon_date = getdate(mktime(0,0,0,$month,1,$year)); $mon_name = $mon_date[month]; $mon_total_days = strftime( "%d",mktime(0,0,0,$month+1,0,$year)); echo $cal_table_tag; echo $cal_mon_tr_tag . "<td colspan=7 align=center><b>$mon_name $year</b></td></tr>"; echo $cal_dayname_tr_tag . "<td>S</td><td>M</td><td>T</td><td>W</td><td>T</td><td>F</td><td>S</td></tr>"; $day_count = 1; while ($day_count<=($mon_total_days-7)) { $fweek = getdate(mktime(0,0,0,$month,$day_count,$year)); if ($day_count<=7) { $sb_cnt_td = $fweek[wday]; $sb_cnt = $fweek[wday]; $sb_max = 7; $p_line = $cal_day_tr_tag;
  3. looks fine , thanks i cant believe i forgot the operator ! , also thanks for your help with that while loop the other day i got it sorted in the end Cheers
  4. sorry guys im trying to update then will this work $query1 = "UPDATE absence_mgt SET abs_value='1', notes='testing', viewable='0' WHERE datestamp='2007-04-28' AND ID='vtc2av' "; // inserts the selection from the form into the db thanks
  5. how do you insert into a row that already exsists ? i have this table im trying to insert into and empty field on an already exsisting row datestamp abs_value ID notes viewable TeamRef 2007-04-28 0 vtc1kb 1 14 2007-04-28 0 vtc2a7 1 14 2007-01-01 1 vtc1kb test 0 0 and want to do the following query $query = "INSERT INTO absence_mgt SET abs_value='1', notes='testing' WHERE datestamp='2007-04-28', ID='vtc2av' "; // inserts the selection from the form into the db $result = mysql_query($query) or die (mysql_error()); // runs the above query im getting the following error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE datestamp='2007/04/28', ID='vtc2av' at line 1 do i need to use and update statemnet and if so how do i do it ? Thanks
  6. hi can this be done ? while ($row2 = mysql_fetch_array($result2), while ($row3 = mysql_fetch_array($query3)){ // do some code
  7. <?php session_start(); include ('db_connect.inc'); $query = " SELECT TeamRef FROM a_users WHERE Login='$keepit' "; $result = mysql_query($query) or die (mysql_error); // runs the above query $row = mysql_fetch_array($result); $tm = $row['TeamRef'] ; $query2 = "SELECT datestamp, ID FROM absence_mgt WHERE viewable='1' AND TeamRef='$tm'"; $result2 = mysql_query($query2) or die (mysql_error); // runs the above query $row2 = mysql_fetch_assoc($result2); $date_stamp =$row2['datestamp'] ; $new_id = $row2['ID']; list($year,$month,$day) = split("-",$date_stamp); $newdate = $day."/".$month."/".$year; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> <link href="/ab_mgt/style.css" rel="stylesheet" type="text/css" /> </head> <body> <div class="title"> <u><b>Pending Absence for your Team</b></u> </div> <div class="pend_subtitle"> Please Confirm if this absence should be saved to your absence calendar ? </div> <div class="back"><a href="main.php">Back</a></div> <div class="pend_absence"> <?php $query3 = mysql_query("SELECT Forename,Surname FROM a_users WHERE In_use='Y' AND Login='$new_id'")or die (mysql_error); $row3 = mysql_fetch_assoc($query3); session_unregister('first'); session_unregister('second'); $first = $row3['Forename']; $second = $row3['Surname']; while ($row2 = mysql_fetch_assoc($result2)){ echo "Date of Absence - ". $newdate." - ".$new_id." - ". $first." ".$second." <a href= 'test' >Save</a>"; } ?> </div> <?php mysql_close(); ?> </body> </html>
  8. these $date_stamp =$row2['datestamp']; //<--Should be row3 $new_id = $row2['ID']; //<--Should be row3 corresponds to this statement $query2 = "SELECT datestamp, ID FROM absence_mgt WHERE viewable='1' AND TeamRef='$tm'"; // this query select the datestamp and users ID $result2 = mysql_query($query2) or die (mysql_error()); // runs the above query $row2 = mysql_fetch_assoc($result2); so should be row2 ? thanks
  9. he he sorry getting a little confused now so lets start again lol this code grabs the team reference of the users where login = $keepit - which is there login, i have etested this and it works if you echo it out after the query <?php session_start(); include ('db_connect.inc'); $query = " SELECT TeamRef FROM a_users WHERE Login='$keepit' ";//this is a session variable already set on another page $result = mysql_query($query) or die (mysql_error()); // runs the above query $row = mysql_fetch_array($result); $tm = $row['TeamRef']; this is the code that it important it grabs the datestamp and id where the team ref is the same as the user who login in $query2 = "SELECT datestamp, ID FROM absence_mgt WHERE viewable='1' AND TeamRef='$tm'"; // this query select the datestamp and users ID $result2 = mysql_query($query2) or die (mysql_error()); // runs the above query $row2 = mysql_fetch_assoc($result2); ?> see comments in the code but this next part should be a loop and show all entries where the teamref = is = to that of the person who is logged in , when i view the page i get one result which is correct but there are about 12 entries so it seems the while loop isn't working correclty <?php $query3 = mysql_query("SELECT datestamp, ID, Forename,Surname FROM a_users ")or die (mysql_error); // this can be ingnores as it works fine // //Also remove the following while testing - WHERE In_use='Y' AND Login='$new_id' $row3 = mysql_fetch_assoc($query3); session_unregister('first'); session_unregister('second'); while ($row3 = mysql_fetch_assoc($result3)) // the problem lies as it displays one row thats correct but doesnt show the others { $first = $row3['Forename']; $second = $row3['Surname']; $date_stamp =$row2['datestamp']; $new_id = $row2['ID']; list($year,$month,$day) = split("-",$date_stamp); $newdate = $day."/".$month."/".$year; echo "Date of Absence - ". $newdate." - ".$new_id." - ". $first." ".$second." <a href= 'test' >Save</a>"; } mysql_close(); thanks for your help with this
  10. that table was the absence_mgt one , the other table is not really that relevant as it works fine and that query just sets the $tm = $row['TeamRef'] ; which is what team basically , im sure your boss will be proud your being so helpful lol thanks
  11. absence _mgt the a_users just grabs some values to add to the criteria. Field Type Null Default datestamp date Yes abs_value smallint(1) Yes ID varchar(10) Yes notes varchar(100) Yes viewable smallint(1) Yes TeamRef smallint(2) Yes
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.