PDA

View Full Version : printing a result after an option has been submitted


dutchie
05-15-2005, 10:13 PM
Hi,

I'm sitting with a question, where I have spend a lot headaches on already?
My goal is this.- To print another field value 'scriptcode', of the same row after an option 'scriptnaam' is submitted.

The first part isn't the problem. I do get all the data 'scriptnaam' in a select field.
But to distillate, a result 'scriptcode' out of it ???

If someone could help me a bit further with that, that would be great.
I like to mention, that I've just started with PHP/MYSQL, so my knowledge about it is limited.

Thanks beforehands

dutchie


++++++++++++++++++++++ here's the code++++++++++++++++++++++++

<?

//control code

if(!isset($_POST['submit'])){select_option_field();
}else{ print_selected_script();}
//end if

//---------------------------------------------------------------------------------------
// select option field
//---------------------------------------------------------------------------------------

function select_option_field()
{
$host="localhost";
$db="snippets";
$user="root";
$pass="password";
$table="htmlcss";
//$scriptnaam="scriptnaam";
$link= mysql_connect($host, $user, $pass);
mysql_select_db($db);
$scriptnaam="SELECT `scriptnaam` FROM $table";
$result= mysql_query($scriptnaam);

echo "<html><body><form action=".$_SERVER['PHP_SELF']." method=post>";
echo"<table><tr><td>Kies een script</td><td><select name='select_option_field'>";
while ($line= mysql_fetch_array($result)){foreach ($line as $value){
echo "<option value='$value' ";}
echo ">$value</option>";}
echo "</select></td></tr>";
echo "<tr><td colspan=2><input name='submit' type='submit' value='Select Script'></td></tr></form>";
}
+++++++++++++++++++++++++++++++++To this point, all is working fine++++++++++++++++++++++++++++++++++

++++++++++++++++from here, I realy don't know or how to get it done++++++++++++++++++++++++++++++++++
function print_selected_script(){
if ($_POST[submitted]= 'yes'){
$script= $_POST[submit];
echo "<tr><th>$script</th><tr>";
}
}
echo "</table></body></html>";
?>
++++++++++++++++ All I get is 'Select Script'++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Tangerine Dream
05-16-2005, 01:40 AM
All I get is 'Select Script'
Hi, but you don't issue any queries in print_selected_script(), so how can you get any column values:


function print_selected_script()
{
// you should use single or double quotes for string indexes:
if ($_POST['submitted']= 'yes'){
$script= $_POST['submit'];
echo "<tr><th>$script</th><tr>";
}