Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

Go Back  dBforums > Data Access, Manipulation & Batch Languages > PHP > Help!! Dropdown to Textarea via MySql

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-21-04, 05:32
edgarsr edgarsr is offline
Registered User
 
Join Date: Oct 2004
Location: KY
Posts: 2
Help!! Dropdown to Textarea via MySql

Hopefully someone here can help me... I am drawing a complete blank and feel like an idiot but here goes....

I am trying to get a drowdown box populated by field b of table A to OnSelect display field b of table B in a textbox below (note: field a of both is id) underneath

the text box it would have update to effect changes if necessary (this part if optional - probably better to have it updated on an admin screen.) Anyway im

stuck...got the javascript/php/mysql to popluate to the dropdown no probably then drew a blank.

I have tried countless way to effect the proper result. Still having trouble. Below is the latest code tried.

Thanks for you help.

PHP Code:
<html>

<head>
<title></title>
</head>

<body>
<table width="100%" align="center" cellspacing="0" cellpadding="0">
<tr valign="bottom">
<td width="50%" align="right">
<font size="2" face="Verdana, Arial, Helvetica, sans-serif">
<form name="testing" method="GET" action="<?=$PHP_SELF?>">
Filter by
<select name="testing">
<?php
require("hits.php");
require (
"db.php");
$result mysql_query("SELECT * FROM title ORDER BY id");
$query "SELECT * FROM title ORDER BY id ASC";
function 
displayerror($message) {
printf("<span class=\"formerror\">%s</span>\n"$message);
}
if (!(
$result mysql_query($query))) {
displayerror(sprintf("Internal ****ed up error %d:%s\n"mysql_errno(), mysql_error()));
exit();
// end if
if($result) {
while(
$row=mysql_fetch_array($result)){
?>
<option value="<? echo $row['id']; ?>"><? echo $row['title']." ".$row[''];?></option>
<?
// end while
// end if
?>
</select> <p>&nbsp;
<textarea name="n" cols="60" rows="10" ><?php echo $row ?></textarea>



</body>

</html>

Last edited by rhs98 : 10-21-04 at 05:42. Reason: format the post properly (i.e. php tag)
Reply With Quote
  #2 (permalink)  
Old 10-21-04, 05:59
rhs98 rhs98 is offline
Moderator
 
Join Date: Feb 2002
Location: Hampshire, UK
Posts: 440
PHP Code:
<form name="testing" method="GET" action="">
Filter by
<select name="testing" onchange="this.form.submit()">
<?php
require("hits.php");
require(
"db.php");

$query "SELECT * FROM title ORDER BY id ASC";
$result mysql_query($query);

if (!
$result)
{
    die(
mysql_errno() . ': ' mysql_error());
}
else
{
    while(
$row mysql_fetch_array($result))
    {
    
?>
    <option value="<? echo $row['id']; ?>"><? echo $row['title'];?></option>
    <?
    
}
}

//enter the bit to display the textbox
if(isset($_GET['testing']))
{
    
$query sprintf("SELECT * FROM blah WHERE id = %d",$_GET['testing']);
    
$result mysql_query($query);
    
    if (!
$result)
    {
        die(
mysql_errno() . ': ' mysql_error());
    }
    else
    {
        
//there may be > one row - but I don't know...
        
if(mysql_num_rows($result)>0)
        {
        
?>
        <textarea name="n" cols="60" rows="10" ><?php echo $row['somecolumn']; ?></textarea> 
        <?php
        
}
        else
        {
            echo 
"Not found!";
        }
    }
}
?>


Dude you code was quite messy...


I've made some assumptions, but this will (should ) do;

Get a list of stuff, and display it in a select drop down box.

When the selection is changed, it will resubmit the form - reloading the page.

The script will then detect the page has been reloaded and display the data from the second query (if found).


HTH.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On