473,467 Members | 1,985 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

creating vars on the fly

Hi everyone,
I have a project that I'm working in which the user is allowed to
create and add columns to certain tables in mysql. After they add
them, I need to be able to display them in a form so I can use them.
Now, that part isn't a problem, but what I'm having a problem w/ is
that when I submit them through the form, how can I process all the
fields dynamically. The user could add 20 fields so how in my code
could I handle that. If anyone could help me out I would appreciate
it or if you need more info or I'm not making sense let me know.
LAMP environment, PHP 4.2.3 MySQL 4.0.12

TIA
Mike B
Jul 16 '05 #1
2 2008
me***********@yahoo.com (Mike B) wrote in
news:70**************************@posting.google.c om:
Hi everyone,
I have a project that I'm working in which the user is allowed to
create and add columns to certain tables in mysql. After they add
them, I need to be able to display them in a form so I can use them.
Now, that part isn't a problem, but what I'm having a problem w/ is
that when I submit them through the form, how can I process all the
fields dynamically. The user could add 20 fields so how in my code
could I handle that. If anyone could help me out I would appreciate
it or if you need more info or I'm not making sense let me know.
LAMP environment, PHP 4.2.3 MySQL 4.0.12


Here's some code that should help you.
$query = "Your query here";
$result = @mysql_query ($query);
while ($row = mysql_fetch_array($result,MYSQL_ASSOC))
{
while(list($key,$val) = each($row)) {
echo '<input type=text name=$key
value="'.htmlspecialchars(stripslashes($row[$key])).'"> '."\n";
}
echo "\n";
}
The key is to get the array return by MySQL to be an associative array
that has the field names as indices to the array.

Ken Robinson
KIS Web Design
www.kis-web-desgin.com
Jul 16 '05 #2
mysql_list_fields() could help.

See the example at
http://www.php.net/manual/en/functio...ist-fields.php

Mike B wrote:
Hi everyone,
I have a project that I'm working in which the user is allowed to
create and add columns to certain tables in mysql. After they add
them, I need to be able to display them in a form so I can use them.
Now, that part isn't a problem, but what I'm having a problem w/ is
that when I submit them through the form, how can I process all the
fields dynamically. The user could add 20 fields so how in my code
could I handle that. If anyone could help me out I would appreciate
it or if you need more info or I'm not making sense let me know.
LAMP environment, PHP 4.2.3 MySQL 4.0.12

TIA
Mike B


--
MeerKat

Jul 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: james | last post by:
I am new to php and need some help getting the session variables into include files. (after-thought, Sorry for the drawn out post but I really, really need help....;) Here's what I'm doing.. ...
12
by: mr_burns | last post by:
hi, i have recently used a system (oscommerce store) where you can backup your database. what happens is that when you click 'backup database', it creates an SQL string, stores it in a text file...
2
by: Claire | last post by:
hi, i use vars() or dir() to get variables. I use them in a def block, so i get variables of that block. How can i get variables from the namespace __main__ ? I use python in interactive mode and...
20
by: svend | last post by:
I'm messing with some code here... Lets say I have this array: a1 = ; And I apply slice(0) on it, to create a copy: a2 = a1.slice(0); But this isn't a true copy. If I go a1 = 42, and then...
3
by: Greg Horwood | last post by:
Dear Anyone, While most of you will laugh at the fundamental nature of my question, I am a bit stuck. I am a reasonable VC++ programmer trying to make the switch to C#. I am trying to create a...
3
by: Jon | last post by:
I have a couple of tables I want to load into a dataset and keep around pretty much forever, although they will need to be refreshed every so often. I can either put the dataset into an...
4
by: deadlyicon | last post by:
So I wanted an object to have a reference to a string in side of an array some where else and so here is how I made that possible: <div id="something"> </div> <script> var obj =...
6
by: Chris Carlen | last post by:
Hi: I have an embedded system, platform: TI TMS320F2812 32-bit integer DSP. A module (.c file) contains external (to the funcs in that module) variables which are used to affect the operation...
6
by: goodguyjam | last post by:
Hi all, I'm having trouble with mysql. I've just finished my php coding for HTTP authentication and with some help am now getting a login window pop up whenever I click on a link on my website...
5
by: Ross | last post by:
Forgive my newbieness - I want to refer to some variables and indirectly alter them. Not sure if this is as easy in Python as it is in C. Say I have three vars: oats, corn, barley I add them...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.