/    Sign up×
Community /Pin to ProfileBookmark

Sequencing a Query

I would like to do 20 querys without have to write the code for each one. I have not been able to achieve this. Here is the code.

[code=php]$sql1=”SELECT cost1 FROM dawn_quotes WHERE year=’$year’ AND notax1=” “;
$results1 = mysql_query($sql1);
while ($rows=mysql_fetch_array($results1)) {
$sum1 += $rows[‘cost1’];
}
[/code]

I would like to repeat this code for numbers 1 through 20.

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@ginerjmNov 06.2013 — A "while" loop? A "foreach" loop?
Copy linkTweet thisAlerts:
@beylahauthorNov 07.2013 — I tried a for and foreach and could not get it to work. I could not get the while to express .$value
Copy linkTweet thisAlerts:
@ginerjmNov 07.2013 — Usually when one has trouble with some code, one shows us the code. Let's see your attempt at a foreach or whatever. Don't be shy.
×

Success!

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