upload multiple textboxes? |
upload multiple textboxes? |
xxkasperxx |
Jun 27 2012, 11:30 AM
Post
#1
|
Serious Coder Group: Members Posts: 261 Joined: 30-April 11 Member No.: 14,449 |
How can i upload more than 1 text box into my database? i want to have it to where they are seperrate fields..
EX: |--------------------------------------------| | FIELD 1.. so text box 1 goes here | |--------------------------------------------| |--------------------------------------------| | FIELD 2.. so text box 2 goes here | |--------------------------------------------| But the user is going to be able to add more text boxes. It is for an announcements page. So the big question is how do i upload the text-boxes into the correct field? CODE <?php session_start(); include("config.php"); $query = mysql_query("SELECT * FROM home"); $query_row=mysql_fetch_array($query) or die (mysql_error()); if (isset($_SESSION['loggedin'])&&isset($_SESSION['username'])) { echo "Welcome, " . $_SESSION['username'] . "!" . "<a href='logout.php'> Log-out!</a>"; ?> <!-- EDIT FOR CMS --> <!DOCTYPE html> <html> <head> <link href="css/main.css" type="text/css" rel="stylesheet" > <title>ConroeGoAway</title> <script src="http://js.nicedit.com/nicEdit-latest.js" type="text/javascript"></script> <script type="text/javascript">bkLib.onDomLoaded(nicEditors.allTextAreas);</script> </head> <body> <div id="wrapper"> <div id="header"> <ul> <li><a href="index.php" class="active">Home</a></li> <li><a href="articles.php">Articles</a></li> <li><a href="email.php">Email</a></li> <li><a href="suggestions.php">Suggestions</a></li> <li><a href="#">Blog</a></li> </div> <div id="picture"> <img src="images/home.png"width="80%"> </div> <div id="bgAnnouncments"> <form action="" method="POST"> <?php $counter =0; while($row = mysql_fetch_array($query)){ $counter++; echo '<textarea id="text.$counter" name="text" rows="15" cols="80" style="width: 100%">'; echo $row['content']; echo '</textarea>'; } ?> <input type="submit" value="Submit" name="submit"> </form> </div> <footer> <p>Copyright © 2012 ConroeGoAway</p> </footer> </div> </body> </html> <?php }else { ?> <!-- REGULAR --> <!DOCTYPE html> <html> <head> <link href="css/main.css" type="text/css" rel="stylesheet" > <title>ConroeGoAway</title> </head> <body> <div id="wrapper"> <div id="header"> <ul> <li><a href="index.php" class="active">Home</a></li> <li><a href="articles.php">Articles</a></li> <li><a href="email.php">Email</a></li> <li><a href="suggestions.php">Suggestions</a></li> <li><a href="#">Blog</a></li> </div> <div id="picture"> <img src="images/home.png"width="80%"> </div> <div id="bgAnnouncments"> <?php while($row = mysql_fetch_array($query)){ echo $row['content']; } ?> </div> <footer> <p>Copyright © 2012 ConroeGoAway</p> </footer> </div> </body> </html> <?php } if ($_POST) { /* foreach ($text as $text){ $text = $_POST['text']; echo $text; echo "data is posted"; if (isset($text)) { echo 'text is set'; $result = strip_tags(mysql_query("UPDATE home SET content = '$text'")); } }*/ } ?> |
xxkasperxx |
Jul 2 2012, 12:43 PM
Post
#2
|
Serious Coder Group: Members Posts: 261 Joined: 30-April 11 Member No.: 14,449 |
okay. But why does it still only take the last text box, and insert that for every box? I guess i dont know where it is overwriting the first text box. How would i figure that out?
|
Ephraim F. Moya |
Jul 2 2012, 01:53 PM
Post
#3
|
Advanced Member Group: Members Posts: 167 Joined: 2-September 07 From: New Mexico Member No.: 3,702 |
okay. But why does it still only take the last text box, and insert that for every box? I guess i dont know where it is overwriting the first text box. How would i figure that out? Because the names are not understandable. Make the names text1, text2, text3, ... etc. Not text.1, text.2, ... etc. or some variant. BTW, How are you going to use this code multiple times? Your counter starts at 0. Use the {$var} method in double quotes. Its more understandable. Instead of "word'.$var2.'" say "word{$var2}" which will cleanly concatenate the two instead of using the .(dot) operator. |
Lo-Fi Version | Time is now: 19th April 2024 - 03:38 PM |