/    Sign up×
Community /Pin to ProfileBookmark

I have this code to dump a table where each row is on a new line and each element is in ” and , delimited.

[code=php]while ($row = mysql_fetch_array($query)) $output .= “”” . implode(“”,””,str_replace(“rn”,””,$row)) . “”rn”;[/code]

But each element shows up twice in the $output line. What am I missing here?

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@ShrineDesignsMar 12.2005 — the mysql_fetch_array() function by default returns an array with numeric and field name indices, try:[code=php]while($row = mysql_fetch_array($query, MYSQL_NUM))
{
$output .= """ . implode("","", str_replace("rn", "", $row)) . ""rn";
}[/code]
Copy linkTweet thisAlerts:
@Beach_BumauthorMar 12.2005 — Thanks, that works, but I am not sure why. What is going on here?

EDIT >> OK, after reading more, I get it now:

http://us2.php.net/manual/en/function.mysql-fetch-array.php
×

Success!

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