I'm trying to construct a database of old houses including the parts
they are made of as roof construction, floor construction, types of
windows, vaults, etc. To do that I set up several tables. One
containing the house id, address, last visit, etc. For each of the
construction items there is a tabel containing the construction id and
the short description. Both tables should be linked by a table
containg the house id numbers and the fitting construction id numbers.
As there is much similarity in getting the right descriptions and
inserting the right values into the right tables I tried to make
functions to do that. Somehow this does't work.
An example for doing this for vaults is here:
(It is not in English, here follows a kind of translation)
.......
Vault:
<select name = "vaulttype">
<?php
$sqlvlt = 'SELECT vaultnr, description FROM vaulttype ORDER BY
`vaultr` ASC';
$resultvlt =mysql_query($sqlvlt,$conn)or die("No vault type today");
while($row = mysql_fetch_row($resultvlt))
{
echo "<option value=\"";
echo $row[0]."\">";
echo $row[1]."</option>\n";
}
?>
</select>
<input type="submit" name="vault" value="Submit">
</FORM>
<?php
$thisisit = $_POST['vaulttype'];
//hereafter testing for double values and actually inserting
?>
........
This works fine.
The function so far goes:
<?php
function getconstruction($construction){
global $houseid;
global $conn;
$a = $construction;
$b = $construction."type";
$c = $construction."nr";
echo $a.": ";
echo "<SELECT NAME = \"$b\">";
$sql = "SELECT $c, description FROM $b ORDER BY '$c' ASC";
$result = mysql_query($sql,$conn)or die(mysql_error());
while($row = mysql_fetch_row($result))
{
echo "<option value=\"";
echo $rij[0]."\">";
echo $rij[1]."</option>\n";
}
echo "</select>";
echo "<input type=\"submit\" name=\"$a\" value=\"Submit\">";
$gotconstruction = $_POST['vaulttype'];
return $gotconstruction;
}
getconstruction(vault);
?>
Now I get the list I ask for but further nothing whatsoever.
When I ask for the value of $gotconstruction the answer is vaulttype,
while when asking for $thisisit the answer is the number I want.
There are no error messages.
What is it I'm overlooking?
What is it I'm doing wrong?
How should I tackle this?
Thanks in advance,
Henny Boxa
>> Stay informed about: function problem involving query