Questions...a few
Posted: Thu May 22, 2008 1:26 pm
ok i've got a set of questions that revolve around a network of users. Normally i would post them separate but just figured if anyone could help on anything that would be great... thanks
{ps: failure can get annoying}
let me explain a little.
I'm putting together a site that alows you to create a network of users. you can search for and view USER X's page and if you want invite him to your network you can via a php button in the right hand corner. this button adds USER X's username and a , to a coulmn in my user table called "network_invite". now that php button needs to change based on the "network_invite" & "network" columns in my user table. so if you art viewing USER X's page and he is already a "network member" (ie your name is in the "network" colum) your right hand corner button will then change to a "Remove from Network" button with a different action (php below).
and i know i should have built my database differently but i've got so many pages already built around it, i just want to get some of these pages working.
ok so my questions are:
1: When I run the current button php I always get an "Invite to network" button?
2: When i try to run the "Invite to network" script it replaces the value in my "network_invite" column insted of adding it to the end?
3: I have no clue on how to delete an username from a string in the "network" column?
4: I need help moving a "username," from a string in the "network_invite" column to a string in the "network" column?
Button Code:
Accept To Network Code:
Remove from network code:
Invite to network code:
{ps: failure can get annoying}
let me explain a little.
I'm putting together a site that alows you to create a network of users. you can search for and view USER X's page and if you want invite him to your network you can via a php button in the right hand corner. this button adds USER X's username and a , to a coulmn in my user table called "network_invite". now that php button needs to change based on the "network_invite" & "network" columns in my user table. so if you art viewing USER X's page and he is already a "network member" (ie your name is in the "network" colum) your right hand corner button will then change to a "Remove from Network" button with a different action (php below).
and i know i should have built my database differently but i've got so many pages already built around it, i just want to get some of these pages working.
ok so my questions are:
1: When I run the current button php I always get an "Invite to network" button?
2: When i try to run the "Invite to network" script it replaces the value in my "network_invite" column insted of adding it to the end?
3: I have no clue on how to delete an username from a string in the "network" column?
4: I need help moving a "username," from a string in the "network_invite" column to a string in the "network" column?
Button Code:
Code: Select all
<?php
include "config.php";
$username=$_SESSION['username'];
$user_profile=$_GET['username'];
$sql4 = "SELECT *
from user
WHERE uname = '$user_profile'
";
$sql5 = "SELECT *
from user
WHERE uname = '$username'
";
$result4 = mysql_query($sql4) or die (mysql_error());
$row4 = mysql_fetch_assoc($result4);
$network_id4 = $row4['network'];
$network_id_parts4 = explode(",", $network_id4);
$network_invite_id4 = $row4['network_invite'];
$network_invite_id_parts4 = explode(",", $network_invite_id4);
$result5 = mysql_query($sql5) or die (mysql_error());
$row5 = mysql_fetch_assoc($result5);
$network_id5 = $row5['network'];
$network_id_parts5 = explode(",", $network_id5);
$network_invite_id5 = $row5['network_invite'];
$network_invite_id_parts5 = explode(",", $network_invite_id5);
//$user_profile=$_GET['username'];
if($network_invite_id_parts5 == $user_profile)
{
echo "<form id=\"form1\" name=\"form1\" method=\"post\" action=\"accept_network.php\">";
echo "<input name=\"network\" type=\"hidden\" id=\"network\" value ='$user_profile'/>";
echo "<input name=\"invitee\" type=\"hidden\" id=\"invitee\" value ='$username'/>";
echo "<label>"."<input type=\"submit\" name=\"button\" id=\"button\" value=\"Accept in network\" />"."</label>";
echo "</form>";
}
else {
if($network_id_parts4 == $user_profile)
{
echo "<form id=\"form2\" name=\"form2\" method=\"post\" action=\"remove_network.php\">";
echo "<input name=\"network\" type=\"hidden\" id=\"network\" value ='$username'/>";
echo "<input name=\"invitee\" type=\"hidden\" id=\"invitee\" value ='$user_profile'/>";
echo "<label>"."<input type=\"submit\" name=\"button\" id=\"button\" value=\"Remove from network\" />"."</label>";
echo "</form>";
}
else
{
if($network_invite_id_parts4 == '$user_profile')
{
echo "network invite pending";
}
else
{
echo "<form id=\"form3\" name=\"form3\" method=\"post\" action=\"add_invite.php\">";
echo "<input name=\"network_invite\" type=\"hidden\" id=\"network_invite\" value = '$username'/>";
echo "<input name=\"invitee\" type=\"hidden\" id=\"invitee\" value = '$user_profile'/>";
echo "<label>"."<input type=\"submit\" name=\"button\" id=\"button\" value=\"invite to network\" />"."</label>";
echo "</form>";
}}}
// swhile ($row = mysql_fetch_assoc($result)) {
// }
?>Accept To Network Code:
Code: Select all
<?php
include "config.php";
$tbl_name="user";
$user_profile=$_POST['invitee'];
$network=$_POST['network'];
$sql=("Select * from user where uname=''{$_SESSION['username']}''");
$result= mysql_query($sql);
$row=mysql_fetch_assoc($result);
$exsisting = $row['network'];
$new_network = $exsisting.$network.",";
$sql1="UPDATE user SET network = '$new_network' WHERE uname = '$user_profile'";
$result1 = mysql_query($sql1) or die (mysql_error());
if($result1)
{
echo "Your have accepted ".$user_profile." to your network"."<BR/>";
}
else
{
echo "Error";
}
?>Code: Select all
<?php
include "config.php";
$tbl_name="user";
$user_profile=$_POST['invitee'];
$network=$_POST['network'];
$sql=("Select * from user where uname=''{$_SESSION['username']}''");
$result= mysql_query($sql);
$row=mysql_fetch_assoc($result);
$exsisting = $row['network'];
$new_network = $exsisting.$network.",";
$sql1="UPDATE user SET network = '$new_network' WHERE uname = '$user_profile'";
$result1 = mysql_query($sql1) or die (mysql_error());
if($result1)
{
echo "Your Invite to".$user_profile."has been sent"."<BR/>";
}
else
{
echo "Error";
}
?>Code: Select all
<?php
include "config.php";
$tbl_name="user";
$user_profile=$_POST['invitee'];
$network_invite=$_POST['network_invite'];
$sql=("Select * from user where uname=''{$_SESSION['username']}''");
$result= mysql_query($sql);
$row=mysql_fetch_assoc($result);
$exsisting = $row['network_invite'];
$new_network_invite = $exsisting.$network_invite.",";
$sql1="UPDATE user SET network_invite = '$new_network_invite' WHERE uname = '$user_profile'";
$result1 = mysql_query($sql1) or die (mysql_error());
if($result1)
{
echo "Your Invite to".$user_profile."has been sent"."<BR/>";
}
else
{
echo "Error";
}
?>