Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    PHP


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Store Mysql Results Into An Array


i just started using php. i've used it before as a maintainer. fun stuff. well now i'm the writer. i want to abstract all the DB commands away from myself and all other developers. so i'm writing a function to query the php database from all users of the database and store them into an array as a return value so that i can seperate my database code from my html creation code.

1. is there a way to put all my database functions into a php file and include that file into all my other php pages? similiarly to a #include in C++ or a import package name in Java?

2. my code to run down the fetched results and store them into an array doesn't seem to be working the way i want it to. if i print out the results from the mysql returned fetch the data is fine. however the array seems to print out "Array[elementnumber]" instead of the value. Code:




View Complete Forum Thread with Replies

Related Forum Messages:
Take All The Results From A Query And Store Them In An Array
trying to get my head around arrays, and I want to take all the results from a query and store them in an array so that I can use them  for later use: Code:

View Replies !
Can I Store An Array In MySQL?
I would like to store an array in a MySQL table. The values will be numeric and ranging from 1-999. I'm not sure if this is possible, and if it is then I'm not sure on the correct field type to use.

View Replies !
Populating Array With Mysql Results
I'm returning a result set of one field in a table, and want to populate an array with the results. I can't for the life of me figure out a simple way to do this without using mysql_fetch_array() to cycle through the results, append that to a var, then explode that into a var and pass that. PHP Code:

View Replies !
MySQL Results Array Not Same As Query In DB
I am running a query in a MySQL database, and the results I am getting in my array do not match the results from running the exact same SQL in MySQL. Code:

View Replies !
How To Loop The Mysql Results Into An Associative Array
i am working on a script that write mysql results to excel file. I got a class that handle MSExcel Stream, but the only problem is I dont know how to loop the mysql results into an associative array like what the script do in the example. Code:

View Replies !
Building An Array With Mysql Results, Then Parsing Them
I'm trying to set up a word censor for a script I'm working on. Code:

View Replies !
Pushing Data Into A Multi-dimensional Array From Mysql Results
First, A result array I'd want to get could look like this:

$chart['chart_data'] = array (
array ( "Region A", 10,12,11,15,20,22,21,25,31,32,),
);

The first is "Region A" and the rest is just int's that I'd pull from the db, so to set it I'd do this:

$chart [ 'chart_data' ][ 0 ][ 0 ] = "Region A";

But the problem is when I want to insert the data in the while loop (like the 10,12,11,15...), I've tried array_push but it's not working, maybe it doesn't work with multi-dimensional arrays? Anyways, here.'s what I tried, the following inside the "while" to loop the mysql results with mysql_fetch_assoc:

while($r=mysql_fetch_assoc($res)) {
   
     $chart [ 'chart_data' ][ 0 ][ 0 ] = array_push($chart['chart_data'][0][0], $r['wght']);
     // the above line is where I have problems    ^^
}

What I want is on each loop to insert the fetched data inside the array so that it gives what I gave first at the top, but what I've written above doesn't work, it gives me a warning saying "first argument must be an array" which seems to be one, but anyway, anybody know how to do this?

View Replies !
Store Values In An Array
$a=10;
$a=15;

while ($a <= $b)
{
$a++;
}

The output is 10,11,12,13,14,15

How to store the values of $a(10,11,12,13,14,15) in an sigle array.

