Tagged Questions
13
votes
3answers
16k views
Php multi-dimensional array from mysql result
I have a mysql table that looks like this:
id | uid | title | description | parent
1 | 1 | Portraits | desc. | photostream
2 | 1 | Abstract | descr. | photostream
and I am ...
13
votes
1answer
422 views
Multi-dimensional array vs. multiple arrays
I need help with some PHP code. I am retrieving data from a MySQL database using left joins. Based on these records I am creating nested arrays which I want to be clean, e.g.:
array(
[0] = array(
...
7
votes
1answer
2k views
Hierarchy commenting system php
i want to do discus/reddit/ like commenting system, i have an "id_answer" (set to 0 by defaut) field in my comment database and when user answer to another comment this field is the "id" of the parent ...
7
votes
2answers
2k views
PHP Multidimensional array to unordered list, building up url path
I have a multidimensional array in PHP produced by the great examples of icio and ftrotter (I am use ftrotterrs array in arrays variant):
Turn database result into array
I have made this into a ...
5
votes
2answers
1k views
PHP - Create multidimensional array via a loop based on a count
Having some trouble coming up with the right combination of count and foreach for a multidimensional array.
I'm currently doing the following to create an associative array from my db's returned ...
4
votes
4answers
2k views
How do I retrieve results as multidimensional array from mySQL and PHP?
I'm just starting to learn more advanced SQL along with PHP and I'm really struggling trying to find out how to query my database for a quiz I'm building.
Ultimately, I'm trying to return a json ...
4
votes
6answers
2k views
Inserting a multi-dimensional php array into a mysql database
I have an array from a csv with a similar structure to this:
Array (
[0] => Array ( [0] => name [1] => age [2] => gender )
[1] => Array ( [0] => Ian [1] => 24 [2] => ...
4
votes
2answers
223 views
MySQL tables or PHP explode for business hours [closed]
I need to store business hours for 200+ unique businesses (and growing). Each business has varying hours and some are closed for lunch. In addition, a business might open at 8am one day and 9am on ...
4
votes
1answer
2k views
Unserialize from MySQL into a Multi-dimensional PHP array
I have a PHP/MySQL e-commerce site that is placing order detail information into a serialized array alongside customer address info.
I want to be able to pull out the order items field, unserialize ...
4
votes
2answers
2k views
Create PHP multidimension associative array from MySQL linked tables SELECT query
I'm hoping someone could help me with this problem.
Say I have 3 DB tables:
Users:
user_id, user_name
100, John
101, Jessica
Cars:
car_id, car_name
30, Corvette
31, BMW
UsersCars:
user_id, ...
4
votes
2answers
100 views
Is this an acceptable situation to store an array in a database?
I've been developing an application and I've run into a situation where I would like to take a snapshot of the current data.
For example, in this application, users will have varying stats and be ...
3
votes
2answers
706 views
Modify an array by reference
I receive from my MySQL database a multidimensional array
Array
(
[0] => Array
(
[page] => categorypropose
[value] => baby-sitters
[id] => 357960
)
[1] ...
3
votes
1answer
298 views
PHP multidimensional array + MySQLi $row array data
$category = array(
"Alpha",
"Beta",
"Gamma",
"Delta",
"Epsilon",
"Zeta"
);
for ($count = 0; $count < 5; $count++) {
$query = "SELECT * FROM random_walk WHERE category = ...
3
votes
2answers
296 views
PHP functions to parse multidimensional array?
I run a query andfetchAll()
$query = "SELECT uid, kill_count FROM users WHERE curmid=:mid AND status='1'";
...
$row = $stmt->fetchAll();
that returns this array:
Array (
[0] => Array ( ...
3
votes
3answers
64 views
Is there a better way to build my PHP array with search capabilities?
I operate a website which allows hundreds of clients to sell products online. When a customer visits one of my client's websites, they do so in the form
www.site.com?userid=12345
On the landing ...
3
votes
4answers
283 views
mysql return multi level array
I'm working with three MySQL tables that are related in a PHP application. There are tests which have many questions, and the questions have many answers. What I would like to do is loop through the ...
3
votes
1answer
298 views
php & mysql: most efficient method to check large array against database
I have a large set of data stored in a multi-dimensional array. An example structure is as below:
Array
(
[1] => Array
(
[0] => motomummy.com
[1] => 1921
...
3
votes
5answers
1k views
MySQL multidimensional arrays
What is the best way to store data that is dynamic in nature using MySQL? Let's say I have a table in which one item is "dynamic". For some entries I need to store one value, but for others it could ...
3
votes
1answer
844 views
Implementing a k-d tree for 'nearest neighbor' search in MYSQL?
I am designing an automated trading software for the foreign exchange market.
In a MYSQL database I have years of market data at five-minute intervals. I have 4 different metrics for this data ...
3
votes
6answers
1k views
Store multidimensional array values into MySQL (PHP)
I have a large multidimensional array that I would like to store into a MySQL database.
Below is an example of the array in question:
Array
(
[user1] =>
[name] => abc
...
...
2
votes
2answers
232 views
MySQL in() multidimensional array
the following works (array is filled in by another MySQL query):
$array=(1,4,5,6,8);
$query=SELECT * FROM table WHERE Id IN(".implode(",",$array)."
But how can I do the following?:
$array=(
...
2
votes
2answers
10k views
How to select multiple rows from mysql with one query and use them in php
I currently have a database like the picture below.
Where there is a query that selects the rows with number1 equaling 1. When using
mysql_fetch_assoc()
in php I am only given the first is ...
2
votes
3answers
79 views
create a workable array from existing array in php
I have trouble understanding arrays and I was wondering if someone could help me reformat an existing array in php.
This is the existing array:
Array
(
[item] => Array
(
[0] => item ...
2
votes
1answer
128 views
php echo records from array grouped by specific record
I have two tables:
ROOMS
room_id>>>room_name
1 foot massage
2 face massage
3 back massage
ORDERS
room_id >>>start_date>>>>>>>end_date>>>>>>>>price
1 2012.09.10 ...
2
votes
2answers
367 views
html form array for each update into mysql
I have been racking my brains trying to figure this out for days and have come up short. I am trying to update rows in the database with the following form value:
<input type="text" name="item[]" ...
2
votes
3answers
629 views
How do i create a 4 dimensional array from a database
I'm trying to figure out how to make this code work. Basically i have used MySQL to fetch an associative array containing multiple values.
example database: database name = Products
...
2
votes
2answers
153 views
finding data in MySQL using multidimensional array data
I've been trying to search this, but I keep finding solutions to problems "MySQL to Multi-dimensional arrays"
I have a multidimensional array, and I'd like to use values from the array to search ...
2
votes
1answer
394 views
Check if the values of two columns from two tables are equal then return
I have 2 tables as follow :
table1 has these fields:
year,day,month,name
table2 has these fields:
years,gift
I want to return the rows where year = years. the two queries NEED to be run ...
2
votes
1answer
80 views
Incrementing Multidimensional Hashes in Perl
As I iterate through the rows of a mysql table, there are 2 values in each table (x,y) that I need to see what interval those two values fall between.
For example if x=-21.1 and y=52.4, x would be ...
2
votes
2answers
599 views
PHP multi-dimensional array find duplicates in specific dimensions
I have the following array:
$masterlist=[$companies][$fieldsofcompany][0][$number]
The third dimension only exists if the field selected from $fieldsofcompany = position 2 which contains the ...
2
votes
2answers
335 views
Database to return multi-dimensional result
This is a follow-up question to my previous one.
Situation:
Table 1:
+--------------------+--------------------+
| v_id | v_name |
...
2
votes
2answers
93 views
MySQL PHP insert data from two rows into multidimensional array
I am trying to insert data into a multidimensional array from two tables in my database, but it does something that I don't really know how to fix.
First of all, here is my PHP script:
if ($stmt = ...
2
votes
2answers
722 views
PHP Subtract values in Array 1 from values Array 2
So I would like to subtract stocks from $array1 and quantity from $array2,
$array1= ([product_id]=>4, [stocks]=>20)
$array2= ([product_id]=>4, [quantity]=>3)
So that would be:
$array1= ...
2
votes
1answer
387 views
PHP parse YAML, store in DB for easy value modification, and return to original structure afterwards
I require the ability to store, modify and retrieve YAML data content in a MySQL database.
My project (and question) aims:
Parse .yml files into a PHP multi-dimensional array
Store these into a ...
2
votes
2answers
110 views
Getting sub items using sql?
I have three tables,
Entries, Tags, Entry_Tag_Link
I have my query which goes through and pulls everything out of the Entries table
SELECT *
FROM (`blog_entries`)
ORDER BY `date` desc
I end up ...
2
votes
2answers
759 views
inserting multidimensional array into mysql
i want to insert data from multidimensional array into mysql but while looping it loop more than necessary. i mean i want it to enter 6 records but i got many records. i knew i have problem with my ...
2
votes
2answers
88 views
How do i get this data in the proper format?
ok so i have this query
select ss.system_step_id, ss.step_number, cd.name, ssp.system_step_product_id, p.cost, ssp.class_id from system_step ss
join system as s on s.system_id=ss.system_id
...
2
votes
3answers
915 views
from multi dimensional array to mysql
I have a multidimensional array called $data that is basically data extracted from a table into the array.
This is how I get my array using JS_extractor:
set_include_path(get_include_path() . ...
2
votes
1answer
57 views
Build multidimensional array from mysql database using php
I have a theoretical question that I cannot seem to figure out. Imagine I have the following data in a database:
Main Sub1 Sub2
a x y
x t u
u f g
I want to ...
2
votes
1answer
89 views
PHP MySQL Menu Sorting
Ok, so here's my table structure:
+--------------------------+ +----------------+ +-------------------------------+
| pages | | menus | | menu_pages |
...
2
votes
1answer
49 views
Multidimensional PHP array stays empty
I'm trying to create a multidimensional array within a PHP function. But it doesn't seem to work. The function I wrote:
//Get newsitems
function getNews() {
$result = mysql_query("SELECT * FROM ...
2
votes
2answers
117 views
How would I create this array structure in an HTML form?
I have the following HTML form, which is being generated dynamically from a table in a MySQL database.
<form method="post" name="chapters" action="ChaptersUpdate.php">
<input type='text' ...
2
votes
2answers
626 views
How do I efficiently locate key-value pairs in a multi-dimensional PHP array?
I have an array in PHP as a result of the following query to a Wordpress database:
SELECT * FROM wp_postmeta WHERE post_id = :id
I am returned a multidimensional array that looks like this:
Array ...
2
votes
4answers
708 views
2
votes
2answers
215 views
Creating one big array from two different arrays by comparing values PHP
I have a MySQL table with reports. Fetching my reports is used by function:
function fillItByRoute($lat){
global $db;
$array = array(array());
$result = $db->query("SELECT * FROM reports WHERE ...
2
votes
1answer
835 views
Creating Multidimensional Nested Array from MySQL Result with Duplicate Values (PHP)
I currently am pulling menu data out of our database using the PDO fetchAll() function. Doing so puts each row of the query results into an array in the following structure:
Array (
[0] ...
2
votes
1answer
793 views
PHP Insert Multidimensional Array into mysql
i try to store the booking booths into database based on user selection, there are 10 check boxes for each booths and user can choose which day they want to reserve booths. For each check box has it ...
2
votes
3answers
2k views
building a multidimensional array from mysql with php
I am trying to form a specific multidimensional array from a mysql result set.
I would like it to look like this:
array(
'product_name' => 'prod_1',
'categories' => array(1,2,3,4)
);
The db ...
1
vote
5answers
77 views
replace a value in a multi dimention array- phap
I need to replace all the total values with the corresponding subtraction of start and end values. Values are come from a sql result
Any help how to do that?
For Ex :
12.30 - 5.00 = 7.30
15.30 - ...
1
vote
6answers
2k views
multidimensional PHP array or multiple queries to mysql DB
Hi there
I'm using the PHPExcel lib which it seems to do great jobs, but in my approach it doesn't seem to be so fast.
I need to generate a excel file with allot of sheets, data, formulas and ...