Hi Im trying to populate a table via sql but struggling to how i can do it. i have search box, and when it is clicked i want the results going in the table.
where you are getting the trouble. Please send some more details so that we can undrstand the problem more precisely.
As of I understood, you have a search and you want to INSERT the results into a table? What code are you trying to use? And I wonder where the search results come from..?
This is the search:: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <style type="text/css"> <!-- body,td,th { font-size: 10px; } --> </style> <? $myServer = '**; $myUser = '**'; $myPass = '***'; $myDB = '***'; $SpecRef = $_GET['query']; print ("$SpecRef"); //connection to the database $dbhandle = mssql_connect($myServer, $myUser, $myPass) or die("Couldn't connect to SQL Server on $myServer"); //select a database to work with $selected = mssql_select_db($myDB, $dbhandle) or die("Couldn't open database $myDB"); //error message (not found message)begins $XX = "No Matches Found"; //query details table begins $query = ("SELECT * FROM dbo.DesignControl WHERE Spec_Ref LIKE'$SpecRef%' "); // $query = ("SELECT * FROM dbo.DesignProcess"); //execute the SQL query and return records $result = mssql_query($query); $numRows = mssql_num_rows($result); //display the results while($row = mssql_fetch_array($result)){ $Spec = $row["Spec_Ref"] . "\n"; $PrePressDate = $row["Pre_Press_Date"] . "\n"; $JobDescription = $row["Job_Description"] . "\n"; $ReproHouseDesignAgency = $row["Repro_House_Design_Agency"] . "\n"; $EndUserFamily = $row["End_User_Family"] . "\n"; $XRef = $row["X_Ref"] . "\n"; $CustRef= $row["Cust_Ref"] . "\n"; } echo"<form action='Pre-presscopy.php' method='get'>"; echo "Spec Ref <input type='text' name='query' id='query' size='40' value='$SpecRef' action='Pre-presscopy.php' columns='2' autocomplete='off' delay='1500' />"; echo"<input type='submit' value='Search'>"; echo"<input type='hidden' name='search' value='1'>"; echo"</form>"; echo "<form>"; echo " Pre Press Date <input type='text' value = '$PrePressDate'>" ; echo " Job Description <input type='text' value = '$JobDescription'>" ; echo " Repro House Design Agency <input type='text' value = '$ReproHouseDesignAgency'>" ; echo " End User Family <input type='text' value = '$EndUserFamily'>" ; echo " X Ref<input type='text' value = '$XRef'>" ; echo " Cust Ref <input type='text' value = '$CustRef'>" ; echo "</form>"; mssql_close($dbhandle); //display the results while($row = mssql_fetch_array($result)) { echo "<li>" . $row["Spec_Ref"] . "</li>"; } //close the connection mssql_close($dbhandle); //textareaContent = ""; //while ($row = @mysql_fetch_array($query)) //{ //$var1=$row["Player"]; //$var2=$row["Avg"]; //$var3=$row["HR"]; //$var4=$row["RBI"]; $textareaContent .= "Spec Ref: $var1 Avg: $var2 HR: $var3 RBI $var4 <br/>"; //} //if (!isset($var1) || $var1=="") { //echo $XX; //} // begin to show results set //echo "Results"; $count = 1 + $s ; $count++ ; ?> <body> <form id="form1" name="form1" method="post" action="search.php"> <label> </label> <span class="searchform"> <td bgcolor="#FFFFCC"> </td> </span> <label for="textfield2"></label> <label for="textfield3"></label> <form action="Search.php" method="POST"> <label for="textfield7"></label> <div> </form> </p> <html> </body> </html> In this part, I have seven text boxes and a search. When I click search, the results are displayed in them text boxes. But how do i do it to the other table so that when i click search, the results are also displayed in them text boxes. This is the table i am working towards: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <style type="text/css"> <!-- body,td,th { font-size: 9px; } --> </style></head> <body> <table border="1" cellspacing="0" cellpadding="0"> <tr> <td width="70" valign="top"><p>Substrate</p></td> <td width="54" valign="top"><p>Film1</p></td> <td width="76" valign="top"><p>Lamination</p></td> </tr> <tr> <td width="70" valign="top"><p>Printed/plain</p></td> <td width="54" valign="top"><p> <input name="name_<? echo $row['Spec_Ref']; ?>" type="text" id="name_<? echo $row['X_Ref']; ?>" value="<? echo $row['X_Ref']; ?>" size="8" /> </p></td> <td width="76" valign="top"><p> <input name="textfield" type="text" id="textfield" size="8" /> </p></td> </tr> <tr> <td width="70" valign="top"><p>Film type</p></td> <td width="54" valign="top"><p> <input name="name_<? echo $row['Spec_Ref']; ?>" type="text" id="name_<? echo $row['X_Ref']; ?>" value="<? echo $row['X_Ref']; ?>" size="8" /> </p></td> <td width="76" valign="top"><p> <input name="textfield3" type="text" id="textfield3" size="8" /> </p></td> </tr> <tr> <td width="70" valign="top"><p>Gauge</p></td> <td width="54" valign="top"><p> <input name="name_<? echo $row['Spec_Ref']; ?>" type="text" id="name_<? echo $row['X_Ref']; ?>" value="<? echo $row['X_Ref']; ?>" size="8" /> </p></td> <td width="76" valign="top"><p> <input name="textfield14" type="text" id="textfield14" size="8" /> </p></td> </tr> <tr> <td width="70" valign="top"><p>Colour </p></td> <td width="54" valign="top"><p> <input name="name_<? echo $row['Spec_Ref']; ?>" type="text" id="name_<? echo $row['X_Ref']; ?>" value="<? echo $row['X_Ref']; ?>" size="8" /> </p></td> <td width="76" valign="top"><p> <input name="textfield13" type="text" id="textfield13" size="8" /> </p></td> </tr> <tr> <td width="70" valign="top"><p>Treatment/coating</p></td> <td width="54" valign="top"><p> <input name="name_<? echo $row['Spec_Ref']; ?>" type="text" id="name_<? echo $row['X_Ref']; ?>" value="<? echo $row['X_Ref']; ?>" size="8" /> </p></td> <td width="76" valign="top"><p> <input name="textfield12" type="text" id="textfield12" size="8" /> </p></td> </tr> <tr> <td width="70" valign="top"><p>Film width</p></td> <td width="54" valign="top"><p> <input name="name_<? echo $row['Spec_Ref']; ?>" type="text" id="name_<? echo $row['X_Ref']; ?>" value="<? echo $row['X_Ref']; ?>" size="8" /> </p></td> <td width="76" valign="top"><p> <input name="textfield11" type="text" id="textfield11" size="8" /> </p></td> </tr> <tr> <td width="70" valign="top"><p>Part number</p></td> <td width="54" valign="top"><p> <input name="textfield9" type="text" id="textfield9" size="8" /> </p></td> <td width="76" valign="top"><p> <input name="textfield10" type="text" id="textfield10" size="8" /> </p></td> </tr> <tr> <td colspan="3" valign="top"><p align="center"><strong>Print Work Centre</strong></p></td> </tr> <tr> <td colspan="3" valign="top"><p><strong> </strong>6E <input type="checkbox" name="checkbox3" id="checkbox3" /> 6F <input type="checkbox" name="checkbox" id="checkbox" /> 8A <input type="checkbox" name="checkbox2" id="checkbox2" /> 8B <input type="checkbox" name="checkbox4" id="checkbox4" /> 10 <input type="checkbox" name="checkbox5" id="checkbox5" /> NA/ <input type="checkbox" name="checkbox6" id="checkbox6" /> </p></td> </tr> </table> <p> </p> <p> </p> </body> </html>
Put that between BBCODE code tags please. But why do you want to save the search results while they are already in a table...?
I don't wish to save the results, i want them results to be displayed in that table. Im using frames to create these tables, so I don;t think you can can't you. I have 6 tables in total and have used 6 frames for them. When I click search, i want them 6 tables to be displayed with information.
try to post your code here http://pastie.org/ in php format so ppl can see better format and can tell you how to format yor tables.