I am planning to code a project status monitor, the idea in matrix is like below
require1 require2 require3
task1 1 2 0
task2 1 0 2
task3 0 1 1
task4 1 0 0
eg. when there is a new project, task1,2,3... should be included, and the requirement 1,2,3... is need to complete for the correspondent task, the letter 0,1,2 to represent that if 1 record in require1 and 2 in require2 and 0 in require3 means the task1 is completed.
my question is that, should I put this matrix into a database then using it to join the record table (concerning the speed if in mass of record), or can I use an array to implement in simply way ?
Please help to suggest and let me know how to use array!
Thank you.
Related
I am thinking to arrange office room.
Office room is always noisy, and you are thinking to separate each room users as possible as you
can so that they don’t feel uncomfortable.
If they are facing each other, we will add unhappy point as 1.
INPUT
What we can do here is based on given rooms and users, arrange room separately so people don’t
feel uncomfortable.
[row, column, users] -> unhappy points
Example 1: [2, 3, 6]
*2 Rows, 3 Columns, 6 people
Example 2: [3, 3, 8]
*3 Rows, 3 Columns, 8 people
Sample Output
]
Following are some Test Cases :
[5,2,8]-> 7
[3,5,14]-> 18
[1,16,1]-> 0
[3,5,1]-> 0
[8,2,12]-> 10
[16,1,1]-> 0
[3,3,6]-> 3
[2,6,12]-> 16
[15,1,0]-> 0
[5,3,7]-> 0
[4,3,5]-> 0
I need either mathematical solution or programming solution in PHP.
This is not a complete question because how will you determine that two rooms are facing each other and one more thing is that how are you counting 7 unhappy points for first example.
I've observes that if you are taking a matrix lets say 4 by 5 than you can put 4*5=20 peoples there.So how will you count more than 20 points while we have only 20 people?
I realy need help to make this work coz i dont know how sorting works and i am begginer in this field guys.
I have table like this:
jobs - hours - user
I am trying to sort and output table like this:
Find all jobs that exist in table horizontal
and then, in vertical menu show all users with hours (if exist) on all jobs add 0 if not
joob 1 - joob2 - joob 3 - joob 4
mark 0 3 1 0
benny 7 5 0 0
john 0 0 0 3
How do i query and sort like this output as html ?
I know latter to group and calculate but this i am having problem with.
I have 2 million rows in a myqsl DB which have multiple columns of contacts as phone_1, phone_2 upto phone_10.
These phone no. may or may not duplicate.
I intend to group them together..as
ID Contact_1 Contact_2 Contact_3
P1 1 2 3
P2 5 6 7
P3 2 8 9
result should be:
ID Contact_1 Contact_2 Contact_3 Group
P1 1 2 3 1
P2 5 6 7 2
P3 2 8 9 1
P3 11 12 13 3
P3 7 21 22 2
Now where should I do the processing part ...PHP/Python or mysql.
i.e. select the entire data in php script and create an arrray and process tha array and then use insert query.
OR
select the entire data in php script and then use UPDATE(with a logic to create groups) query.
??
I have group field in DB table.
It depends, I'd say mostly on how comfortable you are with each language. I would probably do this with PHP, but that's the language I know best.
You can certainly do it purely with MySql, and the operation would probably run faster, but it might be easier to debug and test each step in PHP or Python.
Regardless, I'd recommend first creating a data subset, maybe 1000 or 2000 rows from the table and running everything against that until you're happy with the results. It'll be much much faster and you'll see mistakes sooner.
Also, I'd avoid running anything you're worried about being slow on a production server.
I have searched all over the internet and I have had no luck in finding the answer to my question. I hope this has not specifically been posted yet, but if you can point to where i can find the answer I would appreciate it.
I have set up a site that I am building into a fantasy golf site. I am using GravityForms as my form plugin. I have all the other features I want set, set up and need help with this last thing.
id lead_id form_id field_number value
1 1 1 1 Hosker
2 1 1 7 b**********#yahoo.com
3 1 1 6 Hyundai Tournament of Champions
4 1 1 3 Adam Scott
5 1 1 4 Harris English
6 1 1 5 2014-01-02 23:59:47
7 1 1 8 5b409692-e9ed-486e-8d77-7d734f1e023d
This is what my form submission gets posted as in the database. I would like to be able to take all of the data from this form and do an sql query and put it all in one row. Is that possible? The two columns that I will need to build my query around would be from lead_id and value where the value that I will be basing the query on is in row 7. The only value that I will know is in row 7. Thanks in advance for your help.
This is the result I am looking for
id lead_id form_id field_number value value value value value value value
1 1 1 1 Hosker b**********#yahoo.com Hyundai Tournament of Champions Adam Scott Harris English 2014-01-02 23:59:47 5b409692-e9ed-486e-8d77-7d734f1e023d
I would hook into the gravityform submission action and then perform whatever logic is required at that point to do the insert into the database.
add_action("gform_after_submission", "on_gform_submit");
Then create a function to accept the entry as an argument.
function on_gform_submit($entry){
}
Inside of this function $entry is an array that has the ID of each field (as per the back end) as the key. So if for instance message had an ID of 10, then it would be
$message = $entry['10'];
Then when you're done, simply input the data using a standard SQL Insert statement
Given a table like the one below, what would be the best way to detect the two columns separately?
So what I would need the total colspans for the first column.
What is important to remember is that the nr of columns can change.
In the case of this example, the second column starts at "10 euro" (second row). The first section is equal to 2 colspans. The other section is 5 colspans.
Any (abstract) ideas on how to do this?
You must consider the gaps in between the table cells and mark their positions, like this::
0 1 2 3 4 7
0 2 3 4 5 6 7
0 1 2 4 5 7
...
0 2 7
Once you have built an array with above information, you iterate over them and mark the common gap locations:
0 2 7
Since 0 and 7 are both at the edges of your table, you can strip those off. Then you're left with position 2 as the common gap between your rows.
Done :)