URGENT: Need help from a php/mysql programmer [will pay $1]

Discussion in 'Services' started by krishmk, Apr 4, 2009.

Thread Status:
Not open for further replies.
  1. #1
    Ok, here is what i am trying to do.
    I have a database of cricket players' profile

    I want to pull out the Player's Name and create a hyperlink (for each player) so that it would take the visitor to a new page (profile page for each player). The "anchor text" should be the Player's Name.

    The profile page is working fine as it should be and there is no problem with it.
    However this particular page (list of players with hyperlink) is not working.

    a) At the first instance, should I be using mysql_fetch_row for this?
    b) I have created a "for" loop which outputs the number of hyperlink based on the number of rows.
    c) However the Player Name is not getting populated. It works only with "row[0]".

    -------------------------------------------------------------------------------------------

    You can check the current result of the code here:
    http://www.hostingsindia.com/cricket/players.php?team=8

    [Check the HTML source code. The hyperlink is getting populated [playerid is autoincremented]as expected but not the anchor text.]



    <?php
    $dbconnect = mysql_connect ($hostname, $user, $pass);
    mysql_select_db ($selectdb, $dbconnect);
    
    if (!dbconnect)
    {
    die ("Error connecting database");
    }
    
    $query = "SELECT Player_Name FROM `$team`";
    $result = mysql_query($query, $dbconnect);
    $row = mysql_fetch_row($result);
    $number_rows = mysql_num_rows ($result);
    ?>
    
    
    ------------------------------------------------------------
    <?php
    
    for ($i=0; $i<=$number_rows; $i++)
    {
    echo ("<a href=\"profile.php?team=$team&playerid=$i\">$row[$i]</a><br />\n");
    }
    
    
    echo ("<hr />Total Number of Players: $number_rows");
    ?>
    Code (markup):
    Will pay $1 by paypal for the first person who helps in fixing the code to output the desired result.
     
    krishmk, Apr 4, 2009 IP
  2. kmap

    kmap Well-Known Member

    Messages:
    2,215
    Likes Received:
    29
    Best Answers:
    2
    Trophy Points:
    135
    As Seller:
    100% - 0
    As Buyer:
    100% - 1
    #2
    what are various fields in table?


    Regards

    Alex
     
    kmap, Apr 4, 2009 IP
  3. kmap

    kmap Well-Known Member

    Messages:
    2,215
    Likes Received:
    29
    Best Answers:
    2
    Trophy Points:
    135
    As Seller:
    100% - 0
    As Buyer:
    100% - 1
    #3
    remove this line

    $row = mysql_fetch_row($result);


    And add this



    $i=1;
    while($row = mysql_fetch_array( $result )) {
    echo ("<a href=\"profile.php?team=$team&playerid=$i\">$row["Player_Name"]</a><br />\n");
    $i++;
    }
     
    kmap, Apr 4, 2009 IP
  4. kmap

    kmap Well-Known Member

    Messages:
    2,215
    Likes Received:
    29
    Best Answers:
    2
    Trophy Points:
    135
    As Seller:
    100% - 0
    As Buyer:
    100% - 1
    #4
    echo ("<a href=\"profile.php?team=$team&playerid=$i\">$row["Player_Name"]</a><br />\n");
    chang this to

    echo ("<a href=\"profile.php?team=$team&playerid=$i\">$row['Player_Name']</a><br />\n");

    Regards

    Alex
     
    kmap, Apr 4, 2009 IP
  5. krishmk

    krishmk Well-Known Member

    Messages:
    1,376
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    185
    As Seller:
    100% - 2
    As Buyer:
    100% - 0
    #5
    Thanks a lot!
    It works with the new code you sent via "Yahoo Messenger". Payment sent by paypal.

    For Others:
    This work is resolved. I no longer need assistance for this.
    Contacting MOD to close this thread.
     
    krishmk, Apr 4, 2009 IP
Thread Status:
Not open for further replies.