56
votes
6answers
98k views

PHP/MYSQL using an array in WHERE clause

given an array $galleries = array ( [0] => 1 [1] => 2 [2] => 5 ) I want to have a sql query that uses the values of the array in its ...
5
votes
5answers
3k views

I have an array of integers, how do I use each one in a mysql query (in php)?

I have an array full of random content item ids. I need to run a mysql query (id in the array goes in the WHERE clause), using each ID that's in the array, in the order that they appear in the said ...
26
votes
12answers
34k views

Save PHP array to MySQL?

What is a good way to save an array of data to a single mysql field? Also once I query for that array in the mysql table, what is a good way to get it back into array form? Is serialize and ...
4
votes
4answers
18k views

Why do I get “Resource id #4” when I apply print_r() to an array in PHP? [duplicate]

Possible Duplicate: How do i “echo” a “Resource id #6” from a MySql response in PHP? Below is the code: $result=mysql_query("select * from choices where a_id='$taskid'")or ...
0
votes
2answers
3k views

mysql fetch array if no results display message

I am trying to get a database call to show a statement saying no results found if there are no results returned. How would I go about doing this to my code:- $getFixtures = mysql_query("SELECT ...
0
votes
4answers
4k views

MySQL query using an array

I'm trying to query a MySQL database using an array but I'm having trouble! I have a table called clients, I want to be able to select 'name' from all rows whose 'sector' column is equal to ...
10
votes
4answers
4k views

BLOB vs. VARCHAR for storing arrays in a MySQL table

I've got a design decision to make and am looking for some best practice advice. I have a java program which needs to store a large number (few hundred a day) of floating point arrays in a MySQL ...
5
votes
3answers
2k views

mysql_fetch_array, mysql_fetch_assoc, mysql_fetch_object

The functions are all very similar: mysql_fetch_array(), mysql_fetch_assoc(), mysql_fetch_object() I have recently started using mysql_fetch_object as I am doing alot more OOP with PHP. But what ...
0
votes
4answers
2k views

PHP/MySQL - an array filter for bots

I'm making a hit counter. I have a database and I store the IP and $_SERVER['HTTP_USER_AGENT']; of the visitors. Now I need to add a filter, so I can put away the hits, that are made by bots. I found ...
3
votes
5answers
17k views

PHP/MySQL - building a nav menu hierarchy

So the final menu will look something like this: Item B Item B-1 Item B-1-2 Item B-1-1 Item A SubItem A-1 SubItem A-2 Item C Based on the following DB records: id ...
0
votes
3answers
2k views

PHP - reformat multidimensional array to insert into MYSQL?

how can I parse php array like this: $cars= array( ...
3
votes
3answers
606 views

An efficient way to save an Array and its Keys to a database

I am trying to save lots of variables to a database and its getting ridiculous now. I am using PHP and MySQL. Is there a way, I can get the array value and the array keys (array keys are exactly ...
0
votes
3answers
2k views

Codeigniter Select_Sum returns “array” not numerical value?

I needed to add up all the rows for a result. Using the select_sum as follows Here is the model function Dues_Paid_Tot($date) { $query = $this->db->select_sum('Dues_Paid', ...
15
votes
9answers
13k views

Mysql results in PHP - arrays or objects?

Been using PHP/MySQL for a little while now, and I'm wondering if there are any specific advantages (performance or otherwise) to using mysql_fetch_object() vs mysql_fetch_assoc() / ...
8
votes
2answers
8k 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 ...

1 2 3 4 5 9
15 30 50 per page