Jump to content

GamerGun

Members
  • Posts

    151
  • Joined

  • Last visited

Everything posted by GamerGun

  1. I see what you mean. And it works now Thanks. BTW, (something else) I was already trying on something to select records from the database, but somehow it blew up. records2.php <html> <head> <basefont face="Arial"> </head> <body> <?php error_reporting(E_ALL); if (!isset($_POST['Submit'])) { // form not submitted ?> <?php } else { // form submitted // set server access variables $host = "localhost"; $user = "root"; $pass = "password"; $db = "urendatabase"; $search = empty($_POST['search'])? die ("ERROR: Je moet wel iets invullen") : mysql_escape_string($_POST['search']); $dropdown = empty($_POST['dropdown'])? die ("ERROR: Je moet wel een keuze maken") : mysql_escape_string($_POST['dropdown']); // Open Connection $connect = mysql_connect($host, $user, $pass) or die ("Unable to connect to host"); //select Database mysql_select_db($db) or die ("Unable to connect to database"); $query1 = mysql_query( "SELECT `userid`, `voornaam`, `achternaam` FROM `werknemers` ORDER BY `userid` ASC" ) or die (mysql_error()); while ($data = mysql_fetch_assoc($query1)) { echo "<form method=\"post\" action=".$_SERVER['PHP_SELF']."> Zoeken <input type=\"text\" name=\"search\"><br> <select size=\"1\" name=\"dropdown\"> <option value=\"\" selected>Zoek op...</option> <option value='".$data['userid']."'>".$data['voornaam']." ".$data['achternaam']."</option> <option value=\"userid\">Medewerker</option> <option value=\"specid\">Gerelateerd</option> <option value=\"overid\">Overige</option> <option value=\"afdelingid\">Afdeling</option> <option value=\"uren\">Uren</option> <option value=\"minuten\">Minuten</option> <option value=\"omschrijving\">Omschrijving</option> <option value=\"callnr\">Call nr</option> <option value=\"datum\">Datum</option> <option value=\"week\">Week</option> </select> <input type=\"Submit\" value=\"Verstuur\" name=\"Submit\"> </form>"; } //Create Query $query = "select * FROM uren where $dropdown='$search'" or die (mysql_error()); $result = mysql_query($query) or die (mysql_error()); $num=mysql_numrows($result); mysql_close($connect); echo "<b><center>Database output</center></b><br><br>"; $i=0; while ($i < $num) { $userid=mysql_result($result,$i,"userid"); $specid=mysql_result($result,$i,"specid"); $overid=mysql_result($result,$i,"overid"); $afdelingid=mysql_result($result,$i,"afdelingid"); $uren=mysql_result($result,$i,"uren"); $minuten=mysql_result($result,$i,"minuten"); $omschrijving=mysql_result($result,$i,"omschrijving"); $callnr=mysql_result($result,$i,"callnr"); $datum=mysql_result($result,$i,"datum"); $week=mysql_result($result,$i,"week"); echo "<table border=\"1\" bordercolor=\"#FFCC00\" style=\"background-color:#FFFFCC\" width=\"100%\" cellpadding=\"3\" cellspacing=\"3\"> <tr> <td width=\"15%\">User ID</td> <td width=\"85%\">$userid</td> </tr> <tr> <td width=\"15%\">Spec ID</td> <td width=\"85%\">$specid</td> </tr> <tr> <td width=\"15%\">Over ID</td> <td width=\"85%\">$overid</td> </tr> <tr> <td width=\"15%\">Afdeling ID</td> <td width=\"85%\">$afdelingid</td> </tr> <tr> <td width=\"15%\">Uren</td> <td width=\"85%\">$uren</td> </tr> <tr> <td width=\"15%\">Minuten</td> <td width=\"85%\">$minuten</td> </tr> <tr> <td width=\"15%\">Omschrijving</td> <td width=\"85%\">$omschrijving</td> </tr> <tr> <td width=\"15%\">Call nr</td> <td width=\"85%\">$callnr</td> </tr> <tr> <td width=\"15%\">Datum (YY/MM/DD)</td> <td width=\"85%\">$datum</td> </tr> <tr> <td width=\"15%\">Week</td> <td width=\"85%\">$week</td> </tr> </table><br>"; $i++; } } ?> </body> </html> It just gives a blank screen but no errors in the error log. Any idea why? Thanks!
  2. Well i've been testing but seems like OVERID isn't submitted no more. De volgende werkzaamheden zijn toegevoegd: - The following records are added: '2', '', '', '', '3', '30', 'test', '', '2008-10-08', '41' '2', '', '', '', '1', '45', 'test2', '', '2008-10-08', '41' http://gamergun.com/uren/records.php With Any idea? Thanks
  3. Thanks, it looks like it works now. Will test it better tomorrow at work (its almost 10pm here). Thanks for all the effort! You do a great job and i'm trying to understand it. Will read the entire code asap. Greetings -T
  4. No problem at all! Changed some Dutch words in order to get the form working but it does now. Only the insert is not correct: De volgende werkzaamheden zijn toegevoegd: - The following records are added: '2', '3', '3', '1', '6', '00', 'test1', '32423', '2008-10-01', '40' '2', '3', '2', '1', '6', '15', 'test2', '42323', '2008-10-01', '40' '2', '', '1', '', '5', '30', 'test3', '', '2008-10-01', '40' With this form: You see i'm missing test4 and test5? For the rest, good work mate! Thanks again for all the effort. My code at the moment: index.php <html><head> <title>Urenregistratie CVIS</title> <link rel="stylesheet" href="zpcal/themes/winter.css" /> <link rel="stylesheet" href="style.css" /> <script type="text/javascript" src="zpcal/utils/zapatec.js"></script> <script type="text/javascript" src="zpcal/src/calendar.js"></script> <script type="text/javascript" src="zpcal/lang/calendar-du.js"></script> <SCRIPT language=Javascript> <!-- function isNumberKey(evt) { var charCode = (evt.which) ? evt.which : event.keyCode if (charCode > 31 && (charCode < 48 || charCode > 57)) return false; return true; } //--> </SCRIPT> <script type="text/javascript"> function fieldEnable(rowNum){ var theContents = document.getElementById('type' + rowNum)[document.getElementById('type' + rowNum).selectedIndex].value; //document.body.innerHTML = theContents; if (theContents == '1'){ document.getElementById('specificatie' + rowNum).disabled = false; document.getElementById('afdeling' + rowNum).disabled = false; document.getElementById('callnr' + rowNum).disabled = false; document.getElementById('overige' + rowNum).disabled = true; document.getElementById('overige' + rowNum).selectedIndex = 0; } else if(theContents == '2'){ document.getElementById('specificatie' + rowNum).disabled = true; document.getElementById('afdeling' + rowNum).disabled = true; document.getElementById('callnr' + rowNum).disabled = true; document.getElementById('overige' + rowNum).disabled = false; document.getElementById('specificatie' + rowNum).selectedIndex = 0; document.getElementById('afdeling' + rowNum).selectedIndex = 0; document.getElementById('callnr' + rowNum).value = ""; } else{ document.getElementById('specificatie' + rowNum).disabled = true; document.getElementById('afdeling' + rowNum).disabled = true; document.getElementById('callnr' + rowNum).disabled = true; document.getElementById('overige' + rowNum).disabled = true; document.getElementById('specificatie' + rowNum).selectedIndex = 0; document.getElementById('afdeling' + rowNum).selectedIndex = 0; document.getElementById('callnr' + rowNum).value = ""; document.getElementById('overige' + rowNum).selectedIndex = 0; } } </script> </head> <body> <div class="RedLink"> <?php $connect = mysql_connect("localhost","root","password") or die ("Could not connect to database."); define('NUM_ROWS', 5); mysql_select_db("urendatabase"); $query1 = mysql_query( "SELECT `userid`, `voornaam`, `achternaam` FROM `werknemers` ORDER BY `userid` ASC" ) or die (mysql_error()); echo "<img src=\"http://www.cvis.nl/templates/bediajoomlatemplate/images/logo.png\">\n<br><br>"; echo "<form name='form1' method='post' action='insert.php'>\n"; $htmlToEcho = <<<EOT Datum: <input type="text" id="calendar" name="calendar" size="30" /> <button id="trigger">...</button> <script type="text/javascript">//<![CDATA[ Zapatec.Calendar.setup({ firstDay : 1, electric : false, inputField : "calendar", button : "trigger", ifFormat : "%d %B %Y (Week %W)", daFormat : "%Y/%m/%d" }); //]]></script> <noscript> <br/> Your browser does not support Javascript. <br/> Either enable Javascript in your Browser or upgrade to a newer version. </noscript> EOT; echo $htmlToEcho; $urendropdown = <<<EOT <select name="uren[]"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> </select> EOT; $minutendropdown = <<<EOT <select name="minuten[]"> <option value="00">00</option> <option value="15">15</option> <option value="30">30</option> <option value="45">45</option> </select> EOT; echo "<br><br>"; echo "Naam: <select name='werknemer'>\n"; while ($data = mysql_fetch_assoc($query1)) { echo "<option value='".$data['userid']."'>".$data['voornaam']." ".$data['achternaam']."</option>\n"; } echo "</select> <br><br>\n"; echo "<table border=\"1\" bordercolor=\"#FFCC00\" style=\"background-color:#FFFFCC\" width=\"100%\" cellpadding=\"3\" cellspacing=\"3\"> <tr> <td>Type</td> <td>Gerelateerd</td> <td>Afdeling</td> <td>Call nummer</td> <td>Overige</td> <td>Tijd (hr)</td> <td>Tijd (min)</td> <td>Omschrijving</td> </tr>"; for ($i = 1; $i <= NUM_ROWS; ++$i){ echo "<tr> <td width=\"6%\"><select id=\"type".$i."\" onChange=\"fieldEnable(".$i.")\"> <option value=\"0\">...</option> <option value=\"1\">Call</option> <option value=\"2\">Other</option> </select></td> <td width=\"6%\"><select id=\"specificatie".$i."\" name=\"specificatie[]\" disabled>";include("spec.php");echo "</select></td> <td width=\"6%\"><select id=\"afdeling".$i."\" name=\"afdeling[]\" disabled>";include("afd.php");echo "</select></td> <td><input type=\"text\" size=\"9\" maxlength=\"5\" onkeypress=\"return isNumberKey(event)\" id=\"callnr".$i."\" name=\"callnr[]\" disabled /></td> <td width=\"6%\"><select id=\"overige".$i."\" name=\"overige[]\" disabled>";include("over.php");echo "</select></td> <td width=\"7%\">";echo $urendropdown;echo "</td> <td width=\"8%\">";echo $minutendropdown;echo "</td> <td><input type=\"text\" size=\"69\" name=\"omschrijving[]\" /></td> </tr>"; } echo "</table>"; echo "<br>"; echo "<input type='submit' name='submit' value='Verstuur' onClick=\"return confirm('Weet je zeker dat alle velden volledig ingevuld zijn?');\">\n"; echo "</form>\n"; echo "<a href=\"afdelingen/index.php\">Afdeling toevoegen</a> - <a href=\"medewerkers/index.php\">Medewerker toevoegen</a>"; ?> <br><br><hr><small><a href="http://www.zapatec.com/website/main/products/prod1/">Zapatec Javascript Calendar</a></small><br> </div> </body></html> insert.php <html><head><title>Urenregistratie CVIS</title></head> <body> <?php $con = mysql_connect("localhost","root","password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("urendatabase", $con); //names of the month in dutch $months = array ("Januari", "Februari", "Maart", "April", "Mei", "Juni", "Juli", "Augustus", "September", "Oktober", "November", "December"); $tmpDate = explode("(", $_POST['calendar']); //get date from form and explode into array $week = array_pop($tmpDate); //pop the week off the end of the date array $week = str_replace(array("Week ", ")"), "", $week);//get rid of the ) at the end of the week string $date = explode(" ", trim($tmpDate[0])); //explode the date into an array(day_num, month_str, year_num) $monthNum = 0; //this will hold the month number for the final date //check find the month name in the $months array and set the month number to $monthNum foreach($months as $key=>$month ){ if (strcasecmp($date[1], $month) == 0){ $monthNum = $key + 1; break; } } $date[1] = (($monthNum < 10)?"0":"").$monthNum; //set month number to $dat[1] in the proper format $date = array_reverse($date); //change date order from dd-mm-yyyy to yyyy-mm-dd for database $dateStr = implode("-", $date); //final date in a DB friendly format $werknemer = mysql_real_escape_string($_POST['werknemer']); $checkEmpty = 0; //counter to keep track of the amount of empty rows submitted. $success = array(); //keep records that were successfully inserted into DB for success msg. for ($i = 0; $i < 10; ++$i){ $afdeling = mysql_real_escape_string($_POST['afdeling'][$i]); $overige = mysql_real_escape_string($_POST['overige'][$i]); $uren = mysql_real_escape_string($_POST['uren'][$i]); $minuten = mysql_real_escape_string($_POST['minuten'][$i]); $specificatie = mysql_real_escape_string($_POST['specificatie'][$i]); $omschrijving = mysql_real_escape_string($_POST['omschrijving'][$i]); $callnr = mysql_real_escape_string($_POST['callnr'][$i]); if (empty($omschrijving) || ($overige == 0 && ($specificatie == 0 || $afdeling == 0 || $callnr == 0))){ ++$checkEmpty; //count each empty row continue; } else{ $sql="INSERT INTO uren (userid, specid, overid, afdelingid, uren, minuten, omschrijving, callnr, datum, week) VALUES ('$werknemer', '$specificatie', '$overige', '$afdeling', '$uren', '$minuten', '$omschrijving', '$callnr', '$dateStr', '$week')"; $success[] = array($werknemer, $specificatie, $overige, $afdeling, $uren, $minuten, $omschrijving, $callnr, $dateStr, $week); if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } } } //if all 10 rows were empty, echo the error msg. else, print success msg echo (($checkEmpty == 10) ? ("<img src=\"http://www.cvis.nl/templates/bediajoomlatemplate/images/logo.png\"><br><br>Je kunt geen leeg formulier opsturen - You can't send a blank form") : ("<img src=\"http://www.cvis.nl/templates/bediajoomlatemplate/images/logo.png\"><br><br>De volgende werkzaamheden zijn toegevoegd: - The following records are added:<br><br>")); //print information that was added to the DB $loopCount = count($success); for ($i = 0; $i < $loopCount; ++$i){ echo "'"; echo implode("', '", $success[$i]); echo "'"; echo "<br />"; } echo "<br><br>"; echo("<form><input type=\"button\" value=\"Vorige pagina\" onclick=\"parent.location='index.php'\" /></form>"); mysql_close($con) ?> </body></html>[/p] afd.php [code=php:0]<?php $query1 = mysql_query( "SELECT `afdelingid`, `afdeling` FROM `afdelingen` ORDER BY `afdelingid` ASC" ) or die (mysql_error()); while ($data = mysql_fetch_assoc($query1)) { echo "<option value='".$data['afdelingid']."'>".$data['afdeling']."</option>\n"; } ?> spec.php <?php $query2 = mysql_query( "SELECT `specid`, `specificatie` FROM `specificatie` ORDER BY `specificatie` ASC" ) or die (mysql_error()); while ($data = mysql_fetch_assoc($query2)) { echo "<option value='".$data['specid']."'>".$data['specificatie']."</option>\n"; } ?> over.php <?php $query3 = mysql_query( "SELECT `overid`, `overige` FROM `overige` ORDER BY `overid` ASC" ) or die (mysql_error()); while ($data = mysql_fetch_assoc($query3)) { echo "<option value='".$data['overid']."'>".$data['overige']."</option>\n"; } ?>
  5. I only can't get it to work how to do this with multiple records: <html><head> <title>Urenregistratie CVIS</title> <link rel="stylesheet" href="zpcal/themes/winter.css" /> <link rel="stylesheet" href="style.css" /> <script type="text/javascript" src="zpcal/utils/zapatec.js"></script> <script type="text/javascript" src="zpcal/src/calendar.js"></script> <script type="text/javascript" src="zpcal/lang/calendar-du.js"></script> <SCRIPT language=Javascript> <!-- function isNumberKey(evt) { var charCode = (evt.which) ? evt.which : event.keyCode if (charCode > 31 && (charCode < 48 || charCode > 57)) return false; return true; } //--> </SCRIPT> <script type="text/javascript"> function fieldEnable(){ var theContents = document.getElementById('type')[document.getElementById('type').selectedIndex].value; //document.body.innerHTML = theContents; if (theContents == '1'){ document.getElementById('specificate').disabled = false; document.getElementById('afdeling').disabled = false; document.getElementById('callnr').disabled = false; document.getElementById('overige').disabled = true; } else if(theContents == '2'){ document.getElementById('specificate').disabled = true; document.getElementById('afdeling').disabled = true; document.getElementById('callnr').disabled = true; document.getElementById('overige').disabled = false; } else{ document.getElementById('specificate').disabled = true; document.getElementById('afdeling').disabled = true; document.getElementById('callnr').disabled = true; document.getElementById('overige').disabled = true; } } </script> </head> <body> <?php $connect = mysql_connect("localhost","root","********") or die ("Could not connect to database."); mysql_select_db("urendatabase"); ?> <div class="RedLink"> <?php $connect = mysql_connect("localhost","root","password") or die ("Could not connect to database."); mysql_select_db("urendatabase"); $query1 = mysql_query( "SELECT `userid`, `voornaam`, `achternaam` FROM `werknemers` ORDER BY `userid` ASC" ) or die (mysql_error()); echo "<img src=\"http://www.cvis.nl/templates/bediajoomlatemplate/images/logo.png\">\n<br><br>"; echo "<form name='form1' method='post' action='insert.php'>\n"; $htmlToEcho = <<<EOT Datum: <input type="text" id="calendar" name="calendar" size="30" /> <button id="trigger">...</button> <script type="text/javascript">//<![CDATA[ Zapatec.Calendar.setup({ firstDay : 1, electric : false, inputField : "calendar", button : "trigger", ifFormat : "%d %B %Y (Week %W)", daFormat : "%Y/%m/%d" }); //]]></script> <noscript> <br/> Your browser does not support Javascript. <br/> Either enable Javascript in your Browser or upgrade to a newer version. </noscript> EOT; echo $htmlToEcho; $urendropdown = <<<EOT <select name="uren[]"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> </select> EOT; $minutendropdown = <<<EOT <select name="minuten[]"> <option value="00">00</option> <option value="15">15</option> <option value="30">30</option> <option value="45">45</option> </select> EOT; echo "<br><br>"; echo "Naam: <select name='werknemer'>\n"; while ($data = mysql_fetch_assoc($query1)) { echo "<option value='".$data['userid']."'>".$data['voornaam']." ".$data['achternaam']."</option>\n"; } echo "</select> <br><br>\n"; echo "<table border=\"1\" bordercolor=\"#FFCC00\" style=\"background-color:#FFFFCC\" width=\"100%\" cellpadding=\"3\" cellspacing=\"3\"> <tr> <td>Type</td> <td>Gerelateerd</td> <td>Afdeling</td> <td>Call nummer</td> <td>Overige</td> <td>Tijd (hr)</td> <td>Tijd (min)</td> <td>Omschrijving</td> </tr> <tr> <td width=\"6%\"><select id=\"type\" onChange=\"fieldEnable()\"> <option value=\"0\">...</option> <option value=\"1\">Call</option> <option value=\"2\">Other</option> </select></td> <td width=\"6%\">";include("spec.php");echo "</td> <td width=\"6%\">";include("afd.php");echo "</td> <td><input type=\"text\" size=\"9\" maxlength=\"5\" onkeypress=\"return isNumberKey(event)\" id=\"callnr\" name=\"callnr[]\" disabled /></td> <td width=\"6%\">";include("over.php");echo "</td> <td width=\"7%\">";echo $urendropdown;echo "</td> <td width=\"8%\">";echo $minutendropdown;echo "</td> <td><input type=\"text\" size=\"69\" name=\"omschrijving[]\" /></td> </tr> <tr> <td width=\"6%\"><select id=\"type\" onChange=\"fieldEnable()\"> <option value=\"0\">...</option> <option value=\"1\">Call</option> <option value=\"2\">Other</option> </select></td> <td width=\"6%\">";include("spec.php");echo "</td> <td width=\"6%\">";include("afd.php");echo "</td> <td><input type=\"text\" size=\"9\" maxlength=\"5\" onkeypress=\"return isNumberKey(event)\" id=\"callnr\" name=\"callnr[]\" disabled /></td> <td width=\"6%\">";include("over.php");echo "</td> <td width=\"7%\">";echo $urendropdown;echo "</td> <td width=\"8%\">";echo $minutendropdown;echo "</td> <td><input type=\"text\" size=\"69\" name=\"omschrijving[]\" /></td> </tr> <tr> <td width=\"6%\"><select id=\"type\" onChange=\"fieldEnable()\"> <option value=\"0\">...</option> <option value=\"1\">Call</option> <option value=\"2\">Other</option> </select></td> <td width=\"6%\">";include("spec.php");echo "</td> <td width=\"6%\">";include("afd.php");echo "</td> <td><input type=\"text\" size=\"9\" maxlength=\"5\" onkeypress=\"return isNumberKey(event)\" id=\"callnr\" name=\"callnr[]\" disabled /></td> <td width=\"6%\">";include("over.php");echo "</td> <td width=\"7%\">";echo $urendropdown;echo "</td> <td width=\"8%\">";echo $minutendropdown;echo "</td> <td><input type=\"text\" size=\"69\" name=\"omschrijving[]\" /></td> </tr> <tr> <td width=\"6%\"><select id=\"type\" onChange=\"fieldEnable()\"> <option value=\"0\">...</option> <option value=\"1\">Call</option> <option value=\"2\">Other</option> </select></td> <td width=\"6%\">";include("spec.php");echo "</td> <td width=\"6%\">";include("afd.php");echo "</td> <td><input type=\"text\" size=\"9\" maxlength=\"5\" onkeypress=\"return isNumberKey(event)\" id=\"callnr\" name=\"callnr[]\" disabled /></td> <td width=\"6%\">";include("over.php");echo "</td> <td width=\"7%\">";echo $urendropdown;echo "</td> <td width=\"8%\">";echo $minutendropdown;echo "</td> <td><input type=\"text\" size=\"69\" name=\"omschrijving[]\" /></td> </tr> <tr> <td width=\"6%\"><select id=\"type\" onChange=\"fieldEnable()\"> <option value=\"0\">...</option> <option value=\"1\">Call</option> <option value=\"2\">Other</option> </select></td> <td width=\"6%\">";include("spec.php");echo "</td> <td width=\"6%\">";include("afd.php");echo "</td> <td><input type=\"text\" size=\"9\" maxlength=\"5\" onkeypress=\"return isNumberKey(event)\" id=\"callnr\" name=\"callnr[]\" disabled /></td> <td width=\"6%\">";include("over.php");echo "</td> <td width=\"7%\">";echo $urendropdown;echo "</td> <td width=\"8%\">";echo $minutendropdown;echo "</td> <td><input type=\"text\" size=\"69\" name=\"omschrijving[]\" /></td> </tr> </table>"; echo "<br>"; echo "<input type='submit' name='submit' value='Verstuur' onClick=\"return confirm('Weet je zeker dat alle velden volledig ingevuld zijn?');\">\n"; echo "</form>\n"; echo "<a href=\"afdelingen/index.php\">Afdeling toevoegen</a> - <a href=\"medewerkers/index.php\">Medewerker toevoegen</a>"; ?> <br><br><hr><small><a href="http://www.zapatec.com/website/main/products/prod1/">Zapatec Javascript Calendar</a></small><br> </div> </body></html> Problem is that only the first one works. Thanks
  6. I edited my post, lol, but with the following result: No matter if ..., "Call" or "Other" is chosen.
  7. <table border=\"1\" bordercolor=\"#FFCC00\" style=\"background-color:#FFFFCC\" width=\"100%\" cellpadding=\"3\" cellspacing=\"3\"> <tr> <td>Type</td> <td>Gerelateerd</td> <td>Afdeling</td> <td>Call nummer</td> <td>Overige</td> <td>Tijd (hr)</td> <td>Tijd (min)</td> <td>Omschrijving</td> </tr> <tr> <td><select id="type" onChange="fieldEnable()"> <option value="0">...</option> <option value="1">Call</option> <option value="2">Other</option> </select></td> <td width=\"6%\"><?php include("spec.php"); ?></td> <td width=\"6%\"><?php include("afd.php"); ?></td> <td><input type="text" size="9" maxlength="5" onkeypress="return isNumberKey(event)" id='callnr' name="callnr[]" disabled /></td> <td><select id='overige' name='overige[]' disabled> <option value="0">...</option> <option value="1">what</option> <option value="2">is</option> <option value="2">Beheer?</option> </select></td> <td><select name="uren[]"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> </select></td> <td><select name="minuten[]"> <option value="00">00</option> <option value="15">15</option> <option value="30">30</option> <option value="45">45</option> </select></td> <td><input type="text" size="105" name="omschrijving[]"/></td> </tr> </table>
  8. Beheer = Management But this looks great! I'm gonna play with it now, will let you know what the result is. Edit; but am i still able to use the includes? <td><select id='afdeling' name='afdeling[]' disabled> <option value="0">...</option> <option value="1"> <?php include("afd.php"); ?> </option> <option value="2">go</option> <option value="3">here?</option> </select></td> Doesn't work of course, but how then? Thanks
  9. But uhm i don't get it... this way it's the one or the other table? Or how do i implement this?
  10. See index.php at http://www.phpfreaks.com/forums/index.php/topic,223122.msg1027581.html#msg1027581
  11. Lol, oke So shall we do this (if you have some spare time) or what else? Greetings
  12. Well, your idea sounds good. Didn't know that something like that could work I can't think of anything else for now, so perhaps we should to this. Thanks!
  13. Thats how it is like now right? No no, i'm just brain storming, it's not that i MUST be separated . I was just testing and thinking about the other form on how to do that the best way. Well i hope that it is clear what i am trying to do. The first form is to submit work hours from calls, the second form to submit work hours on other things you did. (Project, Management, Administration). It's no problem at all when it's in the same table and uses the same code, but it should work of course, so just requires a bit more trying and tweaking i guess to make it perfectly. Thanks for all!
  14. Well i just said that in my opinion it will be better to, indeed, split up the "uren" table in the DB. So if we go back to this image: http://www.uploader.gamergun.com/files/1/redgreen.PNG Then both the red and the green form will get a separate table in the database. That way it is easier to manage the data from both forms. (Easier and neater). I just used the "record overview" as another reason on why it would be better, because now the data from both forms are shown together which doesn't look very clear.
  15. Well, what do you think that is easier and better in both creating and using? Maybe it is neater and handier to split "uren" into 2 tables. 1 for the red part and the other one for the green part. I'm also thinking forward a bit, because at the moment i'm trying to make something up to view, edit and delete queries. See the screenshot below: I'm experiencing problems with this (like what to do with long descriptions, and also how to do the edit - remove fields) but that is for later. But what i mean is that perhaps also for that it is better to split up the table like said above. Thanks
  16. How r u? array(5) { [0]=> string(1) "2" [1]=> string(1) "1" [2]=> string(1) "3" [3]=> string(1) "1" [4]=> string(1) "1" } De volgende werkzaamheden zijn toegevoegd: - The following records are added: '1', '1', '2', '1', '6', '45', 'test1', '11111', '00-', '' '1', '1', '1', '1', '5', '15', 'test2', '42342', '00-', '' '1', '', '', '', '4', '15', 'test3', '', '00-', '' '1', '', '', '', '3', '30', 'test4', '', '00-', '' Edit; forgot to select date and week, here's again: array(5) { [0]=> string(1) "2" [1]=> string(1) "1" [2]=> string(1) "3" [3]=> string(1) "1" [4]=> string(1) "1" } De volgende werkzaamheden zijn toegevoegd: - The following records are added: '1', '1', '2', '1', '6', '45', 'test1', '11111', '2008-10-09', '41' '1', '1', '1', '1', '5', '15', 'test2', '42342', '2008-10-09', '41' '1', '', '', '', '4', '15', 'test3', '', '2008-10-09', '41' '1', '', '', '', '3', '30', 'test4', '', '2008-10-09', '41'
  17. Any idea why "overid" (from "overige" = others) is empty? De volgende werkzaamheden zijn toegevoegd: - The following records are added: '1', '', '', '', '1', '15', 'test1', '', '2008-10-16', '42' '1', '', '', '', '2', '30', 'test2', '', '2008-10-16', '42' '1', '', '', '', '2', '15', 'test3', '', '2008-10-16', '42' "specid" and "afdelingid" should be empty in this case. index.php <html><head> <title>Uren</title> <link rel="stylesheet" href="zpcal/themes/winter.css" /> <script type="text/javascript" src="zpcal/utils/zapatec.js"></script> <script type="text/javascript" src="zpcal/src/calendar.js"></script> <script type="text/javascript" src="zpcal/lang/calendar-du.js"></script> <SCRIPT language=Javascript> <!-- function isNumberKey(evt) { var charCode = (evt.which) ? evt.which : event.keyCode if (charCode > 31 && (charCode < 48 || charCode > 57)) return false; return true; } //--> </SCRIPT> </head> <body> <?php $connect = mysql_connect("localhost","root","password") or die ("Could not connect to database."); mysql_select_db("urendatabase"); $query1 = mysql_query( "SELECT `userid`, `voornaam`, `achternaam` FROM `werknemers` ORDER BY `userid` ASC" ) or die (mysql_error()); echo "<img src=\"http://www.cvis.nl/templates/bediajoomlatemplate/images/logo.png\">\n<br><br>"; echo "<form name='form1' method='post' action='insert.php'>\n"; $htmlToEcho = <<<EOT Datum: <input type="text" id="calendar" name="calendar" size="30" /> <button id="trigger">...</button> <script type="text/javascript">//<![CDATA[ Zapatec.Calendar.setup({ firstDay : 1, electric : false, inputField : "calendar", button : "trigger", ifFormat : "%d %B %Y (Week %W)", daFormat : "%Y/%m/%d" }); //]]></script> <noscript> <br/> Your browser does not support Javascript. <br/> Either enable Javascript in your Browser or upgrade to a newer version. </noscript> EOT; echo $htmlToEcho; $urendropdown = <<<EOT <select name="uren[]"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> </select> EOT; $minutendropdown = <<<EOT <select name="minuten[]"> <option value="00">00</option> <option value="15">15</option> <option value="30">30</option> <option value="45">45</option> </select> EOT; echo "<br><br>"; echo "Naam: <select name='werknemer'>\n"; while ($data = mysql_fetch_assoc($query1)) { echo "<option value='".$data['userid']."'>".$data['voornaam']." ".$data['achternaam']."</option>\n"; } echo "</select> <br><br>\n"; echo "<table border=\"1\" bordercolor=\"#FFCC00\" style=\"background-color:#FFFFCC\" width=\"100%\" cellpadding=\"3\" cellspacing=\"3\"> <tr> <td>Gerelateerd</td> <td>Afdeling</td> <td>Tijd (hr)</td> <td>Tijd (min)</td> <td>Call nummer</td> <td>Omschrijving</td> </tr> <tr> <td width=\"6%\">";include("spec.php");echo "</td> <td width=\"20%\">";include("afd.php");echo "</td> <td width=\"7%\">";echo $urendropdown;echo "</td> <td width=\"8%\">";echo $minutendropdown;echo "</td> <td width=\"5%\"><input type=\"text\" size=\"9\" maxlength=\"5\" onkeypress=\"return isNumberKey(event)\" name=\"callnr[]\" /></td> <td width=\"54%\"><input type=\"text\" size=\"105\" name=\"omschrijving[]\" /></td> </tr> <tr> <td width=\"6%\">";include("spec.php");echo "</td> <td width=\"20%\">";include("afd.php");echo "</td> <td width=\"7%\">";echo $urendropdown;echo "</td> <td width=\"8%\">";echo $minutendropdown;echo "</td> <td width=\"5%\"><input type=\"text\" size=\"9\" maxlength=\"5\" onkeypress=\"return isNumberKey(event)\" name=\"callnr[]\" /></td> <td width=\"54%\"><input type=\"text\" size=\"105\" name=\"omschrijving[]\" /></td> </tr> <tr> <td width=\"6%\">";include("spec.php");echo "</td> <td width=\"20%\">";include("afd.php");echo "</td> <td width=\"7%\">";echo $urendropdown;echo "</td> <td width=\"8%\">";echo $minutendropdown;echo "</td> <td width=\"5%\"><input type=\"text\" size=\"9\" maxlength=\"5\" onkeypress=\"return isNumberKey(event)\" name=\"callnr[]\" /></td> <td width=\"54%\"><input type=\"text\" size=\"105\" name=\"omschrijving[]\" /></td> </tr> <tr> <td width=\"6%\">";include("spec.php");echo "</td> <td width=\"20%\">";include("afd.php");echo "</td> <td width=\"7%\">";echo $urendropdown;echo "</td> <td width=\"8%\">";echo $minutendropdown;echo "</td> <td width=\"5%\"><input type=\"text\" size=\"9\" maxlength=\"5\" onkeypress=\"return isNumberKey(event)\" name=\"callnr[]\" /></td> <td width=\"54%\"><input type=\"text\" size=\"105\" name=\"omschrijving[]\" /></td> </tr> <tr> <td width=\"6%\">";include("spec.php");echo "</td> <td width=\"20%\">";include("afd.php");echo "</td> <td width=\"7%\">";echo $urendropdown;echo "</td> <td width=\"8%\">";echo $minutendropdown;echo "</td> <td width=\"5%\"><input type=\"text\" size=\"9\" maxlength=\"5\" onkeypress=\"return isNumberKey(event)\" name=\"callnr[]\" /></td> <td width=\"54%\"><input type=\"text\" size=\"105\" name=\"omschrijving[]\" /></td> </tr> </table>"; echo "<br>"; echo "<table border=\"1\" bordercolor=\"#FFCC00\" style=\"background-color:#FFFFCC\" width=\"100%\" cellpadding=\"3\" cellspacing=\"3\"> <tr> <td>Overige</td> <td>Tijd (hr)</td> <td>Tijd (min)</td> <td>Omschrijving</td> </tr> <tr> <td width=\"6%\">";include("over.php");echo "</td> <td width=\"7%\">";echo $urendropdown;echo "</td> <td width=\"8%\">";echo $minutendropdown;echo "</td> <td width=\"79%\"><input type=\"text\" size=\"160\" name=\"omschrijving[]\" /></td> </tr> <tr> <td width=\"6%\">";include("over.php");echo "</td> <td width=\"7%\">";echo $urendropdown;echo "</td> <td width=\"8%\">";echo $minutendropdown;echo "</td> <td width=\"79%\"><input type=\"text\" size=\"160\" name=\"omschrijving[]\" /></td> </tr> <tr> <td width=\"6%\">";include("over.php");echo "</td> <td width=\"7%\">";echo $urendropdown;echo "</td> <td width=\"8%\">";echo $minutendropdown;echo "</td> <td width=\"79%\"><input type=\"text\" size=\"160\" name=\"omschrijving[]\" /></td> </tr> <tr> <td width=\"6%\">";include("over.php");echo "</td> <td width=\"7%\">";echo $urendropdown;echo "</td> <td width=\"8%\">";echo $minutendropdown;echo "</td> <td width=\"79%\"><input type=\"text\" size=\"160\" name=\"omschrijving[]\" /></td> </tr> <tr> <td width=\"6%\">";include("over.php");echo "</td> <td width=\"7%\">";echo $urendropdown;echo "</td> <td width=\"8%\">";echo $minutendropdown;echo "</td> <td width=\"79%\"><input type=\"text\" size=\"160\" name=\"omschrijving[]\" /></td> </tr> </table>"; echo "<br>"; echo "<input type='submit' name='submit' value='Submit' onClick=\"return confirm('Weet je zeker dat alle velden volledig ingevuld zijn?');\">\n"; echo "</form>\n"; echo "<a href=\"afdelingen/index.php\">Afdeling toevoegen</a> - <a href=\"medewerkers/index.php\">Medewerker toevoegen</a>"; ?> <br><br><hr><small><a href="http://www.zapatec.com/website/main/products/prod1/">Zapatec Javascript Calendar</a></small><br> </body> </html> over.php <?php $query3 = mysql_query( "SELECT `overid`, `overige` FROM `overige` ORDER BY `overid` ASC" ) or die (mysql_error()); echo "<select name='overige[]'>\n"; while ($data = mysql_fetch_assoc($query3)) { echo "<option value='".$data['overid']."'>".$data['overige']."</option>\n"; } echo "</select>\n"; ?> insert.php <?php $con = mysql_connect("localhost","root","password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("urendatabase", $con); //names of the month in dutch $months = array ("Januari", "Februari", "Maart", "April", "Mei", "Juni", "Juli", "Augustus", "September", "Oktober", "November", "December"); $tmpDate = explode("(", $_POST['calendar']); //get date from form and explode into array $week = array_pop($tmpDate); //pop the week off the end of the date array $week = str_replace(array("Week ", ")"), "", $week);//get rid of the ) at the end of the week string $date = explode(" ", trim($tmpDate[0])); //explode the date into an array(day_num, month_str, year_num) $monthNum = 0; //this will hold the month number for the final date //check find the month name in the $months array and set the month number to $monthNum foreach($months as $key=>$month ){ if (strcasecmp($date[1], $month) == 0){ $monthNum = $key + 1; break; } } $date[1] = (($monthNum < 10)?"0":"").$monthNum; //set month number to $dat[1] in the proper format $date = array_reverse($date); //change date order from dd-mm-yyyy to yyyy-mm-dd for database $dateStr = implode("-", $date); //final date in a DB friendly format $werknemer = mysql_real_escape_string($_POST['werknemer']); $checkEmpty = 0; //counter to keep track of the amount of empty rows submitted. $success = array(); //keep records that were successfully inserted into DB for success msg. for ($i = 0; $i < 10; ++$i){ $afdeling = mysql_real_escape_string($_POST['afdeling'][$i]); $overige = mysql_real_escape_string($_POST['overige'][$i]); $uren = mysql_real_escape_string($_POST['uren'][$i]); $minuten = mysql_real_escape_string($_POST['minuten'][$i]); $specificatie = mysql_real_escape_string($_POST['specificatie'][$i]); $omschrijving = mysql_real_escape_string($_POST['omschrijving'][$i]); $callnr = mysql_real_escape_string($_POST['callnr'][$i]); if (empty($uren) || empty($minuten) || empty($omschrijving)){ ++$checkEmpty; //count each empty row continue; } else{ $sql="INSERT INTO uren (userid, specid, overid, afdelingid, uren, minuten, omschrijving, callnr, datum, week) VALUES ('$werknemer', '$specificatie', '$overige', '$afdeling', '$uren', '$minuten', '$omschrijving', '$callnr', '$dateStr', '$week')"; $success[] = array($werknemer, $specificatie, $overige, $afdeling, $uren, $minuten, $omschrijving, $callnr, $dateStr, $week); if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } } } //if all 10 rows were empty, echo the error msg. else, print success msg echo (($checkEmpty == 10) ? ("Je kunt geen leeg formulier opsturen - You can't send a blank form") : ("De volgende werkzaamheden zijn toegevoegd: - The following records are added:<br><br>")); //print information that was added to the DB $loopCount = count($success); for ($i = 0; $i < $loopCount; ++$i){ echo "'"; echo implode("', '", $success[$i]); echo "'"; echo "<br />"; } echo "<br><br>"; echo("<form><input type=\"button\" value=\"Vorige pagina\" onclick=\"parent.location='index.php'\" /></form>"); mysql_close($con) ?> So if we look at this: The red part uses: userid, specid, afdelingid, uren, minuten, omschrijving, callnr, datum, week '$werknemer', '$specificatie', '$afdeling', '$uren', '$minuten', '$omschrijving', '$callnr', '$dateStr', '$week' And the green part: userid, overid, uren, minuten, omschrijving, datum, week '$werknemer', '$overige', '$uren', '$minuten', '$omschrijving', '$dateStr', '$week' Thanks
  18. No problem, I'll figure it out how to do that with .htaccess haha (nightmares). I'm thinking about what to do more with the script. I already have the add hours, add employee and add departments pages. Now i need to start with the rapports page, so it will be possible to print hours from all employees, departments and 'gerelateed' (related). Also gotta find out how to make something up with check boxes to make it more dynamic. So for example print all hours from employee X and department Y. And maybe a page to delete stuff will be handy too. I will surely come back here Pz
  19. Ive been looking for that, but without a solution. Will check again later. Thanks!
  20. It's 18:34 pm here haha! But good morning It works perfectly now! Real good work m8. See below: <?php $con = mysql_connect("localhost","root","password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("urendatabase", $con); //names of the month in dutch $months = array ("Januari", "Februari", "Maart", "April", "Mei", "Juni", "Juli", "Augustus", "September", "Oktober", "November", "December"); $tmpDate = explode("(", $_POST['calendar']); //get date from form and explode into array $week = array_pop($tmpDate); //pop the week off the end of the date array $week = str_replace(array("Week ", ")"), "", $week);//get rid of the ) at the end of the week string $date = explode(" ", trim($tmpDate[0])); //explode the date into an array(day_num, month_str, year_num) $monthNum = 0; //this will hold the month number for the final date //check find the month name in the $months array and set the month number to $monthNum foreach($months as $key=>$month ){ if (strcasecmp($date[1], $month) == 0){ $monthNum = $key + 1; break; } } $date[1] = (($monthNum < 10)?"0":"").$monthNum; //set month number to $dat[1] in the proper format $date = array_reverse($date); //change date order from dd-mm-yyyy to yyyy-mm-dd for database $dateStr = implode("-", $date); //final date in a DB friendly format $werknemer = mysql_real_escape_string($_POST['werknemer']); $checkEmpty = 0; //counter to keep track of the amount of empty rows submitted. $success = array(); //keep records that were successfully inserted into DB for success msg. for ($i = 0; $i < 5; ++$i){ $afdeling = mysql_real_escape_string($_POST['afdeling'][$i]); $uren = mysql_real_escape_string($_POST['uren'][$i]); $minuten = mysql_real_escape_string($_POST['minuten'][$i]); $specificatie = mysql_real_escape_string($_POST['specificatie'][$i]); $omschrijving = mysql_real_escape_string($_POST['omschrijving'][$i]); $callnr = mysql_real_escape_string($_POST['callnr'][$i]); if (empty($uren) || empty($minuten) || empty($callnr) || empty($omschrijving)){ ++$checkEmpty; //count each empty row continue; } else{ $sql="INSERT INTO uren (userid, specid, afdelingid, uren, minuten, omschrijving, callnr, datum, week) VALUES ('$werknemer', '$specificatie', '$afdeling', '$uren', '$minuten', '$omschrijving', '$callnr', '$dateStr', '$week')"; $success[] = array($werknemer, $specificatie, $afdeling, $uren, $minuten, $omschrijving, $callnr, $dateStr, $week); if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } } } //if all 5 rows were empty, echo the error msg. else, print success msg echo (($checkEmpty == 5) ? ("Je kunt geen leeg formulier opsturen - You can't send a blank form") : ("De volgende werkzaamheden zijn toegevoegd: - The following records are added:<br><br>")); //print information that was added to the DB $loopCount = count($success); for ($i = 0; $i < $loopCount; ++$i){ echo "'"; echo implode("', '", $success[$i]); echo "'"; echo "<br />"; } echo "<br><br>"; echo("<form><input type=\"button\" value=\"Vorige pagina\" onclick=\"parent.location='index.php'\" /></form>"); mysql_close($con) ?> The result: De volgende werkzaamheden zijn toegevoegd: - The following records are added: '2', '1', '2', '2', '15', 'test1', '11111', '2008-10-02', '40' '2', '1', '1', '4', '30', 'test2', '45253', '2008-10-02', '40' Thank you very much. I'll play later with the above output so it will be more human-readable (guess with a read join) but the core is here, working! Thanks again. You'll here from me when i have another problem haha. Greetings
  21. Yup, it's dutch. I'm at home right now but i will change it for you tomorrow! Thanks for all the help. Greetings
  22. Sorry De volgende werkzaamheden zijn toegevoegd: - The following records are added: '1', '1', '1', '2', '45', 'test', '11111', '2008-10-29', ' ' $dateArray = explode($_POST['calendar'], " "); //get each element of the date into a seperate element $tmpWeek = array(array_pop($dateArray), array_pop($dateArray)); //separate the week from the rest of the date. we need this twice to get both "(week" and "41)" $tmpWeek = array_reverse($tmpWeek); //get things back in the right order $week = implode(" ", $tmpWeek); //put the week string back together $week = str_replace(array("(", ")"), "", $week); //this should get rid of the parenthesis around week $dateStr = implode(" ", $dateArray); //get the date back into string form $timeStamp = strtotime($dateStr); //create unix timestamp from date string $properDate = date("Y-m-d", $timeStamp); //this is the date in a DB-friendly form
  23. It's no problem at all, glad you wanna help string(1) " " string(0) "" int(1225234800) array(0) { } string(25) "01 Oktober 2008 (Week 40)" De volgende werkzaamheden zijn toegevoegd: - The following records are added: '2', '1', '1', '2', '15', 'test', '11111', '2008-10-29', ' ' var_dump ($week, $dateStr, $timeStamp, $dateArray, $_POST['calendar']);
  24. string(1) " " string(0) "" int(1225234800) array(0) { } De volgende werkzaamheden zijn toegevoegd: - The following records are added: '2', '2', '5', '3', '30', 'test', '12345', '2008-10-29', ' ' <?php $con = mysql_connect("localhost","root","password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("urendatabase", $con); $dateArray = explode($_POST['calendar'], " "); //get each element of the date into a seperate element $week = array_pop($dateArray); //separate the week from the rest of the date $week = str_replace(array("(", ")"), "", $week); //this should get rid of the parenthesis around week $dateStr = implode(" ", $dateArray); //get the date back into string form $timeStamp = strtotime($dateStr); //create unix timestamp from date string $properDate = date("Y-m-d", $timeStamp); //this is the date in a DB-friendly form var_dump ($week, $dateStr, $timeStamp, $dateArray); $werknemer = mysql_real_escape_string($_POST['werknemer']); $checkEmpty = 0; //counter to keep track of the amount of empty rows submitted. $success = array(); //keep records that were successfully inserted into DB for success msg. for ($i = 0; $i < 5; ++$i){ $afdeling = mysql_real_escape_string($_POST['afdeling'][$i]); $uren = mysql_real_escape_string($_POST['uren'][$i]); $minuten = mysql_real_escape_string($_POST['minuten'][$i]); $specificatie = mysql_real_escape_string($_POST['specificatie'][$i]); $omschrijving = mysql_real_escape_string($_POST['omschrijving'][$i]); $callnr = mysql_real_escape_string($_POST['callnr'][$i]); if (empty($uren) || empty($minuten) || empty($callnr) || empty($omschrijving)){ ++$checkEmpty; //count each empty row continue; } else{ $sql="INSERT INTO uren (userid, specid, afdelingid, uren, minuten, omschrijving, callnr, datum, week) VALUES ('$werknemer', '$specificatie', '$afdeling', '$uren', '$minuten', '$omschrijving', '$callnr', '$properDate', '$week')"; $success[] = array($werknemer, $specificatie, $afdeling, $uren, $minuten, $omschrijving, $callnr, $properDate, $week); if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } } } //if all 5 rows were empty, echo the error msg. else, print success msg echo (($checkEmpty == 5) ? ("Je kunt geen leeg formulier opsturen - You can't send a blank form") : ("De volgende werkzaamheden zijn toegevoegd: - The following records are added:<br><br>")); //print information that was added to the DB $loopCount = count($success); for ($i = 0; $i < $loopCount; ++$i){ echo "'"; echo implode("', '", $success[$i]); echo "'"; echo "<br />"; } echo "<br><br>"; echo("<form><input type=\"button\" value=\"Vorige pagina\" onclick=\"parent.location='index.php'\" /></form>"); mysql_close($con) ?>
×
×
  • 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.