Jump to content

Recommended Posts

I looking for a good tutorial that will cover arrays, from HTML forms to storing the data( serialize,unserialize, implode, explode)in mysql with php

 

I need to create a from that will allow me to create an array from text field then submit to database

and late allow me to editied and update that array

 

So I have four basic tables one serving as main table that will hold 5 field of data plus three field set aside for arrays then I have 3 tables that will hold keys and reference for those array plus additional data

 

objective :

In my main table the fields array1 array2 and array3 are the one I need to insert the array data into.

I need to be able to manipulate the data of the array completely from an HTML form or multiple forms create basic HTML forms and PHP code to process

I must be able to pull a record, check to see if that is an in those field array then add some data if their is if not start a new array for that record create basic HTML forms and PHP code to process

I must be able to view and delete part of the array as well create basic HTML forms and PHP code to process

 

then pull a record that has array data in it, then create a query base on those array to pull data from other tables and create some basic calculation base on the original record and the data that you reference in the other tables ( tables array1 array2 and array3 )create basic HTML forms and PHP code to process

To help paint you better picture I am attaching below some sample tables and data

I know that the data is not optimize but that is on purpose

 

ok let say that this is( id) 2 in main

 

2 11 12 12 15 18 ('MOPQY4IV','9QR4TH7K','NZ1O45B0','1XUUU5D4','J94RVSNY')NULL NULL

 

this array would be reference in table array1

'MOPQY4IV','9QR4TH7K','NZ1O45B0','1XUUU5D4','J94RVSNY'

 

So in PHP I need to create a for loop that would take the value of this array and pull the data from table array1

 

I don't think the foreign key would work as this is not normalize database since other (id) in main could reference the same keys in array1

so I believe it be a many to many relation

 

(id)3 could look some like this

3 10 16 12 17 14 ('MOPQY4IV','9QR4TH7K','JAM39TXN',)NULL NULL

some of the array value are the same as in (id) 2

 

 

Thank You

 

Antonio

 

 

 

CREATE TABLE IF NOT EXISTS `array1` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`arrayKey` varchar( NOT NULL,
`data1` int(11) NOT NULL,
`data2` int(11) NOT NULL,
`data3` int(11) NOT NULL,
`data4` int(11) NOT NULL,
`data5` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=14 ;
--
-- Dumping data for table `array1`
--
INSERT INTO `array1` (`id`, `arrayKey`, `data1`, `data2`, `data3`, `data4`, `data5`) VALUES
(1, 'MOPQY4IV', 0, 1, 0, 3, 2),
(2, '9QR4TH7K', 2, 2, 0, 0, 2),
(3, '8NBYRZ72', 2, 1, 3, 3, 3),
(4, 'NZ1O45B0', 0, 2, 2, 3, 2),
(5, 'Y7XPA7Q3', 0, 0, 1, 1, 2),
(6, '1XUUU5D4', 1, 3, 2, 1, 2),
(7, 'JVUI1KA6', 2, 1, 3, 3, 1),
(8, 'J94RVSNY', 3, 2, 3, 1, 1),
(9, 'NF9YSEF4', 2, 3, 0, 1, 3),
(10, 'LFY81TBA', 1, 1, 1, 3, 1),
(11, 'LZH9S2DE', 0, 3, 2, 0, 1),
(12, '7XK4NF8M', 3, 1, 1, 2, 0),
(13, 'JAM39TXN', 0, 0, 2, 2, 1);
-- --------------------------------------------------------
--
-- Table structure for table `array2`
--
CREATE TABLE IF NOT EXISTS `array2` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`arrayKey` varchar( NOT NULL,
`data1` int(11) NOT NULL,
`data2` int(11) NOT NULL,
`data3` int(11) NOT NULL,
`data4` int(11) NOT NULL,
`data5` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=14 ;
--
-- Dumping data for table `array2`
--
INSERT INTO `array2` (`id`, `arrayKey`, `data1`, `data2`, `data3`, `data4`, `data5`) VALUES
(1, 'BZGZX887', 1, 0, 0, 0, 3),
(2, 'WW7JG2WI', 3, 1, 0, 2, 0),
(3, 'U1UAK4Z7', 0, 2, 2, 3, 0),
(4, 'L1ETC8VM', 1, 3, 3, 3, 3),
(5, 'RYPO75Y6', 3, 3, 0, 1, 0),
(6, 'O9XKS4B0', 2, 2, 2, 2, 0),
(7, 'A1W8VD5M', 1, 1, 0, 3, 3),
(8, '4EH4IUBF', 1, 3, 3, 2, 0),
(9, '2YV7VJML', 0, 2, 0, 1, 1),
(10, '1V9TPRT8', 1, 2, 3, 3, 1),
(11, '6XC0QJPB', 1, 2, 2, 3, 3),
(12, 'JWX4SG1M', 2, 2, 3, 1, 0),
(13, '60UBRIB2', 0, 0, 2, 2, 0);
-- --------------------------------------------------------
--
-- Table structure for table `array3`
--
CREATE TABLE IF NOT EXISTS `array3` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`arrayKey` varchar( NOT NULL,
`data1` int(11) NOT NULL,
`data2` int(11) NOT NULL,
`data3` int(11) NOT NULL,
`data4` int(11) NOT NULL,
`data5` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=14 ;
--
-- Dumping data for table `array3`
--
INSERT INTO `array3` (`id`, `arrayKey`, `data1`, `data2`, `data3`, `data4`, `data5`) VALUES
(1, 'XW2R8FZV', 0, 2, 0, 2, 1),
(2, 'U0UQ4XE0', 3, 3, 3, 2, 1),
(3, 'DJZ0F72P', 0, 2, 0, 2, 1),
(4, '58NZG2QT', 3, 0, 3, 1, 0),
(5, '8X0MTA7C', 3, 3, 1, 3, 0),
(6, '566JPHPO', 3, 1, 0, 2, 2),
(7, '59FE3PVA', 3, 0, 2, 3, 1),
(8, 'O87PI80J', 1, 2, 0, 3, 3),
(9, 'J69OP30N', 1, 2, 0, 2, 2),
(10, '4VCA5FA9', 2, 1, 1, 3, 3),
(11, 'N6I82WQS', 2, 0, 3, 0, 2),
(12, 'ZSNV3O7K', 0, 0, 2, 2, 3),
(13, 'YE6E4RB0', 2, 2, 3, 1, 0);
-- --------------------------------------------------------
--
-- Table structure for table `main`
--
CREATE TABLE IF NOT EXISTS `main` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`data1` int(11) NOT NULL,
`data2` int(11) NOT NULL,
`data3` int(11) NOT NULL,
`data4` int(11) NOT NULL,
`data5` int(11) NOT NULL,
`array1` text,
`array2` text,
`array3` text,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=17 ;
--
-- Dumping data for table `main`
--
INSERT INTO `main` (`id`, `data1`, `data2`, `data3`, `data4`, `data5`, `array1`, `array2`, `array3`) VALUES
(1, 10, 11, 15, 14, 16, NULL, NULL, NULL),
(2, 11, 12, 12, 15, 18, NULL, NULL, NULL),
(3, 10, 16, 12, 17, 14, NULL, NULL, NULL),
(4, 18, 10, 13, 16, 11, NULL, NULL, NULL),
(5, 11, 10, 13, 9, 15, NULL, NULL, NULL),
(6, 9, 18, 14, 17, 14, NULL, NULL, NULL),
(7, 14, 18, 16, 13, 17, NULL, NULL, NULL),
(8, 15, 16, 12, 17, 17, NULL, NULL, NULL),
(9, 17, 16, 12, 14, 10, NULL, NULL, NULL),
(10, 17, 14, 11, 9, 17, NULL, NULL, NULL),
(11, 12, 18, 10, 13, 13, NULL, NULL, NULL),
(12, 10, 12, 14, 14, 10, NULL, NULL, NULL),
(13, 14, 14, 12, 17, 18, NULL, NULL, NULL),
(14, 1, 1, 1, 1, 1, NULL, NULL, NULL),
(15, 22, 22, 22, 22, 22, NULL, NULL, NULL),
(16, 1, 1, 1, 1, 1, NULL, NULL, NULL);

Link to comment
https://forums.phpfreaks.com/topic/273571-html-form-to-php-arrays/
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.