jackie11 Posted January 17, 2007 Share Posted January 17, 2007 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 havethe 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 learningI would appricate any help Many ThanksJackie[/code] Link to comment https://forums.phpfreaks.com/topic/34648-displaying-search-results-help-please/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.