/    Sign up×
Community /Pin to ProfileBookmark

MySQl question

How can I get in an array all the values of the row ‘codee’ in Mysql table?
I ttried this:

[code]
$query = “SELECT * FROM users”;
$res = mysql_query($query);
$str1 = mysql_fetch_assoc($res);
mysql_free_result($res);
print_r($str1[codee]);[/code]

but by it I get just the first value of the table. Ideas? ?

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@scragarFeb 03.2009 — [code=php]$query = "SELECT codee FROM users";
$res = mysql_query($query);
$str1 = mysql_fetch_assoc($res);
print($str1['codee']);[/code]
Copy linkTweet thisAlerts:
@our5Feb 03.2009 — [CODE]

$query = mysql_query("SELECT codee FROM users");

while($get=mysql_fetch_array($query)){

echo $get['codee'];

}

[/CODE]
Copy linkTweet thisAlerts:
@auto_webFeb 04.2009 — print_r is used to output array elements

so you should use [B]print_r($str1);[/B] and not print_r($str1[codee]);

to print a particular field use 'echo' instead [B]echo $str1[codee];[/B]
×

Success!

Help @pastet89 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,
)...