creating a mysql query in a php function
Posted: Wed Jun 14, 2006 10:36 am
feyd | Please use
Thanks inadvance!
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I have a query that I have to run over and over in my program. I would like to just set it up as a php function and call it when I need it, but I cannot get it to return the results. My code is posted below.Code: Select all
function getaddress($testsiteid) {
//test for address
$query90 = "select * from expandedaddressjoin where siteid = '$testsiteid'";
$result90 = mysql_query($query90) or die(mysql_error());
if($row90 = mysql_fetch_array($result90)){
$testaddressid = $row90[0];
$testaddressnote1 = $row90[2];
$query91 = "select * from address where addressid = '$testaddressid'";
$result91 = mysql_query($query91) or die(mysql_error());
if($row91 = mysql_fetch_array($result91)){
$teststreetid = $row91[1];
$teststreetnumber = $row91[2];
$testaddressnote2 = $row91[3];
$query92 = "select * from street where streetid = '$teststreetid'";
$result92 = mysql_query($query92) or die(mysql_error());
if($row92 = mysql_fetch_array($result92)){
$teststreetdirection = $row92[1];
return $teststreetdirection
return $teststreetname = $row92[2];
$teststreettype = $row92[3];
return $teststreettype;
$addresscomplete = 'Yes';
}
}
}
getaddress(1);
print "<p>$teststreetnumber $teststreetname $teststreettype</p>feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]