Professional Web Applications Themes

inserting data... - PHP Development

Message-ID: <3efaa4df$0$236hades.is.co.za> from The Script Smiths - PHP/PERL Developers contained the following: > >From your post, it appears you have a record in the format: >Name / Street / City / Country Seems to me that this relies on a, the person entering the data to do so with care and b, no null fields. I think I'd prefer to do it with individual text boxes. -- Geoff Berrow It's only Usenet, no one dies. My opinions, not the committee's, mine. Simple RFDs [url]http://www.ckdog.co.uk/rfdmaker/[/url]...

  1. #1

    Default Re: inserting data...

    Message-ID: <3efaa4df$0$236hades.is.co.za> from The Script Smiths -
    PHP/PERL Developers contained the following:
    >
    >From your post, it appears you have a record in the format:
    >Name / Street / City / Country
    Seems to me that this relies on
    a, the person entering the data to do so with care and
    b, no null fields.

    I think I'd prefer to do it with individual text boxes.

    --
    Geoff Berrow
    It's only Usenet, no one dies.
    My opinions, not the committee's, mine.
    Simple RFDs [url]http://www.ckdog.co.uk/rfdmaker/[/url]
    Geoff Berrow Guest

  2. #2

    Default Re: inserting data...

    thanks!!

    this worked perfectly for me.

    thanks everyone for your replies.

    :)
    James

    "The Script Smiths - PHP/PERL Developers" <mh2isis.co.za> wrote in message
    news:3efaa4df$0$236hades.is.co.za...
    > Hi,
    >
    > PHP, like most langauges, doesn't offered a canned call to perform task,
    > instead it provides an API of many functions that can be combined to
    > complete any task (a toolbox basically)
    >
    > What you would need to do here is (this assumes we are posting one record
    at
    > a time):
    > 1. Split input string up into various peices
    > 2. Valdiate data
    > 3. inserting row row into database
    >
    > From your post, it appears you have a record in the format:
    > Name / Street / City / Country
    >
    > So, we could do something like this (Warning!! untest semi-psuedo code
    > alert!!)
    >
    > // on your form
    > <input type=text name=datablob>
    >
    > // in your code (note: if you are using an older PHP, use
    > $HTTP_POST_VARS[datablob] )
    >
    > if ( $_POST[data_blob] != '' )
    > {
    > // break input up into an array of fields
    > $fields = explode('|',$_POST[data_blob]);
    >
    > // here you would validate the input
    > // ...
    >
    > // now insert into the database....
    > mysql_query( "INSERT INTO my_table (name,street,city,country)
    > VALUES('$fields[0]','$fields[1]','$fields[3]','$fields[4]')" );
    > }
    >
    > Of course, IRL you should never use plain numeric indexes like $field[0] ,
    > rather to improve your code maintainability define an constant in your
    code
    > to represent the index of the field in the input... like so....
    >
    > define( 'DATA_NDX_CITY', 2 );
    > $fields[DATA_NDX_CITY] = 'blabla';
    >
    > Of course, if you want to do many records at once, its a little more
    > complex, can help out on that as well it you need!
    >
    > Hope this helped a bit!!
    >
    > Thanks,
    > Mark
    > --------------------------------------------------------------------------
    --
    > --
    > Windows, Linux and Internet Development Consultant
    > Email: [email]corporatescriptsmiths.com[/email]
    > Web: [url]http://www.scriptsmiths.com[/url]
    > --------------------------------------------------------------------------
    --
    > --
    >
    >
    > "James" <noemail.com> wrote in message
    > news:3efa581d$0$11189echo-01.iinet.net.au...
    > > Hi,
    > >
    > > I have a small php/mysql database. Currently, to enter data you have to
    go
    > > into each field on the website , enter the data, then tab or click to
    the
    > > next field and enter the next fields data ..etc etc..
    > >
    > > I would like to have a long field at the top, which gives the option to
    > > paste all the data into, and then click add, and it automatically adds
    the
    > > correct data to the fields and inserts into the database.
    > >
    > > The data for each field would be seperated by a delimiter.
    > >
    > > example:
    > >
    > > fred bloggs|64 car st|melbourne|australia
    > >
    > > So "fred bloggs" would be inserted into the 1st record, then "64 car st"
    > > into the 2nd and so on....
    > >
    > > Im quite new to php and cant seem to find anything on how to do this.
    > >
    > > TIA
    > > James
    > >
    > >
    >
    >

    James Guest

Similar Threads

  1. Inserting data to SQL
    By toby007 in forum Coldfusion - Getting Started
    Replies: 2
    Last Post: April 18th, 03:38 AM
  2. Replies: 2
    Last Post: March 8th, 11:57 AM
  3. Inserting Data into DB
    By sbitcorp in forum Coldfusion - Getting Started
    Replies: 1
    Last Post: February 16th, 09:29 AM
  4. Inserting Data
    By robert_raw webforumsuser@macromedia.com in forum Macromedia Dreamweaver
    Replies: 1
    Last Post: July 16th, 03:01 PM
  5. Replies: 1
    Last Post: July 10th, 08:29 PM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139