Adding Data To An Array

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:



ADVERTISEMENT

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 View Related

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 View Related

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;
endforeach;
$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 View Related

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 " )"?

[Code]...

View 1 Replies View Related

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 View Related

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 View Related

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');

[Code]...

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 View Related

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 View Related

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 View Related

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:
Array
(
[0]=>Array
(
[id]=>6
[userid]=>1
[date]=>January6,2010,5:17PM

[Code]...

View 2 Replies View Related

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 View Related

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(

[code]...

View 1 Replies View Related

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'),

[Code]...

View 1 Replies View Related

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 View Related

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);

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

View 5 Replies View Related

Adding Data To Xml?

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

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

[code]...

View 3 Replies View Related

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

[Code]...

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

View 2 Replies View Related

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 View Related

Adding Data With Yii Framework

This is my user table structure :

[Code]............

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

$model=new Users;
//$this->performAjaxValidation($model);
if(isset($_POST['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';
$model->attributes=$_POST['Users'];
if($model->save())
$this->redirect('dash/index');
}

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

View 3 Replies View Related

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 View Related

Validate Data Against Xsd Before Adding To Dbs?

Validate Data Against Xsd Before Adding To Dbs?

View 2 Replies View Related

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 View Related

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);

[Code]....

View 6 Replies View Related

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 View Related

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 View Related

Adding Up An Array

i have an array, which holds a total of 10 items, and i would like to add them all up to give me a total. what is the best way to do it, i have tried with the FOR, etc, but cant seem to get my head round it?

View 1 Replies View Related

Adding To An Array

I have the following code: PHP Code:

if (empty($zips)) echo 'Error: '.$z->last_error;
else {
   foreach ($zips as $key => $value) {
      echo "Zip code <b>$key</b> is <b>$value</b> miles away from <b>93001</b>.<br>";
      $getcity = "Select city from zip_code where zip_code = '$key'";
      $resultgetcity = mysql_query($getcity);
      $resultsetgetcity = mysql_fetch_array($resultgetcity);

View 5 Replies View Related

Adding A Value To An Array

Adding a value to an array. Why won't this work?

Code: [Select]$notify_list=file($filename);
$notify_list = array_push($notify_list,"$user_em");
foreach($notify_list as $key => $val) { echo "$val<BR>"; }It prints the number of records.

the file() is clearly an array and foreach prints as expected. I wonder if it is something to do with the at the end of each line? I could easily loop and manually build the new array but....

View 3 Replies View Related

Simple Adding Of Data To A Table

I'm basically creating a system which add records to a pre made SQL
database built in SQLyog.
So far i'va had no problems actually connecting to the database and
displaying resulst but I just cannot make it add records. I know its
connected to the database as a I made a mistake with connection
details on purpose to see if it recognised it.
I just add data into a text field, click submit and the page goes to
a
new, blank page with no changes to the table when I check in SQLyog.

Here is the code I have tried (simple add before I code the proper
system):

HTML page
<form action="script.php" method="post">
Test: <input type="text" name="test2"><br>
<input type="Submit">
</form>

and the PHP script to add data:
<?
$host="localhost"
$username="root";
$database="test";

$test2=$_POST['test2'];

mysql_pconnect($host,$username);
@mysql_select_db($database) or die( "Unable to select database");

$query = "INSERT INTO test2 VALUES ('','$test2')";
mysql_query($query);

mysql_close();
?>

View 2 Replies View Related

Adding Data To Mysql Table

I have the following script which is supposed to process a complete order for a serial number from a POST. It has so far been working okay. It processes the order successfully, then sends an email to me and to the user, but it is failing at the point where it has to do the insert of the data into the CustomersTable. PHP Code:

View 3 Replies View Related

Adding Variable Data To A PHP3 URL

I am new so please allow for this when reading the description of my problem. We are trying out the Cybershop shopping cart. It allows you to generate links on the fly which are then used by customers to buy goods. The format is: Code:

View 1 Replies View Related

Adding Data To Table, No Working

I'm having trouble with a script that is supposed to add data to my table. It shows it on screen, but doesn't write to the database. Code:

View 1 Replies View Related

Merging And Adding Data With SQLite?

I am writing a PHP script that runs on a cron and pulls JSON data from an API [ title (text), path (text), visitors (integer) ] and stores it in a SQLite database. Every time it runs, if it sees an existing title, it should add the new visitors count to the existing visitors. If not, it should add the new data as a new row.

Here's a simplified look at my loop:
foreach($results as $printresults) {
//this iterates though $title, $path and $visitors
$existing_visitors = $db->query("SELECT SUM(visitors) FROM topten WHERE
title='$title'");
while ($existing_vis_row = $existing_visitors->fetch(SQLITE_NUM)) {
$dupe_enter = $db->query("UPDATE topten SET title='$title', path='$path',
visitors='$existing_vis_row[0]' WHERE title='$title' ");
}
$db->query("INSERT INTO topten (id,title,path,visitors,time) VALUES
(NULL, '$title', '$path', '$visitors', '$time');");
}

Then I'll do a SELECT to pull DISTINCT rows ordered by visitors and write this to a file. Since the UPDATE query adds all the visitors to these rows, it doesn't matter that there will be all the dupes. On a certain timeout, I'll drop the whole table and start collecting again, so the file doesn't get too unwieldy.

The problem is that it is adding the summed visitor counts on every pass of the loop making the visitor counts totally out of whack. But I couldn't find a better way to simply add the data together every time the script was run.

View 2 Replies View Related

Adding Data To MySQL From A Table

I'm trying to utilise an 'ADD' button on a table of results, but I am having trouble inserting the data from that table. This is my code so far - [URL] At line 78, it's not allowing me to insert that; $row[Food_Name].

(If I change it to Food_Eaten1 = 'test', it works fine) I think it's because I'm using a while loop for the search, so when Add is clicked it's not recognising which line or array data I'm trying to add? I'm definitely missing something but can't think what.

View 4 Replies View Related

Adding Extra Data To A Variable

my code plucks out only one value using Mysql. So I thought I might aswell add each found result to a variable, however I dont know how to do this.

echo '<table border="1">';
echo "<tr><td><b>Surname</b></td><td><b>Title/Name</b></td><td><b>Numbers</b></td><td><b>Telephone</b></td><td><b>Edit</b></td><td><b>Del</b></td></tr>
";
while ($row= mysql_fetch_array($result)) {
$Surname = $row["Surname"];
$Title = $row["TitleName"];
[Code]....

View 2 Replies View Related

Adding Data To Multiple Tables?

I'm having problems adding data from a php form to more than one mysql table at a time. Below is my php page, insert.php. I have no problems adding data to tblPerson, but when I simultaneously add to tblAsset I get a blank screen.

<HTML>
<HEAD>
<TITLE>Data entry</TITLE>
</HEAD>
<BODY>

[Code]....

View 2 Replies View Related

Obtain Next Insert ID Without Adding Any Data?

Is it possible to obtain the next insert ID without actually executing a proper insert query? I am writing a file upload script but the name of the folder the file gets uploaded to depends on the next insert ID of a certain table.

View 9 Replies View Related

Adding Different Data To Different Jquery Tabs?

i have 2 functions

1- addMessage(): save data into database and is called only on click .

2-updateMessage():get data with ajax from database, called when document is ready ,called every 3 seconds for new data, and called on success of addMessage().

functionupdateMessage()
{
$.ajax({
url:"db.php",
type:"post",
dataType:"text/xml",
success:function(data)

[Code].....

Now the data retrieved i want to add to different tabs with different names and different containers, how would i do that. My question isn't a matter of code, it is more about logic or sequence of steps.

View 1 Replies View Related

Adding Totals To Table Of Data

I have a table of data that is generated with a query php/mysql. I'd like to show a total for one of the columns that include dollar amounts. How would i go about doing that?

View 6 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved