Database Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesDatabase Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
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  
Old June 18th, 2003, 03:18 PM
martindom martindom is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: West Plains, Mo. U.S.
Posts: 16 martindom User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via Yahoo to martindom
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 .= "&nbsp;</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>


Reply With Quote
  #2  
Old June 19th, 2003, 12:38 AM
Matt Matt is offline
Moderator
Codewalkers Specialist (4000 - 4499 posts)
 
Join Date: Apr 2007
Location: Florida
Posts: 4,158 Matt User rank is Private First Class (20 - 50 Reputation Level)Matt User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 h 10 m 20 sec
Reputation Power: 6
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...

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesDatabase Help > Is it possible to dynamically populate a textarea with data from a database?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway