Jump to content

Same page to execute multiple taks


kts

Recommended Posts

Hey, if i have one page that you select which row you want to update with a dropdown and i want it to display in the text box and also a button for submitting the info to update... what would be the best way to do it? Switch statements or if statements?

 

 

you want what to display in the text box?

 

you want to output the results of a drop-down as text after updating the db? or you want to update the db via drop down while also processing a text input from the same form?

this should work - you can also use the isset($_POST['title']) to control whether the submit button for the drop-down even shows up after the user makes the initial selection and the data gets posted back to the page.

 

 

<?php

if(isset($_POST['title'])) {
$title = $_POST['title'];
$result = mysql_query("SELECT text FROM table WHERE title = '$title'") 
or die(mysql_error()); 
}



?>

<form id="dropdown" method="post">
   <select name="title">
      <option>title1</option>
      <option>title2</option>
   </select>
   <input type="submit" value="submit">
</form>



<form id="textbox" action="nextpage.php" method="post">
   <TEXTAREA name="thetext">
   <?php echo $result ?>
   </TEXTAREA>
   <INPUT type="submit" value="submit"> 
</FORM>

Thanks, but I was actually trying to not do a "nextpage.php" hehe I guess I can just use another if

 

 

yeah you weren't real clear in any of your posts on exactly what you are trying to do but you should be able to tweak that to do what you need  ;D

 

 

you could actually combine the 2 forms if you want and still post to self.

 

 

- dhappy

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.