The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

> upload multiple textboxes?
xxkasperxx
post 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'"));
            
            
        }
    }*/
    

        

    }
    
    
    
    


    

?>
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
 
Reply to this topicStart new topic
Replies
xxkasperxx
post 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?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Ephraim F. Moya
post 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



QUOTE(xxkasperxx @ Jul 2 2012, 11:43 AM) *

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.

User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Posts in this topic
xxkasperxx   upload multiple textboxes?   Jun 27 2012, 11:30 AM
xxkasperxx   i have tryed to de-bug this... and it seems like i...   Jun 28 2012, 05:36 PM
Brian Chandler   That's a good start. (Though you should know...   Jun 29 2012, 12:07 AM
xxkasperxx   Because it is being processed on the same page.   Jun 29 2012, 01:50 PM
Christian J   why does the form have no action? If it submits ...   Jun 29 2012, 02:02 PM
xxkasperxx   The text areas are named "text" and have...   Jun 29 2012, 11:54 AM
Christian J   The text areas are named "text" and hav...   Jun 29 2012, 02:29 PM
Brian Chandler   Sorry, I forgot about the empty action thing. I...   Jun 30 2012, 01:44 AM
Christian J   Which way to go is the Really Big Decision of PHP...   Jun 30 2012, 01:43 PM
xxkasperxx   It keeps give me a error message of "Notice:...   Jun 29 2012, 02:51 PM
Christian J   "$text = $_POST["text'....   Jun 29 2012, 03:57 PM
xxkasperxx   So now I get to press submit with no errors, but i...   Jun 29 2012, 04:09 PM
Ephraim F. Moya   How does the user add more text boxes? The only w...   Jun 30 2012, 08:30 AM
Christian J   How does the user add more text boxes? The only ...   Jun 30 2012, 01:44 PM
Ephraim F. Moya   How does the user add more text boxes? The only...   Jun 30 2012, 03:29 PM
xxkasperxx   There is only one user, and there would be a textb...   Jun 30 2012, 12:30 PM
xxkasperxx   so i still havent figured out how to update what i...   Jun 30 2012, 02:47 PM
xxkasperxx   so i still havent figured out how to update what ...   Jun 30 2012, 05:48 PM
Christian J   still havent figured it out My SQL is a bit rust...   Jul 1 2012, 03:14 PM
xxkasperxx   so i tryed to see where stuff was going wrong but ...   Jul 2 2012, 09:03 AM
Christian J   You're mixing up single- and double quote syn...   Jul 2 2012, 12:35 PM
xxkasperxx   okay. But why does it still only take the last tex...   Jul 2 2012, 12:43 PM
Ephraim F. Moya   okay. But why does it still only take the last te...   Jul 2 2012, 01:53 PM
xxkasperxx   the counter is increased each time it goes through...   Jul 2 2012, 04:22 PM
Ephraim F. Moya   the counter is increased each time it goes throug...   Jul 3 2012, 09:58 AM
xxkasperxx   There's something you're not telling us...   Jul 3 2012, 11:14 AM
Ephraim F. Moya   I get this when i use what you have posted. Arra...   Jul 3 2012, 12:50 PM
xxkasperxx   id is starting at 2 because thats what it starts a...   Jul 3 2012, 07:04 PM
Ephraim F. Moya   id is starting at 2 because thats what it starts ...   Jul 3 2012, 07:24 PM
xxkasperxx   it said array because tats waht was put in the DB ...   Jul 3 2012, 08:09 PM
Ephraim F. Moya   it said array because tats waht was put in the DB...   Jul 3 2012, 09:14 PM
xxkasperxx   How do i stop it from over writing? i cant figure ...   Jul 3 2012, 09:23 PM
Ephraim F. Moya   How do i stop it from over writing? i cant figure...   Jul 3 2012, 11:13 PM
xxkasperxx   Because it shows the second text box as the same t...   Jul 4 2012, 01:55 AM
Ephraim F. Moya   Because it shows the second text box as the same ...   Jul 4 2012, 07:59 AM
xxkasperxx   It is not getting the second box's text. Becau...   Jul 4 2012, 10:10 AM
xxkasperxx   So this is what i have so far. Can you please help...   Jul 4 2012, 11:31 AM
xxkasperxx   I got it to work!!!!!!...   Jul 4 2012, 11:47 AM


Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 19th April 2024 - 03:38 PM