/    Sign up×
Community /Pin to ProfileBookmark

query output?

Hello

I wonder if someone can help me with the querry bellow.

it’s outputing tags from the table “images” and it’s limited to 5 and wich tag is most used. currently [url]http://imagefrog.net/test.php[/url] and it’s showing the same tag on all 5 atm cause “wow” is most used. i wonder if there Is someway to make it not show one tag if it’s already shown? like if “wow” is most used and is shown as the first one it’s not supposed to be showing on the other 4.

i hope someone can help.

[code=php]
$get_list = mysql_query(“SELECT * FROM `images` ORDER BY `views` DESC LIMIT 5”);
while($each = mysql_fetch_assoc($get_list)){
echo “<a href=”word.php?word=”.$each[‘tags’].””>”.$each[‘tags’].”</a> “;
}[/code]

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@skywalker2208May 16.2008 — You could try using DISTINCT or GROUP BY
Copy linkTweet thisAlerts:
@izlikauthorMay 16.2008 — You could try using DISTINCT or GROUP BY[/QUOTE]


can you help me to this? i dont know how to :/
Copy linkTweet thisAlerts:
@SheldonMay 16.2008 — try this.

GROUP BY will group similar results

[code=php]<?php
$output = "";
$sql = "SELECT tags FROM images GROUP BY tags ORDER BY views DESC LIMIT 5";
$qry = @mysql_query($sql);
$num = @mysql_num_rows($qry);
if($num >= 1){
while($row = mysql_fetch_assoc($qry)){
$output .= "<a href="word.php?word={$row['tags']}">{$row['tags']}</a>n";
}
}else{
$output = "<p>No Results Found</p>n";
}

echo($output);
?>
[/code]
×

Success!

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