Jump to content

search help


esiason14

Recommended Posts

I have a simple search, where users can query on a players last name, but I want to add something to the search results.

 

Right now it displays, the player with a link to his profile, but I want to add the team name after...Like this:

 

Player Name, Team Name

 

 

Heres the meat of my results page:

 

[!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--]if ($lname == \"\")

{$lname = \'%\';}

 

 

 

$result = mysql_query (\"SELECT fname, lname, player_id

            FROM players

                        WHERE lname LIKE \'%$lname%\'

             \",$conn);

 

echo \"<table align=\\"center\\" width=\\"55%\\" border=\\"1\\" cellpadding=\\"2\\"

 

cellspacing=\\"0\\">\";

  echo \"<TR align=\\"center\\"><td><b>Players found:     </b> </td></tr>\";

 

if ($row = mysql_fetch_array($result)) {

        $fname = $row[\'fname\'];

    $player_id = $row[\'player_id\'];

    $nflteamname = $row[\'nflteam_name\'];

do {

print \"<TR><TD> <a href=\'/football/players.php?player_id=\" . $player_id . \"\'> \".$fname.\"

\".$lname.\"</a>\".$nflteamname.\"</TD></TR>\";

 

} while($row = mysql_fetch_array($result));

} else {print \"Sorry, no records were found!\";}

print \"</table>\";

?>[/span][!--PHP-Foot--][/div][!--PHP-EFoot--]

 

 

 

This is the query for the NFL team name, but I'm just having trouble working it in...

 

 

SELECT players.nflteams_id, nflteam_name, player_id

FROM players, nflteams

WHERE nflteams.nflteam_id = players.nflteam_id

 

 

If you want to try it out....search for the name "Kennison" here

http://www.fantasyfootballresearch....ball/search.php

 

Another problem I'm having is if you query for a common name such as smith. It returns only the first occurence of Smith, but multiple times.

Link to comment
Share on other sites

Make your initial query :

 

[!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--][span style=\'color:blue;font-weight:bold\']SELECT[/span] p.fname, p.lname, p.player_id, t.nflteam_name

FROM players p INNER JOIN nflteams t

ON p.nflteam_id = t.nflteam_id

WHERE lname LIKE '%$lname%' [!--sql2--][/div][!--sql3--]

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.