Jump to content

Archived

This topic is now archived and is closed to further replies.

redarrow

mysql_num_rows help very quick question cheers.

Recommended Posts

i need to know if my mysql_num_rows is correct please cheers.

[code]
<?php

$query2="select * from payment_info where id='$id'";

$result2=mysql_query($query2);

if(mysql_num_rows($result2)==1){

so some think update  members info

}
?>

[/code]

Share this post


Link to post
Share on other sites
Looks ok to me, what's the problem you are having?

Share this post


Link to post
Share on other sites
what i want to do if there more then one entry of the same information in a database field is delete that entery.

i come up with this but should it work cheers mate.

but the problam is that only one of the entrys need to be deleted

or can i set the userid to unique
[code]
<?php

$query="select * from payment_info where id='$id'";

$result=mysql_query($query);

if(mysql_num_rows($query)>1){

$delete="delete from payment_info where id='$id' ";

$delete_query=mysql_query($delete);

}

?>
[/code]

Share this post


Link to post
Share on other sites
I take it that your code is deleting all of the rows with the supplied id, and not just the duplicates, right? I think it might help if you use a LIMIT in your DELETE query...
[code]<?php
$result = mysql_query("SELECT * FROM `payment_info` WHERE `id`='$id'") or die(mysql_error());
$count = mysql_num_rows($result);
if($count > 1) {
    $limit = $count - 1;
    mysql_query("DELETE FROM `payment_info` WHERE `id`='$id' LIMIT $limit") or die(mysql_error());
}
?>[/code]

ID fields are commonly regarded as unique fields, if you are finding you have ID fields with the same numbers in you have a problem somewhere. Deleting those fields is not the solution, preventing them from appearing in the first place would be more ideal.

Share this post


Link to post
Share on other sites
i think that code will work cheers.

I tell you the whole story so you see what's happening, a user goes to pay for a service if the user just close there browser the information for that user will be in a temp field but when the user does pay the temp field updates the correct field but both entrys enter .

so what do you do?

the only way around that situation is delete one entry get me.

Share this post


Link to post
Share on other sites
delete from payment where id = $id will delete them all though.. if you put in the end of the delete clause limit = 1 it will only delete one.

Share this post


Link to post
Share on other sites
what about if the user close the broweser 6 times before payment then i have 6 user enterys then what ?

please help lol.

Share this post


Link to post
Share on other sites
i am sure that the code SemiApocalyptic has provided will do what i wont where it counts the number of entrys then deletes all except 1.

is that correct works so far please advise me cheers.

Share this post


Link to post
Share on other sites
I think I understand, but why are several records getting the same ID? If the user closes his browser 6 times and then pays on the 7th, I'd assume you'd only want the seventh basket marked as paid with the other 6 being left marked as 'abandoned basket'.

Why are you storing the baskets in a temporary table anyway? For saving abandoned baskets, or so that if a user does close their browser their basket is saved for their next visit? Even still, I don't understand how you're getting duplicate rows in the table...

Share this post


Link to post
Share on other sites
SemiApocalyptic what it is that a user can only pay for the service once they activate there account then they login then pay so that why an id is there ok.


it's nearly finished now the system i am working on is a paypal system with ipn but to be sure to be sure ok.

this how my website does work and works fine and is good and gooing good.

1. a user makes a account and also provides relevent information they want to show the world.

2. afther the account is made the users has to activate the account via a link in there email box.

3. when the user first goto the web address and logs in they get redireted to a payment paln the user selects a payment plan then thay confirm with a paypal button they and pay paypal for the my service .

4. paypal sends all information back to my ipn system then  i check if the payment is the payment that they wanted incase they change the form encripted or not it's easy as you all no.

5. then the user logs in and can edit delete and modify anythink they want as there on there own members page.


thank you for your help all worked well cheers.

Share this post


Link to post
Share on other sites
maybe I'm understanding this wrong....are you appending the non paying user info inside the same table as the paying users' info?


another question
[quote]
what it is that a user can only pay for the service once they activate there account then they login then pay so that why an id is there ok.
[/quote]

..what?
so do they pay for the activation and then pay for something else when they ARE activated?
I'm lost

Share this post


Link to post
Share on other sites
zanus read this please ok cheers.

1. a user makes a account and also provides relevent information they want to show the world.

2. afther the account is made the users has to activate the account via a link in there email box.

3. when the user first goto the web address and logs in they get redireted to a payment paln the user selects a payment plan then thay confirm with a paypal button and pay via paypal for the my service .

4. paypal sends all information back to my ipn system then  i check if the payment is the payment that they wanted incase they change the form encripted or not it's easy as you all no.

5. then the user logs in and can edit delete and modify anythink they want as there on there own members page.

6.when the users time is up the account gets deleted that it!

thank you for your help all worked well cheers.

Share this post


Link to post
Share on other sites
Well if the user closes the browser 6 times perhaps your best bet would be to store all the info into some strings.. delete all instances of it and then re-insert one... 

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.