Results 1 to 6 of 6

Thread: pulling into a textbox...

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2002
    Location
    CT
    Posts
    62

    Question pulling into a textbox...

    I'm sorry to keep buggin everyone with my questions... but the book that I have is not advanced enough for what I am trying to do, and i have not had the opportunity to get a better one. At the moment I am trying to pull a bunch of information out of a database and put it in text boxes so the information can be edited.. and then click an update button and have all information be updated in the db.. i have the code to pull it from the DB, but it does not allow for editing, it is just displayed on the screen.. thanks for your help everyone.
    Sometimes the simplest things are the hardest...

  2. #2
    New Member
    Join Date
    Mar 2002
    Location
    Sweden
    Posts
    6
    I'm new to this to but this is the kinda thing I'd do:

    Code:
    <?php
    if($submit){
    	$updateSql = "UPDATE someTable SET text='".$text."', title='".$title."' WHERE someCondition";
    	mysql_query($updateSql);
    }else{
    ?>
    <form action="<?php echo $PHP_SELF; ?>">
    <input type="text" name="text">
    <input type="text" name="title">
    <input type="sumbit" name="submit">
    </form>
    <?php
    }
    ?>
    The values of the textboxes could be set to the information you pulled from the DB.

    This is pretty stripped down. No error handling etc but maybe you get some ideas from it

  3. #3
    scoutt
    Guest
    Originally posted by I Robert I
    I'm new to this to but this is the kinda thing I'd do:

    Code:
    <?php
    if($submit){
    	$updateSql = "UPDATE someTable SET text='".$text."', title='".$title."' WHERE someCondition";
    	mysql_query($updateSql);
    }else{
    ?>
    <form action="<?php echo $PHP_SELF; ?>">
    <input type="text" name="text">
    <input type="text" name="title">
    <input type="sumbit" name="submit">
    </form>
    <?php
    }
    ?>
    that will not work.
    $updateSql = "UPDATE someTable SET text='".$text."', title='".$title."' WHERE someCondition

    can't have .$text. will do nothing. just $text will do fine.

    but you were close. so if you want the fields to go into teh input boxes you have to give them values.

    so you connected to the database and you found the id you want to display. then just add that to the form.

    <form action="<?php echo $PHP_SELF; ?>">
    <input type="text" name="text" value="<? $namevalue ?>">
    <input type="text" name="title" value="<? $titlevalue ?>">
    <input type="sumbit" name="submit">

  4. #4
    New Member
    Join Date
    Mar 2002
    Location
    Sweden
    Posts
    6
    Strange cause that syntax works absolutely fine for me I use it all the time in my current project (http://bender.homeftp.net:4224/) and I have had NO problems what so ever.

  5. #5
    scoutt
    Guest
    well I didn't say that very well. I meant it will work but no need to use it like that. the "." means you are adding things to it, in this case you are not, so why have it in there.

  6. #6
    New Member
    Join Date
    Mar 2002
    Location
    Sweden
    Posts
    6
    Oh, ok. Well I guess my reason is that it makes em stand out in my editor due to syntax highlighting. Kinda like when the variables stand out from the rest of the code

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width