Ok, my site actually depends on the this day in history module. Every day, it displays the birthdays of famous people. It all works great. But I do have a couple of issues. I added an advanced search option. I want my visitors to be able to select a date, hit "zoeken" and then my site must show all of the birthdays of that particulary day. This must be shown in the content area.
Here is what i have done so far. I created a block called "zoekdatum" and put this code in it:
// variables
$maand = $_POST["MAAND"];
$dag = $_POST["DAG"];
// selectieformuliertje
$mijnForm = '
<form method="post" action="/site//modules/birthdays/sdate.php" target = "content">
<select name="DAG" size="1">
<option value="1">1</option>
...
...
<option value="31">31</option>
</select>
<select name="MAAND" size="1">
<option value="1">Januari</option>
...
...
<option value="12">December</option>
</select>
<input type="submit" value="Zoeken" name="Klik"><br />
</form>';
echo $mijnForm;
This is the sdate.php-file:
// variables
$server = "localhost";
$database = "***";
$db_user = "***";
$db_pass = "***";
$maand = $_POST["MAAND"];
$dag = $_POST["DAG"];
// connect to the mysql server
$link = mysql_connect($server, $db_user, $db_pass)
or die ("Could not connect to mysql because ".mysql_error());
// select the database
mysql_select_db($database)
or die ("Could not select database because ".mysql_error());
$rows = 200;
// read data from database
$result = mysql_query("select a.nid, a.body, b.year, b.month, b.day FROM node_revisions as a LEFT JOIN thisdayinhistory b ON (a.nid = b.nid) where month='$maand' and day='$dag' ORDER by b.year asc limit $rows", $link)
or die ("Could not read data because ".mysql_error());
// print the data
echo "Jarig op ", $dag, " - ", $maand, "<br><br>";
if (mysql_num_rows($result)) {
while ($qry = mysql_fetch_array($result)) {
echo $qry[year], ": ", $qry[body] ;
echo "<br>";
}
}
This kinda works. When I hit the "Zoeken"- button, the results are shown on a new tab (Firefox). IE opens a new window. Also, there are strange characters shown: é, í, á are shown as � (only in Firefox; IE shows them correctly).
What I want is that when I hit the "zoeken"- button, my site shows the results in the content area, without the �-characters and with the selected theme. But I'm stuck! Don't know how to fix these issues.
Can someone please help me out? My site is at www.vandaagjarig.com (Drupal 5.7; PHP 5.2.6; MYSQL 5.0.32)
Btw. I am totally not into PHP coding. I created the block and the sdate.php I mentioned using good ol' Google. (It took me a couple of days though!)
Comments
Anyone please???
Anyone please???