|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
Is it possible to dynamically populate a textarea with data from a database?
I have been using a search script for my database from this forum. I use redhat/apache/php 4.1/mysql. I want the "target", I know target only loads to page or frame, of the search to output to a textare named RECORD in a form named wow.
Is it possible to dynamically change the data in the textarea by invoking a database search. Should I be looking at javascript and do this client side? I would much prefer to do it on the server. Thank you for any help. script search script <? function searchtable($test,$resa, $usrquery){ $link = mysql_connect() or die("Could not connect: " . mysql_error()); $db = mysql_select_db($test, $link) or die(mysql_error()); $fields = mysql_list_fields($test, $resa, $link); $cols = mysql_num_fields($fields); $content = ""; for ($i = 0; $i < $cols; $i++) { $allfields[] = mysql_field_name($fields, $i); } foreach ($allfields as $keywords) { $result = mysql_query("SELECT * FROM $resa WHERE $keywords like '%$usrquery%' "); if (mysql_num_rows($result) > 0){ $content .= "<h5>search <i>$test</i> for <i>$usrquery</i>, found match(es) in <i>$keywords</i>: </h5>n"; $content .= "<table border=1 align="center">nt<tr>n"; for ($i = 0; $i < $cols; $i++) { $content .= "tt<th"; if ($keywords == mysql_field_name($fields, $i)){ $content .= " bgcolor="orange" "; } $content .= ">" . mysql_field_name($fields, $i) . "</th>n"; } $content .= "t</tr>n"; $myrow = mysql_fetch_array($result); do { $content .= "t<tr>n"; for ($i = 0; $i < $cols; $i++){ $content .= "tt<td"; if (preg_match("/$usrquery/i", $myrow[$i])){ $mysplit = preg_split("/($usrquery)/i", $myrow[$i], -1,PREG_SPLIT_DELIM_CAPTURE); $content .= " bgcolor="orange">"; for ($si=0;$si<count($mysplit);$si++){ if (preg_match("/$usrquery/i", $mysplit[$si])){ $content .= "<font color="green"><b>$mysplit[$si]</b></font>"; }else{ $content .= "$mysplit[$si]"; } } } else { $content .= ">$myrow[$i]"; } $content .= " </td>n"; } $content .= "t</tr>n"; } while ($myrow = mysql_fetch_array($result)); $content .= "</table>n"; } } mysql_close($link); return $content; } $page_content = searchtable(test,resa,$usrquery); echo $page_content; FORM SCRIPT: <FORM NAME="rform" ACTION="wow.php" METHOD="post" onSubmit="setTextFieldValue();"> <input type=text name='usrquery'><br> <input type= submit> </form> <form name="wow" action="cform.php" method="post" onSubmit="return checkit(this)" ENCTYPE="multipart/form-data"> <TEXTAREA NAME="RECORD" COLS="67" ROWS="5" WRAP="virtual" STYLE="background:00bfff" STYLE="color:000000" VALUE="First fact" INPUT TITLE="STATE FACT" ><? echo $page_content ?></textarea><br> <input value="click for motion" type="submit"></form> |
|
#2
|
|||
|
|||
|
RE: Is it possible to dynamically populate a textarea with data from a database?
In order to do it client side, you would need to store every possible query on the client side so that the javascript would have access to it. Best bet is to just post the page to itself and display the results as normal...
|
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Database Help > Is it possible to dynamically populate a textarea with data from a database? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|