hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Programming Discussion : posting to mysql database via php question
Reply

Programming Discussion Discussions related to web programming languages and other related issues. Topics may include configuration, optimization, practical usage and database connectivity.
Forum Jump

posting to mysql database via php question

Reply Post New Thread In Programming Discussion Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 11-11-2005, 02:43 PM
djacks89 djacks89 is offline
Junior Guru Wannabe
 
Join Date: Feb 2005
Posts: 58

posting to mysql database via php question


I'm creating a page with multiple instances of the same form fields. The number of instances shown is dependant upon an entry into a previous form that will be posted to this form via the hidden form method.

ex:

form1 - input amount of properties you have.(inputs 3)

form2 - display x(3) instances of property data collection-- using for loop.

property address
property zipcode
etc.

property address
property zipcode
etc.

property address
property zipcode
etc.

I can write script to do this. The problem is when they submit everything. I want to know if there will be a problem when I send the info to the mysql database for insertion. Aren't the variables for the replicated fields going to be the same(name=prop_zipcode in each set of fields) when I SET where I want the information to be inserted. Will this cause an issue. If so, I would really appreciate a method for dealing with this.

I was thinking that maybe I shouldn't have to worry about this because the database might just insert the info in order row after row. Maybe I should use some type of method with an array.

Reply With Quote


Sponsored Links
  #2  
Old 11-11-2005, 05:21 PM
Burhan Burhan is offline
Community Guide
 
Join Date: Jul 2003
Location: Kuwait
Posts: 5,100
Not only that, but if you name all the form fields the same, only the last field's value will be available to PHP.

You can avoid this problem by naming your fields with the array notation:

<input type="text" name="hello[]"
<input type="text" name="hello[]"

etc.

__________________
In order to understand recursion, one must first understand recursion.
If you feel like it, you can read my blog
Signal > Noise

Reply With Quote
  #3  
Old 11-11-2005, 06:13 PM
djacks89 djacks89 is offline
Junior Guru Wannabe
 
Join Date: Feb 2005
Posts: 58
Yeah, it makes sense. I've decided to do everything by array. I just wasn't sure. Actually, I was hoping that I wouldn't have to do more work.(lol)
Thanks alot

Reply With Quote
Sponsored Links
  #4  
Old 11-12-2005, 08:58 PM
djacks89 djacks89 is offline
Junior Guru Wannabe
 
Join Date: Feb 2005
Posts: 58
Quote:
Originally Posted by fyrestrtr
Not only that, but if you name all the form fields the same, only the last field's value will be available to PHP.

You can avoid this problem by naming your fields with the array notation:

<input type="text" name="hello[]"
<input type="text" name="hello[]"

etc.
Will the arrays fill after submit is pressed?

Reply With Quote
  #5  
Old 11-12-2005, 09:21 PM
localhost127 localhost127 is offline
Junior Guru
 
Join Date: Sep 2005
Location: Southern California
Posts: 179
When submit is pressed it will go to whatever page you sent it to, and then the arrays will be populated.

If you have register globals off (this is a good thing to have off) then you would need to access it via either $_POST['hello'] or $_GET['hello'] depending on whether your form posts or gets.

Reply With Quote
Reply

Related posts from TheWhir.com
Title Type Date Posted
Joomla Releases Version 2.5 With SQL Server Support Web Hosting News 2012-01-24 13:34:24
Web Host Rackspace Launches Private Beta for MySQL Cloud Database Web Hosting News 2011-12-01 21:09:51
Web Host DiscountASP.NET Lets Customers Keep Testing Web Matrix V2 Beta for Free Web Hosting News 2011-11-15 16:48:12
Selling Your Hosting Company #4 - Who will be the buyer? Blog 2011-08-26 17:56:52
Web Host FireHost Partners with Cloud Security Firm Gazzang for Data Encryption Web Hosting News 2011-08-16 20:33:43


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?