View Replies !
Store Classes In An Array?
Is it possible to store classes in an array? I am fairly new to PHP,
and haven't found anything either way yet.
I have a program that where you can have multiple notes attached to a
ticket, which are stored in a database. I would like to just pull all
the notes from the database, storing each one in a seperate class,
which itself is stored in an array (well, another class, but it's a
classList, it's mainly an array).
I'm getting an error when I run the page:
"Cannot use a scalar value as an array", and "Call to a member function
on a non-object". The second is related to the first, as I'm calling a
function on the array value.
If it is possible, I probably coded something wrong. If that's the
case, I'll post some code.

View Replies !
Get Data From The Db And Store It In An Array
I want to have an input field in my Admin CP when you are creating a Forum where you can input a list of numbers (member ids) seperated by commars, like this:

Quote1,6,4,8,2
These will be the ids of people who can moderate the Forum and will be stored in the db along with all the other stuff like forum name/description etc.

That's easy enough.

Now my problem is I need to get that from the db and store it in an array... basically so I can do something like:

<?php
if(in_array($_SESSION['mem_id'], $forum_moderator_array)) {
    echo('Congratulations, you are a forum moderator.');
}
?>

How can I go about doing this?

View Replies !
Store A Array As A Variable
is there any way that i can store a array as a variable because i dont want to creat a database for thousands of variables. heres what i thought of so far

<?PHP
$arrayval = "1,3,2,7,4,6,8,15,12,78,96,1203,1029,39509,12999";
$array = array($arrayval);
echo $array[1],$array[3],$array[2],$array[5],$array[6],$array[4],$array[7],$array[9],$array[5],$array[10],$array[13];
echo "<hr>";
echo $arrayval;
echo "<hr>";
$sum = $array[1]+$array[3]+$array[2]+$array[5]+$array[6]+$array[4]+$array[7]+$array[9]+$array[5]+$array[10]+$array[13];
echo $sum;
?>

View Replies !
Store Array In Session
i store my shopping carts items in an array in a session like this Code:

View Replies !
What's The Best Way To Store An Array In The Database
I am trying to build a simple tree menu where the main items can be either a link or open up a subList of items which themselves can belinks or open into more submenus and so on.
An example is:

$ar = array(
'new_user' => 'newuser.php',
'tst1' => array(
'subtst' => 'subtstlink.php',
'subtst2' => 'sublink2.php'
),
'heyhey' => 'heyhey.php',
);

I am wondering what is the best way to store that in a mysql database (Both the item name and the link to it). Is there any php function that will allow me to make such an array into some sort of variable (String?) which can then be read easilly and made back into the array for manipulation and creation of the tree menu?

View Replies !
How To Store Array In Cookies?
I try to store array in cookie this way:

for($i=0;$i<5;$i++)
{
    $field[]='test'.$i;
}
$_COOKIE['field2']=$field;

Is it possible do it that way? I don't want to store each value of array list store separately. I'd like to store them at once. If I was storing values just to another "normal" variable (not cookie), I would do it this way: Code:

View Replies !
How Do You Store An Sql Result In A Php Array?
How do you store an sql result in a php array? The array will hold, the following fields; itemid, itemname and itemdesc. I would then require, depending on the user selection to query the array by itmeid, and return the itemname.

View Replies !
Store Variable In An Array
so i have a query that returns a bunch of rows.... i display the contents of the query into a table... one of the variables that the query returns is $title....

after each row is returned im wanting to store the $title variable into an array, so i can then access that array later... here is my code for storing $title into the array Code:

View Replies !
Store An Array In A Text Document
I want to store an array in a text document. what I've been doing so far looks like this:

fputs( $myFile, $myArray );

but all it does is write the word "Array", instead of the actual array. I'm new to php and I've done my best to search the manual and numerous web resources (including this forum) for an answer, so please don't flame.

View Replies !
How To Store Checkbox Values To An Array?
I need to allow the user to select multiple mysql records via an html form checkbox.  On submission of the form I would like to store these values in an array for either multiple record deletion or creating a list of records. Code:

View Replies !
Four Fields That Are Dates, Store As An Array
I have a form that has over 100 fields. I have four fields that are dates that I would like to store as an array. When I submit the form I place the dates in the array like so:

$planworkdate = array("mon" => $planworkdate0,"tue" =>$planworkdate1,"wed" =>$planworkdate2,"thu" =>$planworkdate3);

and insert into mysql database. When I try to retrieve the data I get the word Array for the result. What am I doing wrong?

$query = "SELECT planworkdate from general";
$resultall = mysql_query($query);
$planworkdate=mysql_result($resultall,$x,"planworkdate");

print $planworkdate; ...

View Replies !
Store Form Fields To An Array
i have a form which consists of several fields for name, address, number etc. i use a php form to process this and output it onto a html form. the thing is, i'd like to store the information in an array. so for each user, the array will have their details. and this can be printed on the screen. can you tell me how this is possible. i have seen examples of arrays, but the values are assigned to the variables already.

View Replies !
Store The Entire Table In A Two Dimensional Array
I am reading info from a tab-delimited text file and I was wondering if anyone knew how to get this concept to work. I am trying to store the entire table in a two dimensional array, but the way I'm doing it right now won't work.

for($i=0; $i<$numrows; $i++)
{$columnsvalue[i] = explode(" ",$newfile[i]);}

does anyone else know how to better work with multi-dimensional arrays?

View Replies !
Mysql_fetch_array Way To Pull Out All The Data, Store It In An Array
I have a webpage which runs repetitive queries agaist a database in order to extract one item at a time and then put the items in an HTML table. The reason for this is formatting, plus the page hits 4 databases.

Instead of running multiple queries pulling one item at a time...is there a way to pull out all the data, store it in an array, and then pull individual items from the array with php as I want to insert them in the table? So, example is Code:

View Replies !
Variables To Store (Name,Species,Sex) Inside An Array
In PHP, is there anyway of using variables to store each piece of information (Name,Species,Sex) inside an array. Then, when it comes to fetching the information, the array position (e.g. 0) is called along with the information type (Name etc). A bit like the following: record(1).name The information is coming from the record array, at position 1 displaying names.

View Replies !
Store While Statment Data In Array Using Session And Retrieve?
I wish to store retreve value from my sql using session array and retrieve this value.
here is my while statement, which is displaying records from my database. I want to store all this value in an array using session and than retrieve this value on click of the table row. Code:

View Replies !
Array Problem - Extract And Store In Seprate Variables .
I have an array from a program of the type $list_box_contents[$row][$col]['text'];
 There are 3 columns  and an indefinite no. of rows.

Each array element contains a few bits of information. I want to to extract this and store in seprate variables .

$list_box_contents[$row][2]['text']; has 2 bits of information, a price and a small text box with some text. How can extract the price data from this .

View Replies !
Store The Selected Checkbox Values In A Variable Or An Array?
how to store the selected checkbox values in a variable or an array?

View Replies !
Array Problem... - Store This List In $_SESSION['liste'];
the user selects 6 numbers in a list I have to store this list in $_SESSION['liste']; (I cant do it differently) the list is stored like that: 34-21-44-32-12-11 (cant do it differently either)

what I need to do is to explode the array, get rid of the - , sort the values in ascending order and send them to my table as a string. so in the end I should have: 111221323444

I tried using a variation of laserlight's script (given in a previous post) without success... hope that someone will have time to give me a hand again in telling me what I could change in saberlights script to make it work.

View Replies !
Explode - Open File Store The Numbers In An Array
I have a .txt file looking like this

3
4
56
23
59
10

i want PHP to open that file and store the numbers in an array something like this

$q = "3,4,56,59,10"

Now i want to read $q and see if it contains 56 and 10 (it does) Code:

View Replies !
Sorting Sql Results In An Array Using Things Outside The Array To Sort Them?
I'm using PHP to connect to a database full of place names, and their associated post codes, latitude and longitude on the earth. A user types his or her post code into a form, plus a distance (in miles), and the script looks for other area codes (first half of the post code) within that distance.

I can do that fine, but the results are ordered alphabetically by postcode, and I want to order it by the distance. Problem here, is that the distance isn't part of the array taken from the database, it takes the latitude and longitude of the area it's on in the while loop, and calculates the distance between the user's post code and that one, but it's not part of the array, so I can't sort the array using it.

How can I sort it? Can I add the calculated distances to the array, and sort it using sort()? If yes, how do I add them to the array?

Here's the page, just to explain better what the script does: http://navimaker.org/ed/owain/results.php?postcode=gl15&distance=34
Mess around with the postcode and distance vars.

I'd put the source on here too but I'm doing all this over SSH and can't copy & paste very easily .

View Replies !
MySQL Store
Does anyone have a link to a good tutorial for a PHP/MySQL store that uses PayPal?

View Replies !
Store Password In A MySQL DB
Im doing a site in PHP3 and MYSQL. this site has a customers area. The question are:

Which is the best way to store the pass in the database but encrypted? Should i use md5 or does anyone knows a better script to encrypt the pass.

View Replies !
Store Images Into Mysql?
i'm wondering is it possible to store image (jpg) into mysql? (not talking about url of image, just image)

View Replies !
Store In MySQL Or Files
I'm creating a page which downloads some data from some other websites
and then processes it. I was wondering if it was better practice to
store the data in SQL Blob fields or temporary files.
For a rough approximation we're talking about approximately 10,000 15kb
files.

View Replies !
Store Images In MySql?
I am working on a CMS for small web site, I am using 2 images in the product template (banner / thumb nail). Can i store image in a database? or Should i just mention the 'path"?

View Replies !
Store And Retrieve In/from MySql Using Php
Can anyone give me a script which can store information using a form (about 10 fields) into a database and then show the result in another page. This is for a survey. I just need a simple script which can store and retrieve.

View Replies !
Store The BB Code In Mysql
When using BBcode in things like private messages, or comments. is it better to store the BB code in mysql, and then when the private note is read, replace all the BBcode with html? or is it better to convert all the bbcode to html and then store that in the database?

View Replies !
Store The Image Into The MySQL.
is there any tutorial/coding/free tools available in the internet to help me develop my website.basically i want to make user can upload their image but i want to store the image into the mySQL.

View Replies !
Store SESSIONID Into MYSQL
Id like to store for statistic purposes the SESSIONID into a stat table in MySQL. I know the session id is a 32 chars string, so i shoul duse a varchar(32) column type. Do you know if it is possible to save this in some different way. eg HEX number to save space on mydatabase?

View Replies !
Store An Image In A Mysql DB
Can You store an image in a Mysql DB and if so is it worth it?

View Replies !
Best Way To Store Info In MySQL
I'm creating a site where members can create their own photo galleries, and I'm going to use mysql to organize the photos.

What's the best way to store the photo gallery information in the database? Should I create one table per user's gallery (many tables, each with a few rows),

or should I create a single table where all of the photo records will be stored stored, with a column linking each photo to a user (one table with lots of rows)? What's the best way to do this? Does it even make a difference?

View Replies !
Store Sessions In MySQL Database.
I would like to use the PHP session feature, but instead of storing the session data in a file, I would like it to save it in a MySQL database. Is this possible?

View Replies !
How To Store An Image In Mysql Database
How to store an image(gif or jpg files) in mysql database?
Can u give me the code for that??

View Replies !
Uploading Images, Store It In MySql
Im a beginner in PHP and need help in:
- uploading images, store it in MySql, and how to display it on the page.
- categorized the products (ie. guitar, drums, etc.)

Basically, I have a table named "cms_products" with fields prd_title,
prd_description, prd_img, prd_id, prd_price, prd_stock, prd_category

Im not sure if Im going to make another table for the category and image.
Your help is very much appreciated.....

View Replies !
Store/display Images To/from Mysql Using Jsp?
I was looking for a solution on how to store images and display them from Mysql database using jsp or servlet.

View Replies !
Use PHP And Store The Messages In A MySQL Dataqbase.
Im trying to create a forum on my website. I use PHP and store the
messages in a mySQL dataqbase. Messages can be entered in a textarea.
What should i do to prevent that user enter code (javascript or php or
mysql or ...) that can be executed when i show a message with html? Is
it enough to use htmlspecialchar()?
Any tips?



View Replies !
Store Image Path In Mysql
I was wondering if anyone could tell me how to go about uploading an image in php (i know the form code ok) it's just when it comes to storing the path into mysql database ...

View Replies !
Store Tamil Font In To Mysql
i want to store tamil font in to mysql. i know how to store. but  when i send data to mysql then it automatigaly changed the datas. how i stored other language datas.

View Replies !
Store Image Location In Mysql
I'm looking for a solid way to store an image location in mysql. I've been throwing different ideas around all day and nothing is striking me.

I'd like to be able to view the image again later so saving the full path is troublesome and I definitely don't want to save the full url - better if it's all in variables for when I switch servers.

What are some good ways (or a standard way?) to do this? Hope this makes some sense.

View Replies !
Store The Mysql Unique ID Using The $_SESSION?
Is it safe to store the mysql unique ID using the $_SESSION? Also, how can I destroy a session once the user Click X cancel on the top right hand corner of explorer? I meant I dont want to destroy session while the user is on my page doing their work. I want to destroy the session only when they click that red X cancel.

View Replies !
Automated Store Txt File In MySQL
Is there an effeceint way to store a txt or html file into a table and update once every hour or half hour, the file is only a small document and is accessed by a URL.

View Replies !
Store Encrypted Passwords In A Mysql Table.
i want to store encrypted passwords in a mysql table. what is a good recommendation on how to encrypt them. currently i'm using the mysql password() function, but i'm running into problems with spaces.

if a username=test
and password=joe

it still allows password=' j o e '

with any amount of spaces ANYWHERE in the password as long as the string has the correct password text ....i.e. the j, the o, and the e in the correct order.

wtf is up with that? what the hell is the point of the password() function, if it doesn't care about spaces? am i missing something here? if i am, i would love to be helped out, otherwise i'm going to have to use a php encryption method instead of mysql.

View Replies !
Encrypt Passwords To Store In A MySQL Database
I need to encrypt passwords to store in a MySQL database, can anyone please help. It doesnt matter where the encryption occurs (MySQL or the PHP script), but I need to do it! Any examples of code, or helpw ill be great.

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved