Jump to content

convert chart to an array


jasonc

Recommended Posts

I wish to access the following chart by the number and the headings names.

 

field text mysqlfield

1 username Please enter a username un

2 name Please enter you name nm

3 age Please enter your age ag

4 town What town do you live in tw

5 postcode What is your postcode pc

 

I place the field and the text in to a form and use the mysqlfield to placce the data in the mysql database.

 

what i do not know is how to store the array data and how to access it.

Link to comment
Share on other sites

ok been playing around with stuff from php.net site.

 

this is what i have, but how do i get the number 1,2,3,4,5 ?

 

$array = array(
	'1'=>	array('fieldtext'=>'option1', 'mysqlfield'=>'mysql1'),
	'2'=>	array('fieldtext'=>'option2', 'mysqlfield'=>'mysql2'),
	'3'=>	array('fieldtext'=>'option3', 'mysqlfield'=>'mysql3'),
	'4'=>	array('fieldtext'=>'option4', 'mysqlfield'=>'mysql4'),
	);

foreach ($array as $options) {
		foreach ($options as $key => $value) {
		echo("number = [". $number . "]	-	key = [". $key . "]	-	value = [". $value . "]<br>");
		}
		?><br><br><?
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.