/    Sign up×
Community /Pin to ProfileBookmark

Insert mysql record by loop

Hello, Sir

i want to loop mysql records until amount has not null
here i am want to adjust my amount ONE by ONE by participial FIELD ID and Amount
i have already tried, while loop is not working

just tell me what should i do where i have right “Now Go To up ($one)”
and “come here ($one)”
send the right query with my php script would be appreciated

thank you

[CODE]<?
$amount = $_REQUEST[‘amount’];

// come here ($one);
qry=mysql_query(“select * from invoice where cl_id='”.$_REQUEST[‘search_text’].”‘ order by balance ASC “);
$data=mysql_fetch_array($qry);
$inv=$data[‘balance’]; $id=$data[‘id’];

if($amount == “0”) { echo “Thank You. Your amount has been Adjusted Succfully”; exit; }
//—————————————————————————————-
if($amount > $inv) {
$c=$amount-$inv;
$sql=mysql_query(“insert into recive (cl_id,amount,id)
values(‘”.$_REQUEST[‘search_text’].”‘,’$c’,’$id’)”);
$amount= $c;
// Now Go To up ($one) loop record untill amount ==”0″ also $amount value will change $amount= $c; then go ($one)
exit; }
//—————————————————————————————-
if($amount == $inv) {
$c=$amount-$inv;
$sql=mysql_query(“insert into recive (cl_id,amount,id)
values(‘”.$_REQUEST[‘search_text’].”‘,’$c’,’$id’)”);
$amount= $c;
// Now Go To up ($one) loop record untill amount ==”0″ also $amount value will change $amount= $c; then go ($one)
exit; }
//—————————————————————————————-
if($inv > $amount) {
$c=$inv-$amount;
$sql=mysql_query(“insert into recive (cl_id,amount,id)
values(‘”.$_REQUEST[‘search_text’].”‘,’$c’,’$id’)”);
echo “Thank You. Your amount has been Adjusted Succfully”;
// dont loop this record
exit; }
?>[/CODE]

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@zahidrafAug 10.2009 — You are missing while loop in the code add it and then try .
×

Success!

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