Jump to content

Displaying search results - help please!!!!!!


jackie11

Recommended Posts

Hi Everyone

I am still trying to fix some issues I am having when I run a search and display query on my db,

I have now managed to get the search to work and upload the relevent fields but I am looking for it to be displayed in a in a similar way to another page I have

the script I use is:

[code][<?php


$search = "%" . $_POST["search"] . "%";
 

mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("employee_index") or die(mysql_error());


 $query = "SELECT * FROM employee WHERE Surname LIKE '$search'";
 $result = mysql_query ($query);
 
 
 
   if ($result) {
   while ($row = mysql_fetch_array ($result)) {
     foreach ($row as $key => $value) {
       echo "$key = $value<br>";
     }
     echo "<hr>";
   }
 }
?>

/code]


this is the type of layout I want it to display in

[code]echo "<table cellspacing='15'>";
 echo "<tr><td colspan='20'><hr></td></tr>";
  echo "<th>ID</th><th>Picture</th><th></TD><th>Surname</th><th>Forename</th><th>Job Title</th><th>Office Location</th><th>Telephone</th>
  <th>Email</th><th>Expertise</th><th>Hobbies</th><th>DOB</th>";
 echo "<tr><td colspan='20'><hr></td></tr>";

 while ($row = mysql_fetch_array($result))
 {
    extract($row);
 
     echo "
          <td>$Employee_ID</td>\n
          <td><a href='../Database/pics/{$row['Picture']}' border='0'>
           <img src='../Database/pics/{$row['Picture']}' border='0'
            width='90' height='100'></a><td></td>\n
          <td>$Surname</td>\n
           <td>$Forename</td>\n
            <td>$Job_title</td>\n
             <td>$Office_location</td>\n
              <td>$Telephone</td>\n
               <td>$Email</td>\n
                <td>$Expertise</td>\n
                 <td>$Hobbies</td>\n
                  <td>$DOB</td>\n
                   
                 
               

          </tr>\n";
    echo "<tr><td colspan='20'><hr></td></tr>\n";
 }
 echo "</table>\n";
 
[/code]

I don't no how to combine the two, sorry for being so simple but I am really new to this and am still slowly learning

I would appricate any help

Many Thanks

Jackie
[/code]
Link to comment
https://forums.phpfreaks.com/topic/34648-displaying-search-results-help-please/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.