473,383 Members | 1,868 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,383 software developers and data experts.

PHP - Mysql Question

Hey everybody.
I'm verrynew to PHP and MYSQL and have been working on a form that
when it is submitted stores the information into a mysql database.
The main problem is that i'm trying to finish up my script for almost
a week now and I still cant get it right.
here is the code

<?php

include ("ES_includes/appconst.inc.php") ;
// Ceck of begin datum juist is
if (!checkdate ($_POST['maand_van'],$_POST['dag_van'],$_POST['jaar_van'])){
echo "De begin datum die u hebt opgegeven is ontjuist <b>"
..$_POST['dag_van']. "/" .$_POST['maand_van']. "/" .$_POST['jaar_van'].
"</b>.<br>";
}
else
{
//check of begin datum reeds in het database staat
$datum= $_POST['jaar_van']."-".$_POST['maand_van']."-".$_POST['dag_van'];
$db = mysql_connect("$dbHost", "$dbUser","$dbPwd");
mysql_select_db($dbName,$db);
$sql_check = "SELECT * FROM verlof WHERE
gebruikersID='$_POST['gebruikersID']' AND datum='$datum'";
$check = mysql_query($sql_check,$db);

if (mysql_num_rows($check) != 0){
echo "Deze datums staan reeds in het databse op uw naam.\n";
}
else
{
$sql = "INSERT INTO verlof (gebruikersID, datum, voormiddag,
namiddag, opm_aanvrager) VALUES
('$_POST['gebruikersID']','$datum','$_POST['voormiddag']','$_POST['namiddag']','$_POST['opm_aanvrager']')";
$result = mysql_query($sql);
echo "Uw verlof aanvraag is aangevraagd.\n";
}
}
echo "<br><input type=button value=\"Terug\"
onClick=\"history.go(-1)\"><br>";

$datum_van= $_POST['dag_van']."/".$_POST['maand_van']."/".$_POST['jaar_van'];
$datum_tot= $_POST['dag_tot']."/".$_POST['maand_tot']."/".$_POST['jaar_tot'];

$day1="Monday";
$day2="Tuesday";
$day3="Wednesday";
$day4="Thursday";
$day5="Friday";

$mydate=$datum_van;
$newsplit = explode("/", $mydate);
$dat1=mktime(0,0,0,$newsplit[1],$newsplit[0],$newsplit[2]);

$mydate=$datum_tot;
$newsplit = explode("/", $mydate);
$dat2=mktime(0,0,0,$newsplit[1],$newsplit[0],$newsplit[2]);

$datc=$dat1;
while ($datc<=$dat2){
$datw=date("d/m/Y",$datc);
$jour=date ("l", $datc);
if ($day1==$jour || $day2==$jour || $day3==$jour || $day4==$jour
|| $day5==$jour){
print (date("Y/m/d",$datc)."<br>");
} $datc=$datc + 86400;
}
?>

Now what does it have to do..
When the form gets submitted it must check it datum_van is correct

if (!checkdate ($_POST['maand_van'],$_POST['dag_van'],$_POST['jaar_van'])){

and here is my first problem.
It also has to check if datum_tot is valid so there has to be a new
if (!checkdate ($_POST['maand_van'],$_POST['dag_van'],$_POST['jaar_van'])){
but this time with the values of dag_tot, maand_tot, jaar_tot

than it should get all the weekdays (from mon. till vri.) between
those two dates and this is the script i use for it
$datum_van= $_POST['dag_van']."/".$_POST['maand_van']."/".$_POST['jaar_van'];
$datum_tot= $_POST['dag_tot']."/".$_POST['maand_tot']."/".$_POST['jaar_tot'];

$day1="Monday";
$day2="Tuesday";
$day3="Wednesday";
$day4="Thursday";
$day5="Friday";

$mydate=$datum_van;
$newsplit = explode("/", $mydate);
$dat1=mktime(0,0,0,$newsplit[1],$newsplit[0],$newsplit[2]);

$mydate=$datum_tot;
$newsplit = explode("/", $mydate);
$dat2=mktime(0,0,0,$newsplit[1],$newsplit[0],$newsplit[2]);

$datc=$dat1;
while ($datc<=$dat2){
$datw=date("d/m/Y",$datc);
$jour=date ("l", $datc);
if ($day1==$jour || $day2==$jour || $day3==$jour || $day4==$jour
|| $day5==$jour){
print (date("Y/m/d",$datc)."<br>");
} $datc=$datc + 86400;
}

now here is the second problem.
in my database i have one table called datum
now for every weekday between these two dates the script must create a
record
so that when i submit my form with the following dates
13/01/2003
18/01/2003
and I have selected "namiddag or voormiddag" in my form
I would find in my datase the following records
__________________________________________________ _________________
| gebruikersID | datum | voormiddag | namiddag |opm_aanvrager|
-------------------------------------------------------------------
| Username |13/01/2003 | 1 |or| 1 | some text |
| Username |14/01/2003 | 0 |0 | some text |
| Username |15/01/2003 | 0 |0 | some text |
| Username |16/01/2003 | 0 |0 | some text |
| Username |17/01/2003 | 0 |0 | some text |
-------------------------------------------------------------------
the 18th will be left out because it is a saterday.
I hope some of the experts here can help me out because I'm totaly
lost and realy need this script asap many thanks in advanced
Tiernan.

ps. sorry for my english :)
Jul 16 '05 #1
0 1769

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
by: Westcoast Sheri | last post by:
To keep track of how many fruits my visitors buy, I use a mySQL database (2 columns: "fruit" and "quantity")....so can we make these following mySQL queries work somehow? (visitor buys 5...
0
by: MJL | last post by:
This is a mysql/php question (but a little more on the mysql side.) The two are so closely related these days, I thought it would be ok to ask here. I installed on my Suse Linux system mysql 4.0...
8
by: Tony Clarke | last post by:
Hi, Just a quick question about performance with MySQL & PHP. If I had a table in a MySQL database with about 100,000 records in it and I need to find the last record is there a quick way to do...
2
by: pieter_hordijk | last post by:
Hi all, maybe this isn't a php question, but a MySQL question. If so I'm sorry for asking you guys to help me :) I know this question is asked often in NGs, but I couldn't find the answer...
2
by: kimshapiro100 | last post by:
Question on PhP, MySQL I am thinking of a consumer internet business for which I will have to have a database driven site built. I am thinking of using PhP, MySQL as the main technologies...
39
by: Mairhtin O'Feannag | last post by:
Hello, I have a client (customer) who asked the question : "Why would I buy and use UDB, when MySql is free?" I had to say I was stunned. I have no experience with MySql, so I was left sort...
1
by: Jim Carlock | last post by:
I have a couple questions about MySQL involving which version of MySQL to use. I'm looking for minimal memory use on a Windows XP machine. Which version would be best for this? And can anyone...
15
by: Cheryl Langdon | last post by:
Hello everyone, This is my first attempt at getting help in this manner. Please forgive me if this is an inappropriate request. I suddenly find myself in urgent need of instruction on how to...
5
by: news.telia.net | last post by:
Hi! I have a question. I have installed php and mysql on an apache-server on windows and I can't connect to the server. I tried to create a database (since I am trying to learn howto). My...
27
by: gerrymcc | last post by:
Hello, I'm a php/mysql beginner... Is there any way of making the mysql command line client full-screen? Sometimes it's easier to use the client than go thru php, but since it's only about 80...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.