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.





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 Complete Forum Thread with Replies

Related Forum Messages:
Printing Out An Associative Array - Whats Wrong?
I have this code segment:

$query = "Select * from Payments order by CustID";
..
.. /* execute the query */
..
if (ora_exec($cursor))
{
$recordset=array();
while (ora_fetch_into($cursor,$recordset,ORA_FETCHINTO_N ULLS|
ORA_FETCHINTO_ASSOC))
{
echo $recordset["CustID"]."<BR>";
echo $recordset["Amount"]."<BR>";
}
}

Gives me the following error
Notice: Undefined index: CustID
Notice: Undefined index: Amount

The table Payments has only CustID and Amount as attributes. is my
usage of the array offset incorrect?

View Replies !
Whats The Most Efficient Way To Split An Associative Array At Defined Keys?
whats the most efficient way to split an associative array at defined keys? the main purpose of this is to delimit a $_POST request with key/value pairs that identify what form they belong to. Like: Code:

View Replies !
Create Value On The Fly, Or Store If SQL Database?
I have a value in a database of a car sale which could be $1,000.00 then I have another value in a database of a number of payments, then I create *on the fly* a value of amount per month. Should I store that in the database, or keep that *on the fly*..

What I mean by on the fly is. PHP Code:

View Replies !
Store Database Password
We have a dilemma. We are storing our database password in an include file that resides outside of the web root. The password is in plain text. So, no one can get that password because it can't be served up by the web server. So far, so good. The customer wants all of our passwords encrypted. So, how do I go about securely encrypting that password?

If I use mcrypt, I have to store a key and an IV somewhere. and if those are in clear text, I might as well just store the password in clear text. That is to say, I could encrypt the password with a given key and IV, and then hard code that key and IV into my app and put the encrypted password into the database. But, there's really no security in that. Has anyone else done anything like this?

View Replies !
Database Path Store
uploadforms.php - A form where you simply input a title, choose a file to upload, add a comment for the file, and select a catagory for the file. All of this info is then passed onto upload.php

upload.php - this takes the info from the forms puts it in a database, I know how to get all the text into the database, but how can i store the file location of the file in the DB (the location of the file on the server)? I cannot seem to get this, and I have been at it for weeks.

View Replies !
Store Space In Database
how can i store space in database to echo it later for example if the user press space many times between each word how can i store and get it back.

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 !
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 !
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 !
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 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 !
Secure Way To Store HTML In The Database?
to my understanding it is very unsafe to allow users to submit HTML from a form to the database.

What if I allowed the user to use HTML, but when they submitted it I would change all the >'s and <'s into backets [ and ].

So the user would type out:
<img src="image.jpg">
and it would be inserted into the database like this:
[img src="image.jpg"]
Would this be a secure way of doing it? Or is there a better way?

View Replies !
Store Currency Data Into An Sql Database
Might be mainly a bit of an sql question but here it is anyway. i want to store currency data into an sql database like $233.56 but if theres just $233.00 it only stores $233. Is there a way i can make it store the .00 aswell? Ive tried the function 'round(blabla, 2);' but if there isnt any .00 pulled from the db it just puts $233.

View Replies !
Read RSS Feed And Store In Database?
I'm trying to find out how easy/hard it would be to read a RSS feed and then place the data in MySQL Code:

View Replies !
How To Store Video Files In Database
i want to store video files(.mpeg,.mov etc) in mysql using php.

View Replies !
Get The Member Name From The Database And Store It Into A Variable $name.
I'm using a MySQL database with a table called members with columns - id, member name, etc. Say I want to get the member name from the database and store it into a variable $name. Can I do this without a loop? If so, how?

View Replies !
Store XML Data To Database Using SimpleXML
PHP and MySQL and trying to learn, but can somebody help me to store XML data into a database (MySQL) using PHP (and the example XML file at "http://php.net/simplexml"?)

View Replies !
When To Store Content In A Database Table?
When developing a website in general when should I choose to put
content in a database. For menu options, settings, and listings like
products it seems to be clear for me to put them in. But the main
content (article for example) should I put that in a page or in the
database.

