/    Sign up×
Community /Pin to ProfileBookmark

i’m using the following to count items in a table:

select count(*) from tblcart where cartGuid = 349360d1439a701eb4ca8eb935d21556

how can i echo the result out in dreamweaver?

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@sean1983ukauthorFeb 11.2007 — i've tried:

[CODE]
$cart_items ="select count(*) from tblcart where cartGuid = '$varCartGuid_rsCart'";
$rsCartItems = mysql_query($cart_items, $conn) or die(mysql_error());
echo $rsCartItems;
[/CODE]


but it displays Resource id#6
Copy linkTweet thisAlerts:
@JoeHoldcroftFeb 11.2007 — Get rid of count(), so it's just SELECT * FROM, then put the whole query inside: [code=php]mysql_num_rows(mysql_query("SELECT * FROM tblcart WHERE...."));[/code]
Copy linkTweet thisAlerts:
@sean1983ukauthorFeb 11.2007 — cheers!
Copy linkTweet thisAlerts:
@NightShift58Feb 11.2007 — Get rid of count(), so it's just SELECT * FROM, then put the whole query inside: [code=php]mysql_num_rows(mysql_query("SELECT * FROM tblcart WHERE...."));[/code][/QUOTE] Don't get rid of count()! It's there for a purpose!!! And, if all you need is a count, there's not need to select and retrieve the entire content of a table... be kind to MySQL/PHP...

Leave everything as is and change:[code=php]echo $rsCartItems;[/code]to:[code=php]$r = mysql_fetch_row($rsCartItems);
echo $r[0];[/code]
×

Success!

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