Verjaardagen laten zien
Gewijzigd op 17/12/2004 10:49:00 door Martijn Rouwendal
------------
index.php
------------
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<link rel="Stylesheet" href="" type="text/css">
<body bgcolor="#FFFFFF" text="#000000">
<a href="javascript:history.back()">< Terug</a>
<!-- SCRIPT WRITTEN BY Ridder Roeland and available at come.to/ridderroeland -->
<FORM NAME="speak" METHOD="post" ACTION="post_birthday.php">
<p><font size="3"><b></b></font></p>
<table width="50%" border="0" cellspacing="0" cellpadding="2">
<tr>
<td><a href="show.php?month=1">
</a></td>
<td><a href="show.php?month=7">
</a></td>
</tr>
<tr>
<td><a href="show.php?month=2">
</a></td>
<td><a href="show.php?month=8">
</a></td>
</tr>
<tr>
<td><a href="show.php?month=3">
</a></td>
<td><a href="show.php?month=9">
</a></td>
</tr>
<tr>
<td><a href="show.php?month=4">
</a></td>
<td><a href="show.php?month=10">
</a></td>
</tr>
<tr>
<td><a href="show.php?month=5">
</a></td>
<td><a href="show.php?month=11">
</a></td>
</tr>
<tr>
<td><a href="show.php?month=6">
</a></td>
<td><a href="show.php?month=12">
</a></td>
</tr>
</table>
<p><b><font size="3"></font></b></p>
<table width="39%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td> </td>
<td colspan="2">
<input type="text" name="name" class="formelement">
</td>
</tr>
<tr>
<td></td>
<td>
<select name="day" class="formelement">
<option class="Option" value="select" selected>Select...</option>
<option class="Option" value="01">1</option>
<option class="Option" value="02">2</option>
<option class="Option" value="03">3</option>
<option class="Option" value="04">4</option>
<option class="Option" value="05">5</option>
<option class="Option" value="06">6</option>
<option class="Option" value="07">7</option>
<option class="Option" value="08">8</option>
<option class="Option" value="09">9</option>
<option class="Option" value="10">10</option>
<option class="Option" value="11">11</option>
<option class="Option" value="12">12</option>
<option class="Option" value="13">13</option>
<option class="Option" value="14">14</option>
<option class="Option" value="15">15</option>
<option class="Option" value="16">16</option>
<option class="Option" value="17">17</option>
<option class="Option" value="18">18</option>
<option class="Option" value="19">19</option>
<option class="Option" value="20">20</option>
<option class="Option" value="21">21</option>
<option class="Option" value="22">22</option>
<option class="Option" value="23">23</option>
<option class="Option" value="24">24</option>
<option class="Option" value="25">25</option>
<option class="Option" value="26">26</option>
<option class="Option" value="27">27</option>
<option class="Option" value="28">28</option>
<option class="Option" value="29">29</option>
<option class="Option" value="30">30</option>
<option class="Option" value="31">31</option>
</select>
</td>
<td>
<select name="month" class="formelement">
<option class="Option" value="select" selected>Select...</option>
<option class="Option" value="01"></option>
<option class="Option" value="02"></option>
<option class="Option" value="03"></option>
<option class="Option" value="04"></option>
<option class="Option" value="05"></option>
<option class="Option" value="06"></option>
<option class="Option" value="07"></option>
<option class="Option" value="08"></option>
<option class="Option" value="09"></option>
<option class="Option" value="10"></option>
<option class="Option" value="11"></option>
<option class="Option" value="12"></option>
</select>
</td>
</tr>
<tr>
<td> </td>
<td colspan="2">
<input type="text" name="year" class="formelement">
</td>
</tr>
<tr>
<td>
<input type="submit" name="Submit" value="" class="formbutton">
</td>
<td> </td>
<td> </td>
</tr>
</table>
</form>
</body>
</html>
------------------
post_birthday.php
--------------------
<HTML>
<!--
BirthSys 2.0
Script written by R. Vinke aka Ridder Roeland
http://come.to/ridderroeland
(c)opyright 2001 R. Vinke
-->
<HEAD>
<META name="author" content="Ronald Vinke">
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<META HTTP-EQUIV="refresh" CONTENT="0;URL=show.php?month=">
<TITLE></TITLE>
</HEAD>
<BODY>
<link rel="Stylesheet" href="" type="text/css">
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?php
//$error = false;
if($name == '')
{
echo "<p>$nameerror</p>";
}
else
{
if($month == 'select')
{
echo "<p>$montherror</p>";
}
else
{
mysql_connect ("$servername", "$dbusername", "$dbpassword");
mysql_select_db ("$dbname");
if (mysql_query ("INSERT INTO birthsys (id, month, day, year, name) values (NULL, '$month', '$day', '$year', '$name')"))
{
echo "";
}
else {
echo mysql_error();
}
}}
?>
//$error = false;
if($name == '')
{
echo "<p>$nameerror</p>";
}
else
{
if($month == 'select')
{
echo "<p>$montherror</p>";
}
else
{
mysql_connect ("$servername", "$dbusername", "$dbpassword");
mysql_select_db ("$dbname");
if (mysql_query ("INSERT INTO birthsys (id, month, day, year, name) values (NULL, '$month', '$day', '$year', '$name')"))
{
echo "";
}
else {
echo mysql_error();
}
}}
?>
</BODY>
</HTML>
--------------------------
show.php
--------------------------
<link rel="Stylesheet" href="" type="text/css">
<a href="javascript:history.back()">< Terug</a>
Code (php)
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
<?php
// function to give the month a name, instead of the digits.
$monthName = array(01=> "$jan", "$feb", "$mar",
"$apr", "$may", "$jun", "$jul", "$aug",
"$sep", "$okt", "$nov", "$dec");
$monthname=("$monthName[$month]");
?>
// function to give the month a name, instead of the digits.
$monthName = array(01=> "$jan", "$feb", "$mar",
"$apr", "$may", "$jun", "$jul", "$aug",
"$sep", "$okt", "$nov", "$dec");
$monthname=("$monthName[$month]");
?>
<p><font size="3"><b></b></font>
<TABLE WIDTH="100%" border="0" cellspacing="0" cellpadding="2">
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
// Connect to database and display results
mysql_connect ("$servername", "$dbusername", "$dbpassword");
mysql_select_db ("$dbname");
$result = mysql_query("SELECT * FROM birthsys WHERE month= $month ORDER BY day");
if ($row = mysql_fetch_array($result)) {
do{
$day = $row[day];
$name = $row[name];
require("funcs_$lang.php");
echo "
<TR ALIGN=\"left\" VALIGN=\"top\">
<TD WIDTH=\"10%\"><B>$day:</B></TD>
<TD><DIV ALIGN=\"left\">$name</DIV></TD>
<TD><DIV ALIGN=\"left\">$sign</DIV></TD>
";
if($picshow== "1")
{
echo "<TD><DIV ALIGN=\"left\"><IMG SRC=\"$pic.$ext\"></TD></TR>";
}
else
{
echo "</TR>";
}
}
while($row = mysql_fetch_array($result));
}
else {
print "$nobirth";
}
?>
// Connect to database and display results
mysql_connect ("$servername", "$dbusername", "$dbpassword");
mysql_select_db ("$dbname");
$result = mysql_query("SELECT * FROM birthsys WHERE month= $month ORDER BY day");
if ($row = mysql_fetch_array($result)) {
do{
$day = $row[day];
$name = $row[name];
require("funcs_$lang.php");
echo "
<TR ALIGN=\"left\" VALIGN=\"top\">
<TD WIDTH=\"10%\"><B>$day:</B></TD>
<TD><DIV ALIGN=\"left\">$name</DIV></TD>
<TD><DIV ALIGN=\"left\">$sign</DIV></TD>
";
if($picshow== "1")
{
echo "<TD><DIV ALIGN=\"left\"><IMG SRC=\"$pic.$ext\"></TD></TR>";
}
else
{
echo "</TR>";
}
}
while($row = mysql_fetch_array($result));
}
else {
print "$nobirth";
}
?>
</table>
---------------------------------------------------------
Hoe krijg ik het voor elkaar om op de dag dat er iemand jarig is op een bepaalde plaats op een pagina het volgende staat:
$name van harte gefeliciteerd!
Ik hoop dat iemand me kan helpen.
met vriendelijke groet,
Martijn Rouwendal
Martijn:
Wanneer je meer bestanden nodig hebt, schrijf dan even een reply
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?
$sql = "SELECT * FROM birthsys WHERE month='$month' AND day = '$day'";
$res = mysql_query($sql);
$tot = mysql_num_rows($res);
if ($tot == 0) {
echo "Er zijn vandaag geen mensen jarig.";
} else {
echo "Vandaag zijn jarig:<br>";
while ($rec = mysql_fetch_array($res)) {
echo $rec['name']." [".$rec['year']."]<br>";
}
}
?>
$sql = "SELECT * FROM birthsys WHERE month='$month' AND day = '$day'";
$res = mysql_query($sql);
$tot = mysql_num_rows($res);
if ($tot == 0) {
echo "Er zijn vandaag geen mensen jarig.";
} else {
echo "Vandaag zijn jarig:<br>";
while ($rec = mysql_fetch_array($res)) {
echo $rec['name']." [".$rec['year']."]<br>";
}
}
?>
Code (php)
1
2
3
2
3
<?php
$SQLopdracht = "SELECT * FROM tabelnaam WHERE verjaardag='" . date("Y-m-d") . "'";
?>
$SQLopdracht = "SELECT * FROM tabelnaam WHERE verjaardag='" . date("Y-m-d") . "'";
?>
Peter:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?
$sql = "SELECT * FROM birthsys WHERE month='$month' AND day = '$day'";
$res = mysql_query($sql);
$tot = mysql_num_rows($res);
if ($tot == 0) {
echo "Er zijn vandaag geen mensen jarig.";
} else {
echo "Vandaag zijn jarig:<br>";
while ($rec = mysql_fetch_array($res)) {
echo $rec['name']." [".$rec['year']."]<br>";
}
}
?>
$sql = "SELECT * FROM birthsys WHERE month='$month' AND day = '$day'";
$res = mysql_query($sql);
$tot = mysql_num_rows($res);
if ($tot == 0) {
echo "Er zijn vandaag geen mensen jarig.";
} else {
echo "Vandaag zijn jarig:<br>";
while ($rec = mysql_fetch_array($res)) {
echo $rec['name']." [".$rec['year']."]<br>";
}
}
?>
Wanneer ik deze code gebruik komt er wel te staan dat er vandaag niemand jarig is, maar wanneer er iemand jarig is laat hij dat niet zien. Dan staat er ook gewoon Er zijn vandaag geen mensen jarig.
Doe ik iets verkeerd???
Ik heb de code uitgeprobeert in een blanco php file.