More in general, when would it benefit to use a database and
when not. Does anyone know a good tutorial or do you have advice
concerning this.

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 !
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 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 !
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 !
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 !
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 !
How To Store Textarea With Special Tags In A Database
Special tags means, tags in a "[" "]", like "[legend]". Then i sumbit a form to a server, is i store it in a database this special tags or convert it to a html tags like (url)=>(a) before inserting, and then reediting it i make inverting html tags to a special tags (a)=>(url) (like in this forum).
In the other words i need to know, then phase of converting tags is happend, before inserting to a database or then it selected from database, before it showing to a user.

View Replies !
Session Variables To Store Database Field
On my site I allow users to log in. If the login is sussessful they are taken to a page saying welcome and their name is pulled from the database and displayed on screen. What I want to do is be able to store their name pulled from the database in a session variable if possible which I can then show there name on each page. Is this possible, im using MX to do so.

View Replies !
Redirect Page After Store The Data Into The Database?
How can I redirect this page after I store the data into the database?  Here is the entire script: Code:

View Replies !
Store Upload File Path (Database)
I have come up with the following code, that uploads gif images to the server. How do I allow only MP3 files to be uploaded, and also store the path of the image in a database? Code:

View Replies !
How To Store Image Path In Database & How To Retrieve?
KINDLY PROVIDE ME ASSISTANCE,I WOULD LIKE TO STORE IMAGES OF DIFFERENT PRODUCTS AND WANT TO RETRIVE THEM AND RESIZE IT.

View Replies !
Store Images Either In Database Or In Hard Disk
we have two options to store images, either in a Database (MySQL,Postgres, ...) like blob data, or in the hard disk the file and the path in database. Which option is better?

View Replies !
File On Server - Store Info In Database
I have a html form that allows a user to upload a file to the server. For each file that is uploaded, how do I store relevant information such as date uploaded, name, etc. in a database table? Here's my code so far:

$query = "INSERT INTO tbl values('".$fileName."', NOW())";
$result = mysql_query($query) or die(mysql_error());

And how will I get the info in the database to link to its relevant file on the server?
Basically, how can I select and display a file based on the database data?

View Replies !
Store A Download Date In A MySQL Database
I need to store a download date in a MySQL Database when a user makes an order,and check to see if that download date has expired when the user logs in in the future. What would be the best way to do this? timestamp?

Is there a PHP function that can anaylze the timestamp (or some sort of date string) and check to see how much time is left? Example: User orders download access for 24 hours - Comes back 5 hours, 20 minutes later - It should tell him that he has 18 hours fourty minutes left.

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 Chinese Characters And Pinyins In A Mysql Database
I need to store chinese characters and Pinyins in a mysql database
and then read them from php and using the GD library and
imagettftext() function to create an image based on a chinese ttf font
of the chinese characters.

I have tried setting the encoding in the database as UTF-8 and BIG5
but the characters display (both in MYSQL and when displayed via PHP)...

View Replies !
Read Data From A Table In Pdf File And Store It To Database
I have to populate MySQL database where data will come from a PDF file. This PDF file has a well formatted table and I have to make a similar replica of the table data into MYSQL Database. Is that possible at all?

View Replies !
Store The Image Location In A Database, Access It By Reference
I have the concepts of image uploading without a problem. My dilemma is how to store the image location in a database so I can access it by reference. I've been looking all over for a good tutorial to no avail.

View Replies !
Mysql Store Images On Database From Html Form Again.
i am trying to upload images to a database from an html form. This script is not connecting to the database and i do not know why. when i hit submit i get:

This file has the following Database ID: 0

it acts like something happened but no information is goinig to the database.
am i missing a binding or something? Code:

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 !
Make Html Page And Store On Harddrive From Database For Pagination Technigue
i am creating a news site. i am adding new news in database and it must be visible to user at top. and then second latest news and so on.

i am displaying 15 news on each page and then put a link for next 15 news on page.

my site is accessed by millions of people everyday. so for each when he want to see news he click on news link and in my php program query is run in database. so my database access became very slow because if one million people clicks on news link, the database will be accessed and query will be run one million times. Code:

View Replies !

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