php and html
Postby twinytwo » Thu Feb 16, 2012 1:56 am
Hi Guys,
this question is two fold.
1) im running a search script which returns to the required results, i have incude('users.php') so that it shows the required html etc
The results are showing beneth the body of the html when i need them in it.... is there anyway to do this??
2) When the search results are returned i want the the username to act as a link to that users profile page..
im trying to use this
echo "<tr><td class=center><a href="profile.php?id=<?php echo $row['id']; ?>">";
echo $row['username'];
but im getting an error sayingunexpected T_VARIABLE expected ',' or ';'
code as follows
users.php
<?php
include('config.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="<?php echo $design; ?>/style.css" rel="stylesheet" title="Style" />
<title>List of users</title>
</head>
<body>
<div class="header">
<a href="<?php echo $url_home; ?>"><img src="<?php echo $design; ?>/images/logo.png" alt="Members Area" /></a>
</div>
<div class="content">
Search for other users<br/>
<br />
<p> You can can search for users based on a range of criteria....<p><br/>
<p> Select an option from the drop down box and enter your search term<p><br/>
<form method = "post" action = "search5.php" >
Search by :<select name ="criteria" width ="20">
<option value ="name">Name</option>
<option value ="age">Age</option>
<option value ="sex">Sex</option>
<option value ="address">Address</option>
</select>
Value<input type ="text" name = "keyword">
<input type="hidden" name="submited" value="true" />
<input type = "submit" name = "submit" value ="Search">
</form>
<table>
<tr>
<th>Username</th>
<th>Age</th>
<th>Sex</th>
<th>Address</th>
<th>City</th>
<th>Account</th>
<th>Team</th>
<th>Looking</th>
<th>Experience</th>
</tr>
</table>
</div>
</body>
</html>
search5.php
<?php
Require ('users.php')
?>
<?php
$term = $_POST['keyword'];
$term2 = $_POST['criteria'];
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("bike") or die(mysql_error());
$result = mysql_query("SELECT * FROM users WHERE ".$term2." LIKE '%$term%' ")
or die(mysql_error());
//echo "<tr> <th>Name</th></tr>";
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )) {
// Print out the contents of each row into a table
echo "<table>";
//echo "<tr><td class=left>";
//echo $row['id'];
echo "<tr><td class=center><a href="profile.php?id= $row['id'];">";
echo $row['username'];
echo "</td><td class=center>";
echo $row['age'];
echo "</td><td class=center>";
echo $row['sex'];
echo "</td><td class=center>";
echo $row['address'];
echo "</td><td class=center>";
echo $row['account'];
echo "</td><td class=center>";
echo $row['type'];
echo "</td><td class=center>";
echo $row['looking'];
echo "</td><td class=center>";
echo $row['experience'];
echo "</td><td class=center>";
echo "</table>";
}
?>