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.





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

Related Forum Messages:
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 !
Seprate Decimal And Integer Part
i have a problem that is relatively simple, but i can't seen to figure it out. is there any way in php to seprate the decimal and the integer. basically i want to seprate the integer and decimal part and use decimle part to another place.

View Replies !
Using PHP To Extract All Request Variables
I have several types of contact forms on my web site and when submit
is hit I would like the PHP code to build a string with each variable
name and value and dump it in an email to me.

So I need to iterate through all the request variables on the contact
form in a generic fashion. Can someone please let me know the best way to do this? I am very new to PHP so feel free to point out a better way than below
to send an email.

At the moment it's like this but I explicitly have to extract each
request variable:

$message = "A contact request from the web site has been received.";
$message = $message . "Full Name: " . $_REQUEST['Contact_FullName'] ."";
$message = $message . "Title: " . $_REQUEST['Contact_Title'] . "";

//echo $message;
mail( "example@mail.com", "Web site contact request", $message, "From:
example@mail.com" );

View Replies !
Extract Session Variables
We can extract Post and Get variables by using extract($_GET)/extract($_
{POST) method. How can we extract session variables.

View Replies !
PHP5 Doesn't Extract Variables
I have a bunch of pages I wrote for PHP4 where I pass a variable to the script through the URL, and then the script would have the variable $car = "blue" But now that I upgraded to PHP5, it just ignores the variables I pass in the URL. Is there a way to still do this in PHP5?

View Replies !
Using Buttons To Store Variables
I'm writing a PHP script, and I know exactly how I want it to work, and what I want it to do when certain things happen. I also know how to make everything work. Well, everything except for this!

The goal of the application is to perform sales.  It will use a point and click interface. It should look something like this:

item 1

View Replies !
Store Multiple Variables
how I can store multiple variables in one field of a table and make them usable? For example, if the input from a form is:

Varible 1 = 1
Varible 2 = 9
Varible 3 = 3

Then the data should be stored in a single field as 1,9,3.

View Replies !
How To Store Session Variables Between Visits?
My website gathers some data on its first page, which is used on other
pages. I would like to 'store' the data in some session variables between
visits, to prevent any problems that may occur if a visitor bookmarks a
different page.

What is the best way of achieving this? Can I store the values in a cookie
on the clients pc?

View Replies !
Global Variables To Store User Name
I'm trying to do is set up a global variable for when the user logs in to store his user name, and call upon this variable later.

$loginName = $row['Username'];
session_register("username");
$username = $loginName;

I also set up a variable for a loginflag

session_register($loginFlag = 1);

This is probably wrong also. Here I'm trying to display different data to a logged in user and someone who isn't logged in.

<?php if ($loginFlag == 1) { ?>
<p><b>Welcome staff member <br />
<a href="../chooseupdate.php">
<?php echo $loginName; ?> </a>........

View Replies !
How Can I Store Global Variables For Whole Web Site
can anyone help me that how can i store the global variables for my web site. suppose i want to store the no. of users visited my site then what strategy should i use ?

can i implement some lock mechanism so that this global variable is not accessed by more than one application at some time which may create some confusion.

View Replies !
How To Extract From Array
What is the easiest way to get both the last item name and last item
value from an associative array?

I can get the value with array_pop() but can't see anything similar
for the item's name.

View Replies !
Extract Array
can anyone help me extracting this array using foreach...

$country_list = array(
"1" =>array("country" => "Afghanistan", "flag" => "af.png"),
"2" =>array("country" => "Albania", "flag" => "al.png"),
"3" =>array("country" =>"Algeria", "flag" => "dz.png"),
"4" =>array("country" =>"Andorra", "flag" => "ad.png"),I wont it to dispay:

1 Afganistan
2 Albania
3 Algeria..... and so on

thanx in advance

View Replies !
Array (extract)
What I am trying to do is a 'network sites' links where all the network sites are in an array and after each network site there is a ',' except the last one (because it is the last item of the list) so say the current site was google.com

$all_sites = array('google.com','exaple.com','test.info','site.com','text.com');

what i want to do is
if $_SERVER['HTTP_HOST'] = $array['google.com'] then to take google.com out of the array so there are only 4 other sites left in the array.. I tried doing it like this....

function network_sites(){
    global $all_sites;
    global $site_url;
    $number_of_links = 4;
    shuffle($all_sites);
    for ($i=0; $i<$number_of_links; $i++) {
    $capitalize = ucfirst($all_sites[$i]);
    if ($all_sites[$i] != $site_url){
    $last_site = $number_of_links - 1;
        if ($last_site == $i){
            echo '<a href="http://'.$all_sites[$i].'/">'.$capitalize.'</a>'
        }else{
            echo '<a href="http://'.$all_sites[$i].'/">'.$capitalize.'</a>, '
            }
        }
    }
}

but sometimes the last site has a comma in the end.. and it displays only 3 network sites (when its supposed to show 4) most of the time because if ($all_sites[$i] != $site_url) is being true and just doing nothing.
Exaple.com, Test.info, Site.com,

I think it would be easier and faster to just tackle the exporting before the function is needed but I couldn't find anything on how to completely take out a value of an array so it doesn't exist anymore.

View Replies !
Array Extract
I need to make an array of an sql table with an ID and an name column, where id=key and name=value. Any easy way of getting around this exept a whole lot of for loops?

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 !
How To Extract Array Contents?
Hi, trying to get connected to a database I have set up and see the contents. I got some code setup and it seems to be connecting, but the output just gives the array # and the word array like this: Code:

View Replies !
Use Php Script That Configured To Get Certain Info Off Of A Web Page And Store Them In Some Variables
is there an easy to use php script that configured to get certain info off of a web page and store them in some variables, without having to do a lot of coding by hand.

View Replies !
Warning: Extract(): First Argument Should Be An Array In
I'm creating a program to edit the details of members of an executive committee stored in a MySQL database. However, I recently have started getting the following error:

Warning: extract(): First argument should be an array in (lists file name and location of error)

To give a little background, the user selects the member to be edited from a drop-down list, which then passes the execID associated with that position to this program, which then queries the table for all the details of that particular member. However, I get the above mentioned error located to the line after "extract($row)".

I'm sure the solution to this is obvious to more experienced users, but I am baffled as I have used an almost identical setup for another project without experiencing the same error. I appreciate that the results of a query are loaded into an array, but I don't understand why a one-row result should cause such an error. PHP Code:

View Replies !
How Can I Extract The Values From The 'check' Array?
When information is returned from a form, it can be extracted from global variables quite easily. However, it appears to be better to use $HTTP_POST_VARS for this. After all, this is what it was designed for.

My problem is that if values from several checkboxs are returned in an array, eg $check[], all I can get from $HTTP_POST_VARS is a variable 'check' containing the value 'Array'. How can I extract the values from the 'check' array?

View Replies !
Extract All The Records With Id Array Problem
I have an assoc array with the following; id,type

myArr[0] = array('id' => 1, 'type'=>ds)
myArr[1] = array('id' =>1, 'type'=>dd)

myArr[2] = array('id' =>2, 'type'=>gt)
myArr[3] = array('id'=>2, 'type'=>rt)
myArr[4] = array('id'=>2, 'type'=>xx)

myArr[5] = array('id'=>3, 'type'=>ds)
myArr[6] = array('id'=>3, 'type'=>dd)

myArr[7] = array('id'=>4, 'type'=>xx1)
myArr[8] = array('id'=>4, 'type'=>dd)
myArr[9] = array('id'=>4, 'type'=>xx)

I want to extract all the records with id = 2, 4 because atleast one or the records with these id's has the type 'xx'.

View Replies !
Extract The Keys Of An Asscociative Array
I have an array which get generated as follows:

while($row = mysql_fetch_assoc($res)){
    $dataArr[] = $row;
}

How do i extract the keys only from dataArr?

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 !
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 !
Extract Html Table Cells And Put To An Array
i have a table like:

<tr><td>headA</td><td>headB</td><td>headC</td><td>headD</td></tr>
<tr><td>1a</td><td>1b</td><td>1c</td><td>1d</td></tr>
<tr><td>2a</td><td>2b</td><td>2c</td><td>2d</td></tr>
<tr><td>3a</td><td>3b</td><td>3c</td><td>3d</td></tr>
<tr><td>4a</td><td>4b</td><td>4c</td><td>4d</td></tr>

where there can be any number of rows and there can be any number of columns.

how can i read through this and create an array for each row, and use the header row as the keys.

ie have it something like:

QuotemyArray[0] = array(
     'headA' = '1a',
     'headB' = '1b',
     'headC' = '1c',
     'headD' = '1c',
);
     
myArray[1] = array(
     'headA' = '2a',
     'headB' = '2b',
     'headC' = '2c',
     'headD' = '2c',
);

etc....

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 !
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 !
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 !
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 !
Variables In Array?
Can you put variables in an array? Or can you cocatenate variables?

For ex: When a user submits a form, they have the option of adding 5 links, so to avoid adding 10 columns to my table (5 for title 5 for url), I want to put the 5 urls into an array OR cocatenate them with a semicolon and store that in the database. Then extract it and break them up.

How can I do this? Or do I need to just add the columns, or maybe just make a new table for the links altogether?

View Replies !
Array To Variables
I am wondering if there is a simple way to set an array to seperate variable names? for example:

$inputarray[0] = "name=joe"
$inputarray[1] = "s=q73"
$inputarray[2] = "third=at noon"

what I am looking for in the end is:

$name=joe
$s=q73
$thir=at noon

if this makes sense?

View Replies !
Variables Array
some times we pass variables in the URL ... so is there a way (even i dont know may be how many variable in the URL, or what are the variables builded in my URL so far) is there a way to make all the variables in an array $myvars[]? example:

$myvars= array("var1"=>"value1", "var2"=>"value2", ...etc);

View Replies !
How To Get Variables From Array
I'm working on an image uploader/manager script. When images are uploaded, their details are kept in a database so I can store alt text and control the order images are displayed in etc.

To do this I'm trying to create a form where I can update multiple records at once with different info(alt text for each picture(record), and the order number the picture should display in)

So I've named the form fields that hold the sort-order and Alt text like so: PHP Code:

View Replies !
Variable Variables And Array
I need to name a form field in a variable var1[0], var1[1], var[2]. I've got no problem doing this. However this is a dynamic form, and in other instances I need the variable to be called var2[0], var2[1], var2[2] and var3[0] the next time and so on.

I think the solution is somehow related to variable variables, but I can't figure it out.

If I just needed var[0] and var [1] that is easy I just do:
for ($x = 0; $x <3; $x++) {
echo "var[$x]";}

but when I try and get the variablename and the array number to increment I'm stuck:
for ($i = 0; $i<$mytotal; $++) {
$var= "var" . "$i";
for ($x = 0; $x <3; $x++) { echo "$var[$x]";} doesn't work because it is looking for the array $var1[0] which doesn't exist.
I tried echo "$var.[$x], and everything I can think of. Somehow I think I need a variable variable but can't figure it out.

View Replies !
Variable-variables For Array?
This has puzzled me for a while, what's the best (most efficient) way to get something from within an multi-dim array by using a variable for the key location? Here's what I currently do. PHP Code:

View Replies !
Multiple Variables To Array
I have a problem where I need to add a number of variables (the number varies, but all the variables have a similar name - e.g. $rm2, $rm56, $rm6783 (they all start with 'rm' followed by a number)) to a single array.

In other words, I need to add all the variables that start with 'rm' and followed by a number (e.g. $rm2, $rm56, $rm6783) to a single array.

View Replies !
Unsetting Certain Variables From An Array?
is there any way to unset each variable from the $_SESSION array except certain ones? I want to unset each except the sesssion username and password. PHP Code:

View Replies !

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