electricbeat
Account Closed
- Impact
- 0
right, this is the final piece of help i need before my front end of my website is finished, and this is really buggering me.
If you go to ryan.xenka.com/search.php - and search 'Ryan' firstly it gives mysql errors, secondly it doesnt give me an exact match with Ryan, it shows RRyan instead, which is an account aswell.
I need search.php to display exact matches, and also within the name, so searching Ryan could bring up Ryan, rrrrRyan, Ryanz, etc
If you go to ryan.xenka.com/search.php - and search 'Ryan' firstly it gives mysql errors, secondly it doesnt give me an exact match with Ryan, it shows RRyan instead, which is an account aswell.
I need search.php to display exact matches, and also within the name, so searching Ryan could bring up Ryan, rrrrRyan, Ryanz, etc
PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-2" />
<link rel="stylesheet" href="images/style.css" type="text/css" />
<title>MusicInterests</title>
</head>
<body>
<div class="content">
<div class="header_right">
<div class="top_info">
<div class="top_info_right">
<p><?php include("logged.php"); ?></p>
</div>
</div>
<div class="bar">
<ul>
<li class="slogan">Navigation:</li>
<?php include("navigation.php"); ?>
</ul>
</div>
</div>
<div class="logo">
<h1><a href="#" title="The best music on the net!">Music <span class="red">Interests</span></a></h1>
<p>What are you listening too?</p>
</div>
<div class="search_field">
<form method="post" action="search.php">
<p><span class="grey">Search for a user, example</span> <span class="search">Ryan</span> <input type="text" name="search" class="search" /> <input type="submit" value="Play!" class="button" /></p>
</form>
</div>
<div class="newsletter">
<p>Subscribe for the Newsletter!</p>
</div>
<div class="subheader">
<p><?php include("top.php"); ?></p>
</div>
<div class="left">
<div class="left_articles">
<h2>Search</h2>
<p><?php
//the config file should connect to mysql.
require("config.php");
//select database
mysql_select_db("users");
$search = $_POST["search"];
//assigns the value of the entered search term in to the variable "search"
$result = mysql_query("SELECT * FROM users where username LIKE '%$search%'");
//note "username" would be the field the search looks up, so if you searched for "Waffles" it would look up waffles username in the table users.
while($r=mysql_fetch_array($result))
//grabs all the content it found
{
//then change this to match your mysql columns..this will be the information displayed. You could just have username.
$id=$r["id"];
$username=$r["username"];
$email=$r["email"];
//and so on
// then just display the row
echo "<a href=\"user-$username\">$username</a> <br/>";
}
?>
</p>
</div>
</div>
<div class="right">
<div class="rt"></div>
<div class="right_articles">
<p><b>Most viewed</b><br />The most viewed tool allows you too find the 30 most viewed profiles on musicinterests!</p>
</div>
<div class="rt"></div>
<div class="right_articles">
<p><b>Links</b><br />
<?php include("links.php"); ?></p>
</div>
<div class="rt"></div>
<div class="right_articles">
<p><?php include("sponsor.php"); ?></p>
</div>
</div>
<div class="footer">
<p><?php include("footer.php"); ?></p>
</div>
</div>
</body>
</html>








