Jump to content

Search help!!!!


jackie11

Recommended Posts

Hi all :-\

I am having some difficulty displaying data from my db when I request it based on a search of the field surname, when I run the query I get the message back Query was empty and I'm not sure what I'm doing wrong

The HTML code I am using is:

[code]<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <title>form.html</title>
  <link rel="stylesheet" href="etc/TJConsultants.css">
</head>
<body>
<br>
<div id="wrapper">
<div id="header">
<div style="text-align: center;"><br>
</div>
<br>
</div>
<div id="centercolumn">
<div style="text-align: center;"><br>
<br>
<a href="employee_index.php"><img
style="border: 0px solid ; width: 428px; height: 42px;"
alt="link1" src="etc/employee_index_link.bmp"></a><br>
<br>
<br>
<a href="form.php"><img
style="border: 0px solid ; width: 430px; height: 44px;"
alt="link2" src="etc/Form_link.bmp"></a><br>
<br>
<br>
<br>
<br>
<font style="font-family: Tahoma;" size="+1"><span
style="color: rgb(0, 0, 102);">Search Employee Index -
Please enter employee Surname</span></font><br>
<br>
<form name="form" action="search.php" method="get">
  <input name="employee" type="text"> <input
name="Submit" value="Search" type="submit">
</form>
</div>
</div>
<div id="footer">
<p style="text-align: left;"></p>
</div>
</div>
</body>
</html>
[/code]


The PHP script is:

[code]<?php
$user="root";
$host="localhost";
$password="";
$database = "employee_index";
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("employee_index") or die(mysql_error());
$sqlquery = "SELECT * FROM `employee` WHERE Surname LIKE '%$search%'"; 
$result = mysql_query($query)
or die (mysql_error());

 
$XX = "No Record Found"; 
while ($row  =  mysql_fetch_array($query)) 
  { 
        $variable1=$row["row_Employee_ID"]; 
        $variable2=$row["row_Surname"];
        $variable2=$row["row_forename"];
        $variable2=$row["row_Job_title"];
        $variable2=$row["row_Office_location"];
        $variable2=$row["row_Telephone"]; 
        $variable2=$row["row_Email"];
        $variable2=$row["row_Expertise"];
        $variable2=$row["row_Hobbies"];
        $variable2=$row["row_DOB"];
        $variable2=$row["row_Picture"];
       
print ("this is for $variable1, and this print the variable2 end so on..."); 
  } 

if (!$variable1) 

print ("$XX"); 

//end 
?> [/code]


Can anyone please help no one seems to know why its not working!!!!


Please also bear in mind I am completely new to this so make it simple

Many Thanks

Jackie
Link to comment
Share on other sites

Hi

Thanks for your replies

The Little Guy

I changed this and I am now getting error message

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\Program Files\xampp\htdocs\Database\Search.php on line 15
No Record Found

To Jesirose

Sorry I am not sure what you mean how do I go about definning this? sorry I a real newbie I've only been learning Mysql and php for a few days

Thanks

Jackie


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.