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.





Select One Row Of An Array Where Item Number Is ..?


When I call the Ebays XML API I get an array or something similar back (see the code sample), is it possible to "select item_id where item_id = 123123" or something similar as in MySQL? If, How can I do that? Also, I need to attach a PHP variables to the row I selected as for example $starttime, $endtime and so on.

Here is the code sample (the end of the scritpt);

PHP Code: ....




View Complete Forum Thread with Replies

Related Forum Messages:
Write A Conditional Statement To See If The Current Item In An Array Is The Last Item.
This seems like it would be so simple, but I haven't been able to solve it. I want to write a conditional statement to see if the current item in an array is the last item. I tried

if (count($array) == (current($array))

but that didn't work. count($array) will give me the number of items in the array. What do I use for the current position in the array.

View Replies !
Array_unique - How-to Get First Item Value In Repeated Array Item
I would like to know how-to get the first value of repeated items too in an array using something like array_unique. Code:

View Replies !
Number Count Beside Each Item
i need to list something which will be driven from mysql database and the output that i want to have is something like this.

1. item1
2. item 2
3. item3
4. item5

how can i generate the numbers 1. - 4. ..?

View Replies !
Select ONE Radio Box For Each Item,
I have a long list of items, and beside each item, there's a radio box under several options. Players should be able to select ONE radio box for each item, and the item ID needs to be stored in the array delMsg[]. Here's my code:

View Replies !
Select An Item In Drop Down Box
I have to display country name which selected when i did in registration. How do we select an item in the drop down box (value is fetched from database).

View Replies !
How To Change A Field When SELECT Item Changes?
I used php to create a list, using a SELECT with 40 OPTIONs. In this case, the items in the list correspond to inventory items.

I need to have another field next to this drop down box which, when the user selects an option from the drop down box, will show the quantity on hand for this item.

1. How do I do this?
2. How do I create the field which will show the quantity? (I can retrieve the qty from the sql db no problem)

View Replies !
Lets The User Select The Type Of Item They Wish To Add To The Library
I have an html page that lets the user select the type of item they wish to add to the library, a book, dvd, or cd.  That page has a form which connects to this page, where the information should be entered, and I hope to have this page connect to another page where the items will actually be entered into the database. Code:

View Replies !
Listing Mysql Results In A <select> Or Checkbox Item
I'm currently developping my own user system and so far I've completed my registration and profile but now I'm stuck on a problem at my edit file.

I do'nt have a clue on how to insert mysql entries, like the birthday of the user back into the drop-down list (<select>) or options they choosed back into the checkboxes.

Does anyone know how to do this? I do know how to put mysql entries back into textfields but I can't figure out how to do this for the other form items.

View Replies !
List Box In Form Returns Index Number Not Value Of Selected Item
I have a form that contains a list box that is filled by an array. When the form is submitted, it returns the index number of the selected item of the array of items in the list box, not the value. The value is what I need, not the index number of the selected item. Code:

View Replies !
Array Explode Problem Result In A 6 Item Array
I have the following:

$BB_Basket = "basket=¦APL6007,2.00¦AVX8900,1.00¦ARCAV500,1.00";
$basket_containers = explode('¦', $BB_Basket);
unset($basket_containers[0]);
print_r($basket_containers);

This results in

Array ( [1] => APL6007,2.00 [2] => AVX8900,1.00 [3] => ARCAV500,1.00 )

Now when I try to explode further with

$basket_items = explode(',', $basket_containers);
print_r($basket_items);

This results in

Array ( [0] => Array )

This should result in a 6 item array. Any ideas what I'm doing wrong?

View Replies !
Item In Array
I have an array, set up like this:

$this->navigation_array['Home'] = array('text' => 'Home', 'act' => 'Home', 'redirect' => 'No', 'active' => 'Home', 'link' => 'index.php?act=home', 'default' => 'Info');
$this->navigation_array['Forums'] = array('text' => 'Forums', 'act' => 'Forums', 'redirect' => 'No', 'active' => 'Forums', 'link' => 'index.php?act=forums', 'default' => 'Info');
$this->navigation_array['Users'] = array('text' => 'Users', 'act' => 'Users', 'redirect' => 'No', 'active' => 'Users', 'link' => 'index.php?act=users');
$this->navigation_array['Config'] = array('text' => 'Configuration', 'act' => 'Config', 'redirect' => 'No', 'active' => 'Config', 'link' => 'index.php?act=config');

I want to find the first item inserted into the array, namely "Home". What is the fastest way to just call the first entry? You cant use $this->navigation_array[0] in this case because the keys are text not numbers.

View Replies !
Deleting An Array Item
I have a standard array:
$foo = array(
0 => 'abc'
1 => 'def'
2 => 'ghi');

and I have a variable, $bar, which equals 'def' ... and I want to check
my array to see if the value of $bar exists in the array, and if it
does, delete it from the array.

if (in_array($bar, $foo)) {
// what goes here???
}

I've done this before, but for the life of me, I'm drawing a blank now.
Help a bruthah out?

View Replies !
Random Item Of An Array
What is the best way of picking out a random item of an array, regarding speed and CPU-usage ? I need a super fast way of picking out an ID from my MySQL db.

View Replies !
Delete Item From Array
How do I search for an item within an array, then delete it?

View Replies !
Remove An Item From And Array Entirely
How do you remove an item from an array...

View Replies !
Remove Item From Array
I'm having some trouble understanding how to remove items from an array. The array is created like this: Code:

View Replies !
Modify Array Item
I'm building a shopping cart and need to add the function so if an item is selected twice, the 'quantity' counter increments. I can't get the syntax right for modifying the array value. I have this:

foreach ($_SESSION['basket'] as $key => $row)
{
if ( $row['gnsz']==$gnsz)
{
$newqty=$row['qty'] ;
$newqty++;
$row['qty']= $newqty;
}
}

it picks up the first qty value but I can't seem to modify it in the array. I'm making a dumb mistake somewhere .

View Replies !
Put The Itemid Of An Item Into An Array.
$count = 1;
foreach($trade as $val) {
$val = checkinput($val);
$sel=mysql_query("SELECT * FROM `inventory` WHERE `ID` = '$val' AND `userid` = '$userid2'") or die(mysql_error());
$n=mysql_num_rows($sel);
if($n == 0) {
$input = "You do not own this item.";
error($input);
}
$g=mysql_fetch_array($sel);
$itemid = $g['itemid'];
$itemid[$count] = $itemid;
$count++;

}

Basically, my script is trying to put the itemid of an item into an array. The problem i'm getting is that, it's not saving the values in the array. For example, if i have 3 items and it puts them into the array, it will only save the 3rd item in the array $itemid[3] and 1 and 2 will be blank.

View Replies !
Current Item From An Array
i have an include file with many arrays that look like this: Code:

$event[] = array ('stuff' => 'bla');
$times[] = mktime(0,0,0,6,9,2007);

as of right now, I am using asort to sort all of these by date and display them as a list.

View Replies !
Find Item In Array
I have the following array

$array = array('k1' => 'v1','k2' => 'v2','k3' => 'v3','k4' => 'v4');

how do i select the value that is provided BEFORE the key i provide

ex:
$mykey = "k2";
$array = array('k1' => 'v1','k2' => 'v2','k3' => 'v3','k4' => 'v4');
$value = somefunctions(); // gives the value v1

ex:
$mykey = "k4";
$array = array('k1' => 'v1','k2' => 'v2','k3' => 'v3','k4' => 'v4');
$value = somefunctions(); // gives the value v3.

View Replies !
How To Remove An Item From An Array
Been looking around on how to remove an item from an array, i need the item totally removing, without a gab in the array, as i will be using the implode fuction afterwards.

View Replies !
Item In A Multidimensional Array
I have a multidimensional array (I think). It is an array that has arrays inside it. The inside arrays all have the same structure, (qty, product, color, size). How do I count how many items are 'White' * qty? I looked into the php manual and found array_count_values but others say it doesn't work with MD arrays.:confused:

array(
[0] array([0]qty, [1]product, [2] color, [3] size)
[1] array([0]qty, [1]product, [2] color, [3] size)
[2] array([0]qty, [1]product, [2] color, [3] size)
[3] array([0]qty, [1]product, [2] color, [3] size)
[4] array([0]qty, [1]product, [2] color, [3] size)
[5] array([0]qty, [1]product, [2] color, [3] size)
[6] array([0]qty, [1]product, [2] color, [3] size)
...)

View Replies !
Extra Item In My Array
Why is my code.

$urlarray = explode("/", "/about/new/index.php");
print_r($urlarray);

returning this

Array ( [0] => [1] => about [2] => new [3] => index.php ).

Perhaps I am being dense but why do I have an extra empty value at the beginning of the array. Is there any way I can make it return the ones I want (ie only those containing an actual value) or do I simply have to work around this.

View Replies !
Delete An Item From An Index Array?
How can I delete an Item from an index array in php4?

View Replies !
Shopping Cart Item Array
Trying to build a small simple shopping cart and I am having difficulty getting the solution. The cart is displaying each product, but it is overwriting the values. So if I have added 10 products, it shows ten items, but each item has the values of the last product I added.

I think that this may be due to me trying to use a key to store both an array and string at once, but Iam not sure. I have looked at other examples but due to different methods, syntax is throwing me off. Code:

View Replies !
Remove A Single Item From An Array
I have gathered an array of ID's. I need to go throught the array and find a specific ID and remove it from the array. Because we want to keep that ID. Any suggestion of how to do that.

View Replies !
Preg_split First Item In Array Is Blank
could someone please explain to my why using the code below generates a blank item in $array[0] please. The 'x' from xbox360 is in $array[1]?

View Replies !
Remove Item From Session Array
i have a simple script that adds an item id to a session Code:

View Replies !
Retrieving Previous Array Item
I have an array. The array key is the id of the item (for example
categories[91], 91 is the ID of the category) all ID are not exactly in
date order, but they're added to the array in date order, how do I find
the previous (in the sense of when it was added) array entry of, for
example category[&#3991;']?

View Replies !
Arrays : Returning A Reference To An Array Item ??
I am currently storing a set of objects inside an array,

$itemlist = array();
$itemlist[] = new item("myitem");
//...

and I am looking to develop a search function, which returns a
reference to the found item.

function &search_item($itemlist,"myitem") {
//...
}

I am trying to figure out how to obtain a reference to a given item in
an array.
Indeed, foreach() and each() seem to work on copies of the data in the
array.
For example:

$array = array("a","b","c","d");
print_r($array);
foreach($array as $v) $v="xxx";
print_r($array); // $array is unchanged

reset($array) ; while(list(,$v)=each($array)) $v="xxx";
print_r($array); // $array is unchanged, again

View Replies !
Deleting A Single Item From The Middle Of An Array?
I have an array that contain objects, I want to be able to test against the id of that object and remove it from the array. In it's simplest for I want to go from this:

$people = array('Tom', 'Dick', 'Harriet', 'Brenda', 'Jo');

...to this...

$people = array('Tom', 'Dick', 'Brenda', 'Jo');

The fact that the items in the array are objects should not matter right? Plus I've already written my loops and conditionals to check which item i need to remove.

function removeItem ( $item ) {
   $len = count ( $_SESSION['basket_arr'] ) ;
   if ( $len == 1 ) {
      emptyBasket ( ) ;
   } else {
      for ( $i = 0 ; $i < $len ; $i++ ) {
         if ( $item->id == $_SESSION['basket_arr'][$i]->id ) {
            //$_SESSION['basket_arr'][$i] must go
         } } }}


View Replies !
Removing Item From Array Then Overwriting File
I have a bookings.txt file which has a list of dates each on a new line, for example: -

21/06/07
22/06/07
29/06/07
25/12/07
01/01/08

I also have a variable $event_dd_mm_yy which I want to remove from this file if found. Code:

View Replies !
Select One "item" Of All Items The Script Returns..
I'm trying to build a Ebay API system to leave feedback (I still need help with that in thread http://www.phpbuilder.com/board/show...4#post10773544 in the PHP section) but here is another more specific question about XML and PHP. Code:

View Replies !
Select By Highest Number?
As the title of my post explains, can i select by finding the highest number? I have a links page for my current web site and this records click throughs to the links and then shows them on the link page for views to see.

I would ideally like to sort the listing of the links by the highest number of click throughs.The field in MySQL is an INT column and just gets increased each time someone clicks the link. Is it possible to sort by working out which the highest number is? If so, how? Im not too sure where to start!

View Replies !
Select Sum Value As A Number Not A String
$sql = "SELECT sum(NumPeople) FROM fall2005 WHERE VisitTime LIKE a.m.' AND VisitDate LIKE '$VisitDate'";
  $result = mysql_query($sql);
  $count_10am = mysql_fetch_row($result);

This gives me an array value for count_10am - I need it to be an integer. How do I get that value out of the query as an integer?

View Replies !
Select Largest Number
My current query:

$result = dbquery("SELECT user_id FROM fusion_ip WHERE user_id='".$userdata['user_id']."'");

I want the query to select the row with the highest number (or, in this case, datestamp).
So if this were the database.

View Replies !
SELECT With Number String
I am wanting to do a select on a database which store items for a webstore. Within this table there is a item_category section. For example I have 50 categories, and I want all to be displayed execpt those in categories 13, 37 and 38. Basically like: eg something like SELECT * from items where item_category doesn't = 13, 37, 38.

View Replies !
Select Number Range
I have weight ranges of 100,300,500,1000. The user will enter the package weight in the form and the query will return the price per pound. How can I select the correct weight in the query.

$getprice="SELECT * from priceMatrix
WHERE VENDOR='$vendorArray[$i]'
AND SERVICE=$serviceArray[$s]
AND WEIGHT<=$HTTP_POST_VARS[weight]";

View Replies !
MySql Select Highest Number
how can I perform a MySql query to select the highest number under the "number" column? The number column is an auto_increment.

View Replies !
Select The Number Of Rows From A Table,
So here's what I've got. I'm generating some graphs, and I want to be able to select the number of rows from a table, and then return the number of rows with a specific value...for instance.

John Group 1
Jesse Group 2
Frank Group 1
Jack Group 2
Fred Group 3
Jenn Group 1
Amy Group 1

So if I generate a pie chart with this data, I need the number of rows from Group 1, the number with Group 2, and the number with Group 3. Without specifying specifically (group 1, group 2, etc.), how can I select this data ?

View Replies !
Select A Number Of Words From A String In Mysql
I have a series of long documents stored in mysql rows. I am trying to figure out how to select a section of of one of those documents to be displayed on the web.

Example. Document 2000 words. Query (or php) to select 500 words from the document. (sometime from word 1-to-500, but also sometimes from the middle of the string).

Does anyone have any ideas on how to break these large chunks of data into smaller chunks? (I would ideally like to use a SQL query to speed things up, but whatever gets the job done...) .

View Replies !
Select * From A Table Where One Of A Number Of Fields May = A Variable.
I would like to be able to select * from a table where one of a number of fields may = a variable. I think i need to use AND|OR ruotine but cant find anything on the syntax that makes sense

SELECT *
FROM projectdata
WHERE projectdata.proauthone AND|OR projectdata.proauthtwo AND|OR projectdata.proauththree = 'authuser'

View Replies !
MySQL: Select Based On First Letter Or Number
I'm working with a fairly large database of company names, and I'm looking for a way to display them all in a format similar to the following:

A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z|#

Click on a letter, and all companies that start with the selected letter are displayed.

I have it ALL working just fine, except for the numeric selection. Several companies start with numbers (ie. 3Com), and I would like to display all of those (0-9) when the pound symbol is clicked on. Code:

View Replies !
Created A Form Where The Number Of Rows Are Displayed Based On A Value From A Select Box.
I have created a form where the number of rows are displayed based on a value from a select box. Everything works excellent this far. however I need to take it to the next step where I display the information back into the form based on values in a mysql table. Code:

View Replies !
Simple Select Query To Get The Huge Number Or Recors And Save In Text File
I have a huge mysql database with arround 500,000 records. All the records have a date field. Every day like 100 records been added in the database with date. I am getting this data using select query in different forms like current week, month, year and all from beginning data and save it as a text file Now the problem I am having is with the select query ...

View Replies !
Number Array
I have a looping database query and want to create a variable for each one, there will only be 6 results from the query. I tried:

$number = array(1,2,3,4,5,6);
..{ echo "$variable$number = $database_entry";  }

View Replies !
Number In An Array
I would like to find out the count of a particular number in an array and every time that number is found the counter should increase. For example: There's an array containing numbers and I would like to find out how many of them are less than 45. If a number less than 45 is found the counter should increase. I know I should use loop with mathematicl function < and variable counter but I don't know where to start. I searched in PHP manual and couldn't find one.

View Replies !
Get The Value In The Array With A Select
$form_array = array('title', 'entry', 'comment', 'rating');

foreach ($form_array as $cs)
{
        $query = mysql_query('SELECT value FROM prefix_config WHERE name = "'.$cs.'"');
        $test = mysql_fetch_array($query);
        $cs = $test['value'];
}
What I am wanting to do is get the value for each thing in the array with a select, and then I want to update the array value with the new value from the query. This isn't working.. what should I do?

View Replies !
Select Box To Array
I have a multiple select box named

<select name=schools[] multiple>

now my php to retrieve thse is

$school=$_REQUEST['school'];
foreach ($school as $k=>$v)
{
$sql=$sql."reason like '".$v."%'";
if ($n>0){
$sql=$sql." or ";
}

now instead of adding each school to the sql it's just writing it out as array instead of the school name from the select. what am i doing wrong?

View Replies !
Select Only The First Of An Array
I just got done building a site that has past issues that a user can browse to. The only issue with it is that when the admin deletes an article and it was the first one to have been submitted, it no longer shows up in the past issues. This is because there is a column I setup in the table called newIssue where it is set to "1" if it is a new issue, or "0" when it's not the first one of it's month and year to be submitted. If it deletes the row, it deletes this record and it doesn't show up in the past issues.

View Replies !
Select ID For Each Value In Array
So im trying to do an insert of an array of choices made from a listbox. Im coming up with an error message: Code:

View Replies !
Array Splitting By Number
I have an array of numbers. There can be anything from 1 to n.

I need to split this array into seperate arrays in chunks of 100.

Of course if there is < 100 then I just need the one array with that total in i.e. say the first array has 48 then there will be only ine chunk with 48. The following code just shows that I can do it but very basically.

Also each number is then to be comma seperated within the new array. Except for the last one which at the moment the code below does not take into account.

View Replies !

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