/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Getting MySQL results from the function

Hi guys

I’ve got a function that reads in the data from db. although sometimes it might return more then 1 result.

Does anyone know a way to get these results from inside the page without it crushing ?

[code=php]
function get_addresses($customer_id, $address_id, $address_type){

$address_search=mysql_query(‘
select address.*,address_type.atype
from
address join address_type on address.atype_id=address_type.atype_id
where
address.customer_id=”‘.$customer_id.'”
and
address.address_id like “%’.$address_id.’%”
and
address_type.atype like “%’.$address_type.’%”;’);

$addresses=mysql_fetch_array($address_search);

return $addresses;
}
[/code]

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@scragarOct 11.2008 — [code=php] function get_addresses($customer_id, $address_id, $address_type){


$address_search=mysql_query('
select address.*,address_type.atype
from
address join address_type on address.atype_id=address_type.atype_id
where
address.customer_id="'.$customer_id.'"
and
address.address_id like "%'.$address_id.'%"
and
address_type.atype like "%'.$address_type.'%";');

/// make it return an array
$addresses=Array();
while(FALSE !== ($tmp = mysql_fetch_array($address_search))){
$addresses[] = $tmp;
}
return $addresses;
}[/code]

and use like so:
[code=php]
$addresses = get_addresses($customer_id, $address_id, $address_type);
foreach($addresses as $row=>$val){
echo 'address '.$row.'<br> ';
var_dump($val);
}[/code]
Copy linkTweet thisAlerts:
@NightcatauthorOct 12.2008 — Thanks alot that realy helped ?
×

Success!

Help @Nightcat spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...