I have a dynamically created dorpdown list where users can select newsletters. I am trying to get it to work so when you select something from the dropdown list then a php file gets executed. My dropdown list looks like this:
<?php
echo "<select id=\"NieuwsbriefSelect\" name=\"show\" onchange=\"what do I do here??? \">";
echo "<option size =30 selected>Select</option>";
if(mysql_num_rows($sql_result))
{
while($row = mysql_fetch_assoc($sql_result))
{
echo "<option value=\"$row[Titel]\">$row[Titel]</option>";
}
}
else {
echo "<option>No Names Present</option>";
}
?>
And my php file looks like this:
<?php
ini_set('display_errors', 'On');
error_reporting(E_ALL);
?>
<?php
$title = $_REQUEST["show"];
mysql_connect('localhost','root','root');
mysql_select_db('NAW') or die (mysql_error());
$strSQL = "SELECT Content from NAW.Mail where Titel = '".$title."' ";
$sql_result = mysql_query($strSQL);
$row = mysql_fetch_assoc($sql_result);
$file = 'nieuwsbrief.txt';
$current = urldecode($row["Content"]);
file_put_contents($file, $current);
?>
Currently this: $title = $_REQUEST["show"]; is not working and gives the error Undefined index: show. So basicly I have 2 questions:
-How do I get the php file to execute when I select a newsletter?
-How do I the right data from my DB according to my selected newsletter?
I have tried several things with examples I found on other forums etc but since I have almost no experience with javascript I can't get anything to work. If anyone could give me an example or push me in the right direction it would be great! If you have any other questions just ask them as a comment!
NOTE I know that mysql_* is deprecated and I will change to PDO once I get everything to work!