mjgdunne Posted April 21, 2008 Share Posted April 21, 2008 Hi i have a basic search which works in mysql database, i now need to be able to update the information in the results fields, is there any way of echoing the results into input fields so i can update the records? Here is my code: Any help would be great, thanks. <html> <head> <title>Car Rentals & Returns</title> <meta http-equiv="Content-Type" content="text/html" /> <link href="style2.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="wrapper3"> <img src="images/cars.jpg" width="996" height="100"></a> <TABLE BGCOLOR="#F0F8FF" BORDER=0 CELLPADDING=10 WIDTH=100%> <tr> <td align="center"> <H1>Search Results:</H1> <form method="post" action="login_success3.php"> </td> </table> <TABLE BGCOLOR="#F0F8FF" BORDER=0 CELLPADDING=10 WIDTH=30%> <tr> <TD ALIGN=CENTER VALIGN=TOP WIDTH=50> </TD> <TD ALIGN=LEFT VALIGN=TOP WIDTH=83%> <TR><TD> <?php $host="localhost"; // Host name $username="root"; // Mysql username $password="root"; // Mysql password $db_name="test"; // Database name $tbl_name="customers"; // Table name // Connect to server and select databse. mysql_connect("$host", "root", "root")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $myq=$_POST['myq']; if (isset($_POST['myq'])) { $myq = mysql_real_escape_string($_POST['myq']); $result = mysql_query("SELECT * FROM customers WHERE firstname LIKE '%$myq' OR surname LIKE '%$myq'"); while ($row = mysql_fetch_assoc($result)) { echo "<p>You searched for: "" . $myq . ""</p>"; echo "<table border=\"1\" align=\"center\">"; echo "<tr><th>Title</th>"; echo "<td>"; echo $row['title']; echo "</td>"; echo "<tr><th>First Name</th>"; echo "<td>"; echo $row['firstname']; echo "</td>"; echo "<tr><th>Surname</th>"; echo "<td>"; echo $row['surname']; echo "</td>"; echo "<tr><th>Age</th>"; echo "<td>"; echo $row['age']; echo "</td>"; echo "<tr><th>Email</th>"; echo "<td>"; echo $row['email']; echo "</td>"; echo "<tr><th>Address</th>"; echo "<td>"; echo $row['address']; echo "</td>"; echo "<tr><th>Credit Card Details</th>"; echo "<td>"; echo $row['']; echo "</td>"; echo "<tr><th>Tile</th>"; echo "<td>"; echo $row['title2']; echo "</td>"; echo "<tr><th>First Name</th>"; echo "<td>"; echo $row['firstname2']; echo "</td>"; echo "<tr><th>Surname</th>"; echo "<td>"; echo $row['surname2']; echo "</td>"; echo "<tr><th>Card Type</th>"; echo "<td>"; echo $row['cardtype']; echo "</td>"; echo "<tr><th>Date</th>"; echo "<td>"; echo $row['date']; echo "</td>"; echo "<tr><th>Date</th>"; echo "<td>"; echo $row['date2']; echo "</td>"; echo "<tr><th>Verification</th>"; echo "<td>"; echo $row['verification']; echo "</td>"; echo "<tr><th>Address</th>"; echo "<td>"; echo $row['address2']; echo "</td>"; } } if (!$result) { $message = 'Invalid query: ' . mysql_error() . "\n"; $message .= 'Whole query: ' . $query; die($message); } if (mysql_num_rows($result) == 0) { echo "No records found"; exit; } ?> <TABLE BGCOLOR="#F0F8FF" BORDER=0 CELLPADDING=10 WIDTH=30%> <tr> <td align="center"><input type="submit" value="Home"/></td> </tr> </table> </table> </td> </form> </tr> </table> </BODY> </HTML> Link to comment https://forums.phpfreaks.com/topic/102171-how-to-print-resluts-of-a-search/ Share on other sites More sharing options...
Northern Flame Posted April 22, 2008 Share Posted April 22, 2008 yea for each of the things that you echo, just put in the input tag, ex: echo "<tr><th>Title</th>"; echo "<td>"; echo '<input type="text" name="title" value="'. $row['title'] .'" size="20" />'; echo "</td>"; Link to comment https://forums.phpfreaks.com/topic/102171-how-to-print-resluts-of-a-search/#findComment-523681 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.