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

Related Forum Messages:
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 !
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 !
Store Values In A Class
How do I store a value into a class and display the value on another page?

View Replies !
Store Image Values In Db
I have a form that allows user to upload images. All in all users can upload 3 images. One of them should be a default one. I thought of adding 4 columns to user table and name them something like:

img1
img2
img3
defaultImg

So far so good. If a user uploads only one I can also record it as a default. If more then 1 then have radiobutton to indicate which one is default? And if they want to change image, have them first delete the one that will be replaced.

I'm not very clear how to detect where to store new images if they delete say #2 or #1. How do I know where to store new value? I also need to be able to change the default if they delete an image that's currently a default one.

View Replies !
How To Store 3 Seperat Post Values Into A Time Field In A MySQL Table
I am setting up a form to except time I've set up 3 drop down boxes:

- Hour (1 - 12)
- Min (15, 30, 45)
- AM or PM

what's the best way to get these three post values into a format to store in a MySQL time field.

View Replies !
Use Preg_replace To Replace Values In A Template XML File With Values From An Array.
I am trying to use preg_replace to replace values in a template XML file
with values from an array using the following:

$tmp = preg_replace('/<!-- (S+) -->/ge', $values[1], $line);

The template file will have lines such as:

<image source="pics/<!-- pic1 -->" thumb="pics/<!-- thumb1 -->"
title="<!-- caption1 -->"/>

And the $values array has values:

$values[pic1] = "raj1.jpg"
$values[thumb1] = "traj1.jpg"
$values[caption1] = "Who is this?"

Can anyone see where I am going wrong?

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 !
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 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 !
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 !
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 !
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 !
Adding New Values To An Array That Already Contains Values..
is it possible to append new values to an array that already has values in it??

say, i have my existing array;

existing array;
$array = array([66314] => 66314 , [66315] => 66315) ;

then , when i check my checkbox on my next page, the ids should be appended to the $array:

array that needs to be added to the $array;

$array = array([66316] => 66316,[66317] => 66317,[66318] => 66318);

how should it be done??

View Replies !
Selecting Array Rows Based On An Array Of Field=>values
Here's the code i have:

$db = array(); //main array
$db['main'] = array(); //table `main`
$db['main'][] = array('id'=>0,
'username'=>'joshfrench','userpass'=>'password','userlevel'=>'admin');
//row
$db['main'][] = array('id'=>1,
'username'=>'bob_smith','userpass'=>'psswrd','userlevel'=>'user');
//row

function trim_value(&$value){
$value = strtolower(trim($value));
}
function fdb_select($fields = "*", $table, $where = false, $limit =
false){
global $db;
$retv = $db[$table];

//LIMIT RESULTS TO FIELDS
if(strrpos($fields, ",") === false){$field=array($fields);}else{$field
= explode(",", $fields);};
array_walk($field, "trim_value");
$all_fields = array_keys($retv[0]);
if($fields == '*'|| is_null($fields)){$field = $all_fields;};
$field = array_uintersect($all_fields, $field, "strcasecmp");
$retvi = array();
foreach($retv as $num =$row){
foreach($row as $fname =$fvalue){
$fname1 = strtolower($fname);
if(in_array($fname1, $field)){
$retvi[$num][$fname]=$fvalue;
};
};
};
//DONE LIMITING TO FIELDS
if($where != false){

//UP TO HERE IT WORKS FINE
//LIMIT TO WHERE CLAUSE
$retvj = array();
foreach($retvi as $num =$row){
//IN THE ROW
foreach($where as $k =$v){
//IF ROW MEETS ALL REQUIREMENTS
if($row[$k] == $v){
$retvj[] = $retvi[$num]; //Keep that row
};
};
};
//DONE LIMITING TO WHERE CLAUSE
};
$retvi = (isset($retvj)) ? $retvj:$retvi;
//SEND A FINAL ASSOCIATIVE ARRAY
return $retvi;
};
print_r(fdb_select("*", "main", array('id'=>"1",
"username"=>"joshfrench")));

the previous code outputs this:

Array
(
[0] =Array
(
[id] =0
[username] =joshfrench
[userpass] =password
[userlevel] =admin
)

[1] =Array
(
[id] =1
[username] =bob_smith
[userpass] =psswrd
[userlevel] =user
)

)

View Replies !
Accessing Array Values Inside A Multidimensional Array
I need to access a value which is inside in a multidimensional array...

Suppose there is a form and where I takes all the form values inside an array named access..and I post the values into a different array.

$registrationArray = $_POST['access'];

Now I need to loop through this registration array and get values printed to the new variables...

Suppose this is the array $access = array (fname,lname,date,year,month)

How do I print the date,year,month values into different variable by looping through registration array..

View Replies !
Trying To Compare Array Values To A Value, Then Create Boolean Array
I have an array that returns data like this (see array below) The array[0] contains all the votes for one story as well as information that pertains to that vote, and the array[1] contains vote information for another story. What I need to do is check is a user_id stored in a session, is in the array, and then create a boolean array from that.

For example, here I want to check if the user_id is featured in the first set of data, let's say my user_id is 74. Ok, so it is in the first set of data, so we set the boolean variable to true. Next I need to search the second data field for my user_id, 73. It is not featured here so the value in my array is set to 0.

I need an array that returns values either 1, for true, your user_id was found in the table, or false, for your user_id was not featured in the table. They need to be in order of the story too. I'm having trouble one comparing the two variables against eachother, since the array is very deep, and two, creating the array on the fly. Code:

View Replies !
Modifying Values In An Array And Then Putting Them In A New Array
How do i get values out of an array, modify them and then put them back into a new array.
I have tried using a foreach to get the values out and to edit them but i don't know how to get them into a new array. Here's the code:

View Replies !
Sort The Array By The Values In Array[$i][0]
How would I go about sorting the following array, I've been looking at array_multisort but to be honest I'm either not fully understanding it or it's not capable of what I'm trying to do.

What I'd like to do is to sort the array by the values in array[$i][0] but I can't figure it out, the values being zzzz,a0,a1,00000000000000. PHP Code:

View Replies !
Copy Values From Array In To New Array?
I have an array with the following values in it:

REC_DATE = 'abc'
REC_CREATE = 'abc'
REC_DONE = 'abc'
DATE = 'abc'
TEST = 'abc'

Now I would like to put all the values which are starting with REC in to another array, what would be the best way to achieve this?

View Replies !
Get The Sum Of The Array Key Values.
I want to get the sum of the array key values.

ex: $key1=>10, $key2=>15, $key3=>5

I want variable $sum = 30.

any solution?

View Replies !
Array (add More Values To The End)
I have an array. I wan to add more values to the end of the array. how would i go about doing this. my current code does not work. PHP Code:

View Replies !
Use The Values From The Array
First I define an array and assign 65 values to it from a mysql database. Using print_r (array_values($arr_anmref)) I can see all the values and they are correct so no problem there.

I then need to process the information from a form when the users clicks ok. (This is to update the records based on if the user has checked or unchecked a checkbox).

When the user presses the OK button they are taken to a new page where I want to process the form and show the results of the processed information.

However in the code I need to use the values from the array but its misfiring.

The array is now empty and

print_r (array_values($arr_anmref))

.....shows nothing

I have tried adding session_start() at the top of both pages but to no avail.

View Replies !
How Many Values Is In One Array
if theres a way to know how many values is in one array. What i'm doing is, using a while query which stores an ID of an item in the value of a checkbox and the checkbox name is "name[]"

This turns it into an array, so i was wondering if i could count how many items actually are in that array?

View Replies !
Array Values
I have an associative array called "$infoDivs". I want to do something like the following: PHP Code:

$var = $var . $infoDivs[value1] . $infoDivs[value2];

The problem is, that the array has over 20 values, and is liable to get more at any point. I would like to just say. PHP Code:

$var = $var . ALL VALUES OF $infoDivs;

I would like PHP to do this (^) for me, I'm thinking that I could use a loop, but I'm not very good at them . How should I go about doing this?

View Replies !
Values Into Array
I am trying to combine JavaScript snippet wtih my PHP code. As a final result i need to get the following array:

PHP Code:

mytext[0]=""
mytext[1]="My text 1"
mytext[2]="Another text line"
mytext[3]="Yet one more"
mytext[4]="And another"

Now, I can run a loop and get the actual values in the string like:

PHP Code:

foreach ($myString as $str) {        
$str = $pr->myvalues;
}

Having difficulties combining the two together.

View Replies !
Values In Array
I have the following array:

$affiliations = ('Name1,Company1,City1,Country1', 'Name2,Company1,City1,Country1', 'Name3, Company2, City2, Country2');

I want to be able to detect in the array that Name1 and Name2 have the same company, city & country.

View Replies !
Values Into Array
i have a form, which has triple drop down lists which populate depending on the previous selection using javascript, an input text box, and a checkbox. the purpose of this form is to allow a user to create a phone package, now a user can create more than one package, however only one form is displayed, is there a way i can submit one form into an array and display that underneith on the same page and blank the form to add another package.

View Replies !
Values Into An Array
I've got this dymanic form that, I need to take the values of the selected checkboxes and puthem into an array. Here's my form: PHP Code:

foreach ($inputArr as $key => $value) {
  echo "<input type='checkbox' name='$key' ";
  if (in_array($key, $checkedArr))
    echo "checked='checked' ";
  echo "/>$value
";
}

PHP Code:

$new_array = array($_POST[$key']);
$info = implode(",", $new_array);

View Replies !
Add Values To Array
My arrays look like this:

1 , 3, 5, 6, 7, 8 ,9 ,12, 14, 16, 17

I need it to be filled from 1-17. Is it possible to add a where each number is missing. The missing numbers are random. So by adding a dash, it would then look like this:

1, -, 3, -, 5, 6, 7, 8 ,9, -, -, 12, -, 14, -, 16, 17.....

View Replies !
Comparing Array Values
I'm developing a database that holds information about crew members. There are 7 categories of service types. Crew members can be associated with any number of categories.

I'm working on an update form to add or delete categories for a crew member. I first issued a query to find the member's categories. I issued a second query to list all possible categories. I want to show a checkbox for any possible categories that aren't in the member's individual category list. If the member is in categories 1 and 2, but not in 3 or 4, I want to show a checkbox for categories 3 and 4.

I can get the two category lists to print, but I can't figure out how to compare them.

Here is the code I have for the select statements:

Generates the list of member categories:
$cat_query = "SELECT crew_category.crew_id, crew_category.category_id, category.category_desc
FROM crew_category, category
WHERE crew_category.crew_id = "$crew_id" and crew_category.category_id = category.category_id";

$cat_result = mysql_query($cat_query);


Generates the list of all possible categories:
$all_cat_query = "SELECT category_id
FROM category";

$all_cat_result = mysql_query($all_cat_query);


I'm just developing my programming skills (as I'm sure you can tell), so I apologize for my ignorance! Thanks in advance to anyone who can help!

View Replies !
Reusing The Array With A Different Set Of Values.
Is there any way that after filling the array in a loop with values that i can go back and start filling in the same array from scratch with a different set of values.

View Replies !
Accessing Values From An Array
i having trouble accessing the values from superglobal arrays. there
are two situations but i'm pretty sure it's the same problem.

here's the deal:

View Replies !
Shifting Values Up In The Array
i have some values in a text file and im reading it into an array when i unset a value in the array from the middle eg array[2], then i want array[3] and array[4] to shift up keeping the same values. i tried shuffle() and sort() but that rearranges the values. i dont want that to happen. i could not find anything else.

View Replies !
SUM Of Array - Total Of All Values
I have an array filled with data. I need to sum it's value.

example: $key1=>10, $key2=>15, $key3=>5

I want the total of all values which should be: 30

View Replies !
Sort Values In Array?
Does anybody know how to sort through an array so that I would only receive distinct values. For example, if I have an array like this:

Examplearray[0] = apple
Examplearray[1] = orange
Examplearray[2] = orange
Examplearray[3] = pear
Examplearray[4] = banana
Examplearray[5] = banana

I want the output to be this:

apple, orange, pear, banana

View Replies !
How To Get The Values Of An Array Using Javascript
In my php application , I am using an sql query and this query
is returning me a now of rows and I am storing these values in check
box. Here I am using a single check box and declared this to an
array like <input type="checkbox" name="C3[ ]" value="<?php echo
$arr['xx'];?>"and i want to get these checked values using
javascript. but when I am doing
document.formname.C3.checked , it gives me javascript error.

View Replies !
Passing Array Values In Url
I want to pass an array to another php script as follows: Code: echo "<a href="./xxx.php3?value_list=$value_list">xxx</a>"; What would be the correct way to do it?

View Replies !

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