Adding Data To An Array

Mar 12, 2007

I'm trying to make a simple shopping basket script, but am a little unsure of the best way to do it. I want an array where items can be added/removed with a simple form and displayed as a list, but I'm a little unsure how to go about doing it. Code:

View 8 Replies


Adding Data To An Array Using Checkboxes

I'm using PHP to create a list of options with checkboxes from a MySQL database. Making the checkboxes appear with their names is no problem, but I can't figure out how to use the checkboxes to add data to an array. That is to say, the page initially displays just fine, but if I click submit, nothing happens.

I've put a bunch of places where I print out what's going on with the page, and the only real problem seems to be that $myarray stays empty. I've seen so many different ways to do this that I can't figure out which way would apply to my very simple case. Code:

View 1 Replies

Adding Data To Existing Array

i am using an associative array with a list of columns for a mysql table. below is the array: PHP Code:

$log = array("columns" => array("Who", "Project", "WhatDone", "Started", "Finished"));

the array above will also have another row called Data which is added later. basically i want to be able to add new data/rows into the columns part of the array without erasing the current data.

View 2 Replies

Adding Data To Multidemensional Array After Or Before Foreach()?

ich have thios foreach loop to create an array. After or before it is created by the foreach, I want to add some values manually. I tried it in this way:

$data = array();
foreach ($xyz as $single):
$data[$dynamic_name] = $single->xyz;
$data[oid] = '####';

but in this way, only the last added values (oid) are stored in the rray. The rest gets deleted. Where ist the error in my code?

View 2 Replies

Adding Execution Timestamp For Each Bit Of Data In The Array?

Using curl_multi, I have loaded up 3 url's and then printed the array.

1) How can I also set a timestamp on output to let me know when each url was run?

2) How can I explode the array to only display the data and timestamp, excluding the text "Array ( [0] =>", "[1] =>", "[2] =>" and " )"?


View 1 Replies

Adding Data To The POST Array On Submit

I have a form on a PHP page that I submit into a POST array; my question is this: is there a way to change the value of the things you submit when the submit happens?For example, I have a box whose default value entered in is 4, could I do something with PHP so the value has a flag prepended onto it at submit time, like this: -f"4" ? So, basically, getting $_POST['textbox'] wouldn't be '4', but '-f"4"' ? Is there a way to do this? I've Googled for this without success,

View 3 Replies

Drupal Rules Adding Field Data To Referenced Node Without Replacing Existing Data?

My question is about: "adding field data to referenced node without replacing existing data".

For example, I have a project node with team members referencing the project. Each team member has on its node a location, ie, 'United Kingdom', 'United States', 'Australia'.

On the project node I have those exact same fields. I need to create a rule so that when a 'team member' node is created, its location is added to the project node without replacing existing content.

So for instance, a project node with a team member from the United Kingdom would also have on its location field, 'United Kingdom'. When a team member from 'United States' is added, the project's location field would have 'United Kingdom' and 'United States'. When a team member who's location is both Canada AND France is added, the project's location becomes United Kingdom, United States, Canada, and France.

Doing something like:

