/    Sign up×
Community /Pin to ProfileBookmark

mysql question

Hey, is there anyway to make this

[code=php]
$query0 = ‘SELECT `id`, `cp` FROM cp WHERE `cp` = ‘.$usercp.’ ORDER BY `cp` ASC LIMIT 0,1′;
$resid = mysql_query($query0, $link) or die(mysql_error());
$curr = mysql_fetch_assoc($resid);
$max = $curr[‘id’] + 10;
$min = $curr[‘id’] – 10;
$query = ‘SELECT * FROM cp WHERE `id` BETWEEN ‘.$min.’ AND ‘.$max.’ ORDER BY `id` ASC’;
[/code]

in just one query???

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@SheldonJun 14.2006 — maybe [code=php]
$query = 'SELECT * FROM cp WHERE id BETWEEN (id - 10) AND (id + 10) ORDER BY id ASC';
[/code]
Copy linkTweet thisAlerts:
@HuevoosauthorJun 15.2006 — Thanks, but I need to select the id from the db also
×

Success!

Help @Huevoos 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.2,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...