Jump to content

Recommended Posts

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]
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.
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.
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...
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.
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
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.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.