Jump to content

Need help with php script and variables


patheticsam

Recommended Posts

Hi! I'm not really good in PHP and I have a problem. I tried many different way to solve it but none of them worked.

 

 

In the first part I'm taking out some stuff of mySQL database and fetch it into a multiple select box

 

Here's the code :

 

<select name="fields" size=5 multiple>

<?php

 

$db = mysql_connect('localhost', 'database', 'password');

 

mysql_select_db('databasename',$db);

 

$sql = "SELECT `firstname`, `lastname`, `field3`, FROM table1";

 

$rs = mysql_query($sql);

 

while($row = mysql_fetch_array($rs))

{

  echo "<option value=\"".$row['field3']."\">".$row['field1']." ".$row['field2']."\n  ";

 

}

 

echo "

</select>

    ";

 

After that I have 3 radio buttons that will change the content of a "textarea" depending on which radio button is selected. Until now everything works fine....

 

Here's the code :

 

 

echo "

<script type=\"text/javascript\">

function updateText(src)

{

  if(src.checked)

      document.getElementById('email').value = src.value;

}

</script>

 

 

And now the problem.....

 

let's say I selected the first radion button. What I want to do is I want the text 1 to appear but with the firstname depending on which firstname I have selected in the multiple select box...

 

 

<input type='radio' value='email text 1 looks like blah blah blah firstname blah blah ' onClick='updateText(this);' name='text'/>Option 1

 

 

 

<input type='radio' value='email text 2' onClick='updateText(this);'  name='text'/>Option 2<input type='radio' value='email text 3' onClick='updateText(this);'  name='text'/>Option 3

 

<br>

<textarea cols=78 rows=15 id='email'></textarea>

<input type=submit value=send>

    ";

?>

 

 

I don't know if anyone can help me out....But it would be really appreciated....Thank you!!!!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.