hey I having a problem wth search it is not allowing me to search what I want it is just coming up with errors
this the code I have done so far
search.php
<?
$conn = mysql_connect("localhost","root","") or die("Could Not Connect To The Database");
mysql_select_db("aziz",$conn) or die("Could Not Select The Database");
if ($_POST['submitForm']) {
$sql = "INSERT INTO search (text) VALUES '".$_POST['text']."'";
mysql_query($sql) or die("Couldn't update information.");
}
if ($title == "")
{$title = 'Nothing!';}
if ($text == "")
{$text = 'nothing';}
$result = mysql_query ("SELECT * FROM azizpassword WHERE text LIKE '%$text%'");
if ($row = mysql_fetch_array($result)) {
PRINT "<font face=tahoma size=2>Your search for <b>$text</b> returned the following results:<br><br>";
do {
$record_text = $row[3];
$text_limit = substr($record_text, 0, 300);
PRINT "<font face=tahoma size=2><b>";
print "<a href=\"solution.php?id=$row[id]\">$row[title]</a>";
print ("</b> ");
print ("<br>");
print $text_limit;
print ("...<p>");
} while($row = mysql_fetch_array($result));
} else {
PRINT "<font face=tahoma size=2>Your search for <b>$text</b> returned 0 results:<br><br>";
}
?>
search:
<input type=password name=pass>
<br>
<br>
<input type=submit value=Search></form></body></html>
basically, its not functioning properly. What i want it to do, is return a view of what i search. This is a table that i already have working:
tableview.php
<?php
$conn = mysql_connect("localhost","root","") or die("Could Not Connect To The Database");
mysql_select_db("aziz",$conn) or die("Could Not Select The Database");
if(isset($_GET['action'])) {
if($action == "delete") {
$user_id = $_GET['user_id'];
$delete = mysql_query("delete from azizpassword where user_id = '$user_id'") or die(mysql_error());
# you can then put a header("Location: ..."); to go somewhere else
}
}
$result=mysql_query("SELECT user_id,az_firstname,az_surname,username FROM azizpassword ORDER BY user_id;");
$i=0;
while( $row=mysql_fetch_array($result) )
{
if($i>0)
{
echo "<tr valign=top>";
echo "<td bgcolor=#93B0B4 colspan=4><img src=img/blank.gif wuser_idth=1 height=1></td>";
echo "</tr>";
}
echo "<tr valign=center>";
echo "<td width=100 class=table><b>".$row['user_id']."</b></td>";
echo "<td width=100 class=table><a href=\"edituser.php?id=".$row['user_id']."\">".$row['az_surname']."</a></td>";
echo "<td width=100 class=table>".$row['az_firstname']." </td>";
echo "<td width=100 class=table><i>".$row['username']."</i> </td>";
//echo "<td width=100 class=table><i><a href=\"?action=delete&user_id=".$row['user_id']."\"> delete: ".$row['username']."</a></i> </td>";
echo "<td width=100 class=table><i><a href=\"?action=delete&user_id=".$row['user_id']."\" onclick=\"if(confirm('Are you sure you want to delete the entry?')) return true; else alert('Delete canceled.');return false;\"> delete: ".$row['username']."</a></i> </td>";
echo "<td class=table></td>";
echo "</tr>";
$i++;
}
echo "<tr valign=bottom>";
echo "<td bgcolor=#93B0B4 colspan=6 height=8></td>";
echo "</tr>";
echo"<h4>To Edit a User please click on the users Surname.</h4>";
?>
any suggestions as to why my search isn't working properly???? is there a way to include the search in the tableview.php i posted using code from the search.php file? linking the two with an if-else statement?? that would be a better option
Inevitably i would like the results to come out the same way as they do in the tableview.php file i pasted above.
If someone can help me out with this i'd be very greatful, thanks a lot in advance.