Jump to content

Simplle help needed, please.


BRYANBRYAN

Recommended Posts

ok i created this to add a user to follow list 

if(Params::getParam('follow')!='') {
    if(osc_logged_user_id()!='') {
        $fav = $conn->osc_dbFetchResult("SELECT * FROM %st_follow WHERE fk_i_seller_id = %d AND fk_i_user_id = %d", DB_TABLE_PREFIX, Params::getParam('follow'), osc_logged_user_id());
        if(!isset($fav['fk_i_user_id'])) {
            $conn->osc_dbExec("INSERT INTO %st_follow (`fk_i_user_id`, `fk_i_seller_id`) VALUES (%d, %d)", DB_TABLE_PREFIX, osc_logged_user_id(), Params::getParam('follow'));
        }
    }
}

 now i need something to remove user from same list, im new to php and mysql so i tried something like this but it doesnt work

if(Params::getParam('unfollow')!='') {
    if(osc_logged_user_id()!='') {
		if(!isset($fav['fk_i_user_id'])) {
            $conn->osc_dbExec("DELETE FROM %st_follow fk_i_user_id = %d AND fk_i_seller_id = %d LIMIT 1", DB_TABLE_PREFIX, osc_logged_user_id(), Params::getParam('unfollow'));
        }
    }
}

can someone please help me make it work, thank you so much.

Link to comment
Share on other sites

im sorry to bother u but it worked only once, i even removed LIMIT 1 and it wont work any more, hmm?

if(Params::getParam('unfollow')!='') {
	if(osc_logged_user_id()!='') {
		 $fav = $conn->osc_dbFetchResult("SELECT * FROM %st_follow WHERE fk_i_seller_id = %d AND fk_i_user_id = %d", DB_TABLE_PREFIX, Params::getParam('unfollow'), osc_logged_user_id());
        if(!isset($fav['fk_i_user_id'])) {
            $conn->osc_dbExec("DELETE FROM %st_follow WHERE fk_i_seller_id = %d AND fk_i_user_id = %d", DB_TABLE_PREFIX, osc_logged_user_id(), Params::getParam('unfollow'));
        }
    }
}
Edited by BRYANBRYAN
Link to comment
Share on other sites

like i said im very new to this especially mySQL am i getting close to right ?

if(Params::getParam('unfollow')!='') {
		$conn->osc_dbExec("DELETE FROM %st_follow WHERE fk_i_item_id = %d AND fk_i_user_id = %d LIMIT 1", DB_TABLE_PREFIX, osc_logged_user_id(), Params::getParam('unfollow'));
	}
Edited by BRYANBRYAN
Link to comment
Share on other sites

All I can see is that you are passing 4 arguments to to a class method called osc_dbExec. You are not reporting any errors so I assume it expects and takes those four without any problems.

 

But, not being clairvoyant, I don't know what that method then does with them. As I said, your class.

Link to comment
Share on other sites

ok once again when i code

if(Params::getParam('follow')!='') {
    if(osc_logged_user_id()!='') {
        $fav = $conn->osc_dbFetchResult("SELECT * FROM %st_follow WHERE fk_i_seller_id = %d AND fk_i_user_id = %d", DB_TABLE_PREFIX, Params::getParam('follow'), osc_logged_user_id());
        if(!isset($fav['fk_i_user_id'])) {
            $conn->osc_dbExec("INSERT INTO %st_follow (`fk_i_user_id`, `fk_i_seller_id`) VALUES (%d, %d)", DB_TABLE_PREFIX, osc_logged_user_id(), Params::getParam('follow'));
        }
    }
}

when it receives follow it inserts date into database, now i wanted to do delete that same data when it receives unfollow, if u were me what would u wright to remove date u just imputed with this code. im sorry if i sound stupid but im a newbie

Edited by BRYANBRYAN
Link to comment
Share on other sites

since Barand wasnt able to figure this one out, any other gurus that know what they are doing that can simply post the right code to unfollow or delete data from database following my pattern of adding it, thanks in advance.

Edited by BRYANBRYAN
Link to comment
Share on other sites

simply post the right code to unfollow or delete data from database following my pattern of adding it

We don't respond well to this type of demanding entitled language.

 

We also can't help you if you don't post the relevant code. Barand asked you to.

Link to comment
Share on other sites

i wasnt demanding just asking for him to stop pulling me around and acting like a wizard of oz to a total noob, i have no idea what he is asking, this is all the code i have to add entry to a table and it works someone that knows php can figure out the reverse code for it to delete entry from db and code it for me since i already said im stupid for php. im sorry if i sounded demanding but not to get any code written by you gurus in 3 days wasnt expected :( he is doing it like this, you ask him can u show me how to make pizza, he goes are u using flour in your dough, u say here im using water flour and salt, he goes is your pepperoni beef or chicken, just lay it on pizza, u r like but how do i make pizza, he is like lay it on pizza, and u simply want him to show u how to lay down dough, sauce on it, pepperoni on top and cheese, once u see a completed pizza u know how to make a new one, why is he going around it like rain around Fresno.

Edited by BRYANBRYAN
Link to comment
Share on other sites

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.