Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Dec 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Row Count with Dynamic URLs

    The code below use to reference username. I changed it to go by first/last name. Except the system goes by username when opening dynamic URLs. I have the rows printing out first and last name and when you select the name it needs to open website by "user".

    The url name appears to have first and last name (this is what I want), but when you select name I want it to go by username.

    CODE:

    PHP Code:
    <? if (isset($_GET['add']))
    {
        
    $add sanitizeString($_GET['add']);
        
    $query "SELECT * FROM friends WHERE user='$add'
                  AND friend='$user'"
    ;
        if (!
    mysql_num_rows(queryMysql($query)))
        {
            
    $query "INSERT INTO friends VALUES ('$add', '$user')";
            
    queryMysql($query);
        }
    }
    elseif (isset(
    $_GET['remove']))
    {
        
    $remove sanitizeString($_GET['remove']);
        
    $query "DELETE FROM friends WHERE user='$remove'
                  AND friend='$user'"
    ;
        
    queryMysql($query);
    }
    $result queryMysql("SELECT Concat(firstname,' ', lastname), user FROM profiledetails ORDER BY lastname");
    $result2 queryMysql("SELECT user FROM members ORDER BY user");
    $num2=mysql_num_rows($result2);
    $num mysql_num_rows($result);
    echo 
    "<h5>Follow your friends progress and find people with similar interests by clicking below</h5><ul>";
    for (
    $j $j $num ; ++$j)
    {
        
    $row mysql_fetch_row($result);
        
    $row2=mysql_fetch_row($result2);
        if (
    $row[0] == $user) continue;
        echo 
    "<li><a href='members.php?view=$row[0]'>$row[0]</a>";
        
    $query "SELECT * FROM friends WHERE user='$row[0]'
                  AND friend='$user'"
    ;
        
    $t1 mysql_num_rows(queryMysql($query));
        
    $query "SELECT * FROM friends WHERE user='$user'
                  AND friend='$row[0]'"
    ;
        
    $t2 mysql_num_rows(queryMysql($query));
        
    $follow "follow";
        if ((
    $t1 $t2) > 1)
        {
            echo 
    " &harr; is a mutual friend";
        }
        elseif (
    $t1)
        {
            echo 
    " &larr; following";
        }
        elseif (
    $t2)
        {
            
    $follow "recip";
            echo 
    " &rarr; is following you";
        }
        if (!
    $t1)
        {
            echo 
    " [<a href='members.php?add=".$row[0] . "'>$follow</a>]";
        }
        else
        {
            echo 
    " [<a href='members.php?remove=".$row[0] . "'>drop</a>]";
        }
    }
    ?>

    I need the print rows of
    PHP Code:
    <li>a href=members.php?view=$row[0]>$row[0]</a>"; 
    The URL needs to open referencing user, but the row needs to print first/last name.

    Any help would be appreciated.

  • #2
    Senior Coder
    Join Date
    Apr 2011
    Location
    London, England
    Posts
    2,120
    Thanks
    15
    Thanked 354 Times in 353 Posts
    I don't quite follow your description but..

    PHP Code:
    $result queryMysql("SELECT Concat(firstname,' ', lastname), user FROM profiledetails ORDER BY lastname"); 
    concatenates (joins) firstname and lastname separated by a space, which becomes the first field returned, which you refer to later as $row[0].
    PHP Code:
    $result queryMysql("SELECT firstname, lastname, user FROM profiledetails ORDER BY lastname"); 
    will keep firstname and lastname separate, referred to as $row[0] and $row[1] in your later code. Then, to perform your comparison, you would use:
    PHP Code:
    if ($row[0] . ' ' $row[1] == $user) continue; 
    which temporarily rejoins first and lastname.

    I may not have answered your precise requirement, but I'm sure the answer is in the above description
    "I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
    Validate your HTML and CSS

  • #3
    New to the CF scene
    Join Date
    Dec 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Basically, I have first/last name printing for the rows. The user will see first/last name but when they select first and last name I need it to open URL with username instead of first/last name.

    Example:
    PHP Code:
    echo "<li><a href='members.php?view=$row[user]'>$row[firstlastname]</a>"
    firstname lastname when selected opens URL by username.

    The HREF is where I am stuck because I need it to call username. but when row prints it must be first/last name...
    Last edited by COcode; 12-09-2012 at 07:50 PM.

  • #4
    Senior Coder
    Join Date
    Apr 2011
    Location
    London, England
    Posts
    2,120
    Thanks
    15
    Thanked 354 Times in 353 Posts
    Does $user contain the username?

    PHP Code:
    echo "<li><a href='members.php?view=$user'>" $row[0] . ' ' $row[1] . "</a>";
    // or

    echo "<li><a href='members.php?view=$user'>{$row[0]} {$row[1]}</a>"
    "I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
    Validate your HTML and CSS

  • #5
    New to the CF scene
    Join Date
    Dec 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    No it does not, I have to pull user form my SQL in $row[0] basically row[0] print all the rows. so far row[0] print first and last name. i need row[0] to also print user name
    Last edited by COcode; 12-10-2012 at 12:23 AM.

  • #6
    New to the CF scene
    Join Date
    Dec 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I fixed it!!! I just had to call $row[1] and it pulled user. $row[0] is my concat string with first and last name $row[1] is for user.


    hehe i dont know how i misssed that one


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •