Yes that was it what I tried to do.
So I am having another problem.
First of all I am having a database named fernschule. It has 3 tables which are:
t_kurse
t_institute
t_ins_kurse
t_kurse includes course names and their IDs like KURSE_NAME KURSE_CODE
t_institute includes institute names which give these courses like INS_NAME INS_CODE
t_ins_kurse includes the foreign keys KURSE_CODE INS_CODE
What I am trying to do is to build a php page which takes the course names into a combobox and their IDs as OPTION value and search the institute(s) which includes the selected course.
So here is my first php page
<?php
/*
* Created on 12.11.2006
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
*/
$link = mysql_connect('localhost','root','admin');
$db = mysql_select_db("fernschule");
if (!$link) {
die('Could not connect: ' . mysql_error());
}
$sqlquery = "select * from t_kurse ORDER BY KURSE_NAME";
$res = mysql_query($sqlquery);
echo "<FORM ACTION = 'trial1.php' METHOD = 'POST'>";
echo "<SELECT NAME ='t_kurse'>";
while($dsatz = mysql_fetch_assoc($res)) {
$value = $dsatz["KURSE_CODE"];
echo "<OPTION VALUE=".$value.">".$dsatz["KURSE_NAME"]."</OPTION>";
}
echo "<INPUT TYPE = 'SUBMIT' VALUE = 'Suchen'>";
echo "<input type='reset' VALUE = 'Abbrechen'>";
mysql_close($link);
?>
So the trial1.php is
<?php
/*
* Created on 11.12.2006
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
*/
$link = mysql_connect('localhost','root','admin');
$db = mysql_select_db("fernschule");
if (!$link) {
die('Could not connect: ' . mysql_error());
}
$sqlquery = "SELECT t_institute.INS_NAME
FROM t_kurse INNER JOIN (t_institute INNER JOIN t_ins_kurse ON t_institute.INS_CODE=t_ins_kurse.INS_CODE) ON t_kurse.KURSE_CODE=t_ins_kurse.KURSE_CODE
WHERE (((t_kurse.KURSE_CODE)=".$_POST['value']."))";
$res = mysql_query($sqlquery);
while($dsatz = mysql_fetch_assoc($res)) {
echo "<p>".$dsatz["INS_NAME"]."</P>";
}
?>
So it gives error in SQL code. I tried to include the $value variable in the second file as a posted value but it doesn't accept it and gives this error.
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:\Programme\xampp\htdocs\trial1.php on line 18
So how should I write this SQL query so that it takes the OPTION VALUE $value from trial.php and compares it in trial1.php? Can anyone help me?
Your attitude determines your altitude
|