Welcome to dbFreaks.com!
FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

function problem involving query

 
   Database Help (Home) -> PHP SQL RSS
Next:  mbstring, mcrypt, php4ts and other errors  
Author Message
Henny Boxa

External


Since: Mar 25, 2008
Posts: 2



(Msg. 1) Posted: Tue Mar 25, 2008 9:21 am
Post subject: function problem involving query
Archived from groups: alt>php>sql (more info?)

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 
Back to top
Login to vote
David Quinton

External


Since: Oct 08, 2007
Posts: 19



(Msg. 2) Posted: Wed Mar 26, 2008 8:06 am
Post subject: Re: function problem involving query [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Tue, 25 Mar 2008 09:21:58 +0100, Henny Boxa <tirelibom.TakeThisOut@hotnet.com>
wrote:

>I'm trying to construct a database of old houses

I'm not totally sure I understand fully but AFAICT you're assuming
that you are POSTING from within the Function.

But the POST will be to the whole script - not just to that Function?
--
Locate your Mobile phone: <http://www.bizorg.co.uk/news.html>
Great gifts: <http://www.ThisBritain.com/ASOS_popup.html>

 >> Stay informed about: function problem involving query 
Back to top
Login to vote
Henny Boxa

External


Since: Mar 25, 2008
Posts: 2



(Msg. 3) Posted: Fri Mar 28, 2008 6:32 pm
Post subject: Re: function problem involving query [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Wed, 26 Mar 2008 08:06:45 +0000 wrote David Quinton
<usenet_2005D_email DeleteThis @REMOVETHISBITbizorg.co.uk>:

>On Tue, 25 Mar 2008 09:21:58 +0100, Henny Boxa <tirelibom DeleteThis @hotnet.com>
>wrote:
>
>>I'm trying to construct a database of old houses
>
>I'm not totally sure I understand fully but AFAICT you're assuming
>that you are POSTING from within the Function.
>
>But the POST will be to the whole script - not just to that Function?

I'm afraid I was overlooking that.
Thank you,
Henny
 >> Stay informed about: function problem involving query 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
SQL needs AGE function. - Hello, I want to select people from a database within a certain age range. For example: Select * From TablePerson Where (Age(Birthdate) > 20) and (Age(Birthdate) < 98) That would make it really easy. Things I have tried so far: Trail 1, SQL....

mysql_connect and private user function - Hi, got a bit stuck whit this... I have page where I connect to database and it works fine, but when I try to do it in my own function, I get error. my code: ----------------------------------------------- //connect to database... $con =..

Upgrade problem - Hi folks, I recently upgraded my db from version 3.23.49 (I think) to 4.0.23. I had previously done this on two other machines with no problems but on this server some (not all) of my MySQL user accounts have stopped working. For example one I had to...

Weird mysql_connect problem - Hello. My mysql_connect just started to give me following error today, Fatal error: Call to undefined function: mysql_connect() in ..../database_functions/db_functions.inc.php on line 11. So it seems that my php no longer finds php-mysql module...

[MySQL] hierachy problem ... - Hello, I have a table which have these fields: - id - idParent - label I would like to display each field and his children but each parent may have no child. Example: A AA AB AC B C CA CB .... I can't write the request, could you help me?....
   Database Help (Home) -> PHP SQL All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]