Webmaster Forum

Go Back   Webmaster Forum > Web Development > Coding Forum

Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more.


Reply
 
LinkBack Thread Tools Display Modes
Old 12-13-2006, 01:43 PM   #1 (permalink)
Member
 
Join Date: 07-20-06
Posts: 34
iTrader: 0 / 0%
Latest Blog:
None

drewtown is liked by many
[PHP + MySQL] Confirming friends

I am not creating a social networking site but I would like my site to have a friends list. So far I have created the ability to add the user as a friend if they are not already friends and then the confirmed portion of the database is set to zero.

Now I want the user who was invited to be friends to be able to go to the control panel and confirm that they are friends with this person. I am stuck here on the best way to go about this

$result_unconfirmed = mysql_query("SELECT * FROM friends WHERE username2 = '$username' and confirmed = '0'");
$num_rows_unconfirmed = mysql_num_rows($result_unconfirmed);


while( $row = mysql_fetch_array($result_unconfirmed) ) {

echo($row['username2'] . "<br />");


}
Is what I have so far and it successfully pulls the user that is requesting to be there friend. But I'm not sure on how to go through and have the user individually select which user they would like to accept or deny. I would preferably like to do this with buttons in a form. If you have an guides or tips it would be greatly appreciated.
__________________
Nintendo-Friends.com
Social Networking and Friend Code management for DS users
drewtown is offline  
Add Post to del.icio.us
Reply With Quote
Old 12-13-2006, 03:48 PM   #2 (permalink)
Member
 
Join Date: 07-20-06
Posts: 34
iTrader: 0 / 0%
Latest Blog:
None

drewtown is liked by many
ok so looking at it more and using this code

while( $row = mysql_fetch_array($result_unconfirmed) ) {

echo($row['username'] . " " . $row['username2'] . "<br />");

}
?>
<form method="get" action="<?php $_SERVER['PHP_SELF']?>">
<input type="submit" name="<?php echo($formUser);?>" value="confirm" />
<input type="submit" name="<?php echo($formUser);?>" value="noconfirm" />
</form>


<?php
}

The problem is finding out which user they selected. So is there anyway through GET or POST that I can find out the name (which would be the user they selected). I need to do this so the script can use the user they selected. I know you have to do $_GET['NameOftheInputType'] to get the value, but how can I use the name of the input type with my script if I don't know which one was sent?
__________________
Nintendo-Friends.com
Social Networking and Friend Code management for DS users

Last edited by drewtown; 12-13-2006 at 04:01 PM.. Reason: clarity
drewtown is offline  
Add Post to del.icio.us
Reply With Quote
Old 12-13-2006, 04:16 PM   #3 (permalink)
v7n Mentor
 
Taltos's Avatar
 
Join Date: 11-22-06
Location: Phoenix, AZ
Posts: 1,784
iTrader: 0 / 0%
Latest Blog:
None

Taltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web pro
Hey drewtown,

I'm not sure I follow exactly what you have so far with the pieces. My first instinct is to use a column of checkboxes next to friend names rather than submit buttons. Use the submit button on the bottom labeled as "Save Changes" or whatever.

That way you can loop through the friend requests for a given user to build the list. You can then loop through the same list looking for checkbox values. Use a unique identifier from your database for a friend request as the "name=" on the checkbox. Then you are looping through the same list looking for $_POST["frienduniqueidentifier"].

Don't have time right this second to cobble code together but hopefully you get the idea? Or it gives you some other ideas?
__________________
Experimenting
Taltos is offline  
Add Post to del.icio.us
Reply With Quote
Old 12-14-2006, 12:01 AM   #4 (permalink)
Member
 
Join Date: 07-20-06
Posts: 34
iTrader: 0 / 0%
Latest Blog:
None

drewtown is liked by many
While i didn't use exactly your idea it did give me an idea. I used image buttons instead of text buttons and this allows me to set a name that I know of such as deny and confirm and then the values can be anything without polluting the look of the buttons. If anybody is interested here is the code
PHP Code:
<?php
$result_unconfirmed 
mysql_query("SELECT * FROM friends WHERE username2 = '$username' and confirmed = '0'");
$num_rows_unconfirmed mysql_num_rows($result_unconfirmed);

$i 0;
while( 
$row mysql_fetch_array($result_unconfirmed) ) {

    echo(
$row['username'] . " " $row['username2'] . "<br />");
    
$formUser $row['username'];
    if(
$_POST['confirm'] != "" && $i<1)
    {
        echo(
"hey something was confirmed");
        echo(
$_POST['confirm']);
        
        
$result_confirming mysql_query("UPDATE friends SET confirmed='1' WHERE confirmed='0' and username2 = '$username' and username = '$formUser'"
or die(
mysql_error());
        
        
$i++;
        
    }
    if(
$_POST['deny'] != "" && $i<1)
    {
        echo(
"hey something was denied");
        echo(
$_POST['deny']);
        
        
$result_confirming mysql_query("UPDATE friends SET confirmed='-1' WHERE confirmed='0' and username2 = '$username' and username = '$formUser'"
or die(
mysql_error());
        
        
$i++;
    }
    
?>
    <form method="POST" action="<?php $_SERVER['PHP_SELF']?>">
    <input type="image" src="/images/confirm.jpg" name="confirm" value="<?php echo($formUser);?>" />
    <input type="image" src="/images/deny.jpg" name="deny" value="<?php echo($formUser);?>" />
    </form>
    
    
    <?php
    
}

?>
__________________
Nintendo-Friends.com
Social Networking and Friend Code management for DS users
drewtown is offline  
Add Post to del.icio.us
Reply With Quote
Old 03-12-2007, 02:57 PM   #5 (permalink)
Junior Member
 
Join Date: 03-12-07
Posts: 2
iTrader: 0 / 0%
Latest Blog:
None

inspectorgadget is liked by many
hey drewtown...sorry for the excessive asking...can u send me ur design of the frenster alike coding to me?cos i currently learning on design a web page base on frenster alike function..add fren, fren confirmation upload photo, leave coment, then link it to blog....i need an example for the codding..would u like to help me here??i'm new...if u not feeling well of giving me a hand then its ok la..thanks anyway....
inspectorgadget is offline  
Add Post to del.icio.us
Reply With Quote
Old 03-12-2007, 02:58 PM   #6 (permalink)
Junior Member
 
Join Date: 03-12-07
Posts: 2
iTrader: 0 / 0%
Latest Blog:
None

inspectorgadget is liked by many
or anyone would like to give me an example or tell me how to get the example coding from???thanks...
inspectorgadget is offline  
Add Post to del.icio.us
Reply With Quote
Go Back   Webmaster Forum > Web Development > Coding Forum

Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



Sponsor Links
Get exposure! Contextual Links V7N SEO Blog V7N Directory


All times are GMT -7. The time now is 04:18 AM.
© Copyright 2008 V7 Inc
Powered by vBulletin
Copyright © 2000-2009 Jelsoft Enterprises Limited.


Search Engine Optimization by vBSEO 3.3.0 ©2009, Crawlability, Inc.