return array(
0 => array('value' => 'United Kingdom')

Just wouldn't work! It would replace the existing values. How do I make it so that it adds on to the existing values.

View 3 Replies

Storing A Multidimensional Array As An Object Variable - Adding Additional Keys To The Array?

So I have a multidimensional array which is stored in an object. I want to add additional keys to this array. Here's what I have:

$object->pathsArray = array(
"key1" => array('path' => '/some/path/to/some/file.php', 'action' => 'index'),
"key2" => array('path' => '/some/path/to/some/class.php', 'action' => 'method2')

And here's what I assumed would work but did not:

$object->pathsArray['key3'] = array('path' => '/some/path/to/some/method/or/script.php', 'action' => 'method3');


So my question: Is there a simpler syntax (ie: one line solution) or am I forced to bring in a temp. variable, append to that then merge/re-assign the value to the object?

View 1 Replies

Adding Checkbox To A Combobox / Checked Values To An Array And Then Use The Elements Of That Array In Mysql Query?

I want to add check boxes inside a combo box and then use the values of the checked boxes in my sql query.

Also I need to append the checked values to an array and then use the elements of that array in my sql query.
How can I proceed?

View 1 Replies

Adding An Element To The Beginning Of An Array Without Changing Other Array Keys?

How can I add an element to the beginning of array without changing array key values in PHP?

View 7 Replies

Array Push - Adding An Elements To An Array With A Specific Name?

Hopefully a simple question. I have an array with the following structure:

PHP Code:
[0] => Array
[id] => 6
[userid] => 1
[date] => January 6, 2010, 5:17PM


View 2 Replies

Adding To $_POST Array Is Not Reflected In $_REQUEST Array

Recently I wrote this:

<? echo 'action = '.$_REQUEST['action'].'
'; ?>
<?php $_POST['action'] = 'newmember_split'; echo 'action = '.$_REQUEST['action'].'
'; ?>

My expected output was:

action =
action = newmember_split

However my output was:
action =
action =

How is this so. As far as I know $_REQUEST is supposed to reflect both $_POST and $_GET. I tried to find some information on it but failed.

View 10 Replies

Adding An Array Inside An Array In A Function?

I have created a function in PHP that calls a webservice and parses through the result, assinging values to variables and returning them all as an Array. This all works perfectly, however I have come across a need to have an "array within my array"I am assigning values as below:

$productName = $product->Name;
$productID = $product->ID;
$productArray = array(


View 1 Replies

Adding Array Key Multidimensional Associative Array?

I am having problems updating a deeply nested multidimensional php associative array.what I basically want it to add and 'parent_id' key with an incrementing value to all array elements that has an array under them.

For example i have the array below.

[root] =>
Array('child_1' =>
Array('child1_grandchild_1' => 'gchild1_value',
'child1_grandchild_2' => Array('grandchild_1' => 'gchildval1',
'grandchild_2 => 'gchildval2',
'grandchild_3' => 'gchildval3'),


View 1 Replies

Adding A Value From MySQL Query Array Into A Array?

So I'm querying my database to add the results (mapID's) into a PHP array. The MySQL query I used in the below code would usually return 10 values (only 10 mapID's in the database)

Code: [Select]while($data = mysql_fetch_array(mysql_query("SELECT mapID FROM maps"))){
$sqlsearchdata[] = $data['mapID'];

Instead the page takes ages to load then gives this error: QuoteFatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 16 bytes)It says the error begins on the first line of the above code. I'm assuming this is not the right way to add the value from the MySQL array into a normal PHP array.

View 4 Replies

Adding Data Via

Created a form, which I want to add to a mysql database named employees. PHP Code:

$Host = "localhost";
$User = "*******";
$Password = "******";
$DBname = "******";
$TableName = "employees";
$Link = mysql_connect($Host,$User, $Password);
$Result = mysql_db_query($DBname,$Query,$Link);

$query = "INSERT INTO employee VALUES ('$firstname','$lastname','$dob','$password','$house','$town','$county','$country','$postcode')";
$msg = "New record is saved";.

View 5 Replies

Adding Data To Xml?

have a form that a name has been entered and need to add it to xml file.

<form name="form" action="insert.php" method="post">
<label for="name">Name:</label> <br />


View 3 Replies

Adding To An Array In Multidimensional Array?

I have a Multidimensional array.

PHP Code:
$playerid = 5;
$finaldraft = array();
$playerchoice = some number pulled from the database
$finaldraft[] = array($playerid, array($playerchoice));

This store the information properly, but later on in the code I need to add onto the array inside the first one. I can't figure out how to add onto the interior array. Ive tried running


Does this even make sense. Let me know if it does not and I'll try to explain it another way.

View 2 Replies

Adding A Value To Post Data

I am taking input from a form, I would like to add &#392;.00' to it. Ive tried a variety of ways, None of which actually work. My goal is to keep the $_POST structure, after editing it, If possible. Code:

View 2 Replies

Adding Data With Yii Framework

This is my user table structure :


I'm trying to add data to my database. (in my controller)

$model=new Users;
//screen_name, email,pass comes from form. Also, we need to set **slug** and **singin_twitter**
$_POST['Users']['slug'] = $this->sanitize($_POST['Users']['screen_name']);
$_POST['Users']['signin_twitter'] = 'F';

But it's not saving data . $model->save() returning FALSE . How can i debug it ?

View 3 Replies

Adding Data Into Json?

i used json_decode to create a json object. After going through some elements i would like to add child elements to it.

View 2 Replies

Validate Data Against Xsd Before Adding To Dbs?

Validate Data Against Xsd Before Adding To Dbs?

View 2 Replies

Adding Comma To Data

I have an SQL database with a price field. The field is INT(10), as I do not need decimal to show cents. My problem is that when the data is sorted and displayed, it shows as "20000" or "200000" or "2000", etc. I need it to have commas like so - "20,000" or "200,000" or "2,000". Is there an easy way to "format" the output?

View 1 Replies

Script Not Adding All Data To Db?

I have added a function so i can add more textboxes to the form if needed

Code: [Select]<script language="javascript1.2" type="text/javascript">
function addRow() {
var tbl = document.getElementById('thetable');
var lastRow = tbl.rows.length;
var row = tbl.insertRow(lastRow);


View 6 Replies

Array And Adding

i have lots of values in my sql table, i need to collect all the values from each row and retireve them in an array, then find the average of this array. PHP Code:

<td width="122"><strong>Average Bid:</strong> <?php $getprices = mysql_query("SELECT * FROM bids WHERE project='$id'");

function add_array($array)
for( $i = 0; $i < count( $array ); $i++ )
$total_array = intval($total_array) + intval($array[$i] );

can anyone see the problem?

View 9 Replies

Adding An Array

Is it possible to add an array variable and a variable together? What I have is a for statement where $i runs from 1-10. Inside the for statement I have an array variable $row['hometeam'].

What I need to do is add $i to $row['hometeam'], i.e

PHP Code:

$hometeam = $row['hometeam''.$i.''];

... so I end up with $hometeam = $row['hometeam1'] through to $row['hometeam10']But I dont think the above code will work.

View 2 Replies

Copyrights 2005-15, All rights reserved