Display All Array Items
How do I display all the items within an array? Also, how do I delete a particular item from an array?
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Display Items Using Checkbox
i have a page where in it lists all job items on a table and each item has a checkbox so when i check one or more items when i click the post button it should display the job items on this post page. my problem is, my post page is not working. Code:
Display Items From A Mysql Database In A Table
I am trying to display items from a mysql database in a table but I need it to start a new table row each time multiples of 3 rows of the database table have been displayed like the following example: item 1 item 2 item3 item 4 item 5 item 6 Does anybody know how I can make this work using php.
How Many Items Are In An Array?
I dont know how many values there are in my array after it's been split.. is there a command? array_count_values doesnt do what I need sadly.
Compare Items In An Array...
I have been getting on fine with basic coding until I stumbled accross a problem. I cant seem to figure out how to check to see if a value in one array is in another array - and if so just simple report back "true" or "false". Lets call the two arrays LOCKS and KEYS. Doing a print_r($locks) would give: Code:
How Do I Delete Items From Array?
I can add several items to the basket, but how do I delete one from the basket? I want to delete any of the added items. Here is my code for creating the array and adding items to it. // creating the array $item = array(); $item['id'] = "1"; $item['price'] = "100"; $item['quantity'] = "1"; // add item $_SESSION['basket'][] = $item;
Adding Only Unique Items To An Array
I've made a small code snippet that adds a new item ($value = $_GET) to an array in a cookie. My main question is in the title of the post, and I have a related one: How do I delete a specific value from the array and shift all the other values down to fill its place? Will this happen on its own? And one more: Using this code I display the array values in descending order; foreach ($_COOKIE['best'] as $name => $value) { $best = urlencode($value); echo //insert code here } } Is there any way to display this in ascending order?
Counting Items In An Array Having X Attribute
I want to randomly select 5 cards from a standard playing card deck and count how many of each suit are returned: [connect] $sql = "SELECT * FROM cards ORDER BY RAND()LIMIT 5"; $result = mysql_query($sql); while($cards = mysql_fetch_array($result)) { $value = $cards["card_value"]; $suit = $cards["card_suit"]; $image = $cards["card_image"]; -------- Using count() within the loop returns a count of 1 since each card can only be of one suit. I tried using something like this: $spades = 0; if($suit='spades') { $spades = $spades+1; } and I tried a foreach statement to count within the loop which always returns a count of 1. Would someone be so kind as to point me in the right direction?
Trying To Return Mysql Array Items From Function
I am writing a calendar script which returns events, holidays etc.. from MySQL for days with events. This was easy BUT then I tried to return multiple events on some days and thats where I am stuck. I found some examples of returning arrays from functions from functions but they all use some form of array(Ƈ',ƈ',Ɖ') and then use a for loop... I am using mysql_fetch_array so this does not seem to work... First, here is some of the code from the function where I am returning the value: PHP Code:
Check If Any Items In An Array (php) Is In A Table (mysql).
I want to check if any of the items in a PHP array exist in a MySQL table. What is the best way to do this with making repeated calls to the database for each item? Actual application is: I have an array (in PHP) of serial numbers of units about to be shipped.I want to check the ship record (a table in a MySQL database) to check if that serial number has been used before. According to our quality policy we never reuse serial numbers, serial numbers are unique. So prior to printing the packing slip I want to warn the shipping guy/gal a serial number may be incorrect. I could brute force it and increment through the "to be shipped array" and check each item against the table. But that is, as I said brute force, and I am having to be concerned with system speed lately.
Remove Items From Array, Shift Positions
Hey, lets say I have: x = array("red", "blue", "green", "yellow", "orange", "grey"); Now lets say I have a loop that prints out what is in the array. I want to be able to remove blue green and yellow, but effectively shift down everything else in the array (in this case orange and grey) so that orange is now positioned relative to where blue was and grey is where green was. By this I mean x[1] = "blue" and x[2] now quals "grey". How can I do this?
Set An Array Of Array, Do An Unset And Display Both
see this code, i only set an array of array, then i copy this array in another one, do an unset and display both: $a["row1"]=array("row1.1"=>"row1.1.1" , "row1.2"=>"row1.2.1"); $a["row2"] = array("row2.1"=>"row2.1.1", "row2.2"=>"row2.2.1"); print_r($a); $temp=$a; unset ($temp["row2"]["row2.1"]); print_r($temp); print_r($a); it works as expected, the unset within $temp does not affect rows within $a. BUT, if you replace $a=>$_SESSION, the unset within $temp do the same thing within $_SESSION!! The row is unset within $temp AND $_SESSION!! How do you explain that?
How To Get And Display Array From *.csv
i am using db stored in csv file (ponuka.csv) and i want to display lines (arrays) by key (words in first row). i wrote code written under this text but every time i want to diplay data it display only first row data correctly others are wrong Code:
Display Array
$display[] = $row['firstName'']; how would I display the lastname also? $display[] = $row['firstName''lastName']; ? that didnt' seem to work.
Display Array Vertically
To display an arrays contents, I have been using print_r(), but this displays the array across the page/screen. Is there a function that displays the array vertically?
Display Values Of Multidimensional Array
Can anyone help me with a function to display the keys/values of a multidimensional array in a more simpler to read display than that of the standard print_r()?
Display Array Values In A Class
I'm trying to diplay values from an HTML mutiple select list in a class. I'm trying to pass the array of selected values in the same manner as the strings in the other sets and gets in the code below. But I don't seem to be getting an array when I try to use getArrayCities. How do I pass the array and display the array values by using getArrayCities? Code:
Mysql Fetch Array - Image Display If Available
I am using a HTML search form to give me the following result. I can get everything to work, even get it to display images that are associated with particular search term, but can't figure out how to keep it from displaying that annoying little "There's not image here image" that explorer shows, the one with box and red "x". I know that an if statement would do the trick, but I can't do "if's" inside of the "echo" is it possible to accomplish this? How? Code:
Query Array, Sort Results And Display In Seperate Tables
The problem I have it breaking out the results and displaying them (broken out) alphabetically in seperate tables. For instance, I have generated (bookmarked) tables, one for each letter (A-Z) and want to display all recordsets with say, last name beginning with "A" in one 2 column table, "B" in another 2 column table, and so on... each table would have two columns (with 2 background colors alternating), each cell containing values of one recordset. Even more tricky is if I have an odd number of cells, still generating the last cell with empty values (for asthetics). And can anyone say "sort" (yes, I am nuts)? The ability to sort the whole mess by any column value. I have looked at freeware and other third part apps, but they can only do what I already can do (mine is actually cleaner) but not as complicated.
Related Items
I noticed a lot of websites show "Related Items" on each product page. I want to know how usually do you implement it. Should I add a field in the mysql table to hold the "Related Items" information? What's the best solution?
Get ID Of Deleted Items
I wonder if there is anything similar to "mysql_insert_id();" for deleted/updated id's? If i do a query and DELETE WHERE text_field="", can i get the id's of the fields that were deleted?
Add/Delete Items
I have the following code, that displays a message whether a users shopping cart contains items or not. How do I add/delete items from the shopping cart, upon the appropriate product link being clicked? If a items is already in the cart, how do I display a message notifying the user? Code:
Favorit Items
i have many tables with different data structure due, am making a service which will allow users to add itimes to thier "favorit items" tables I thinked to use the table names as a hidden filed, like if the table name is "hotel" and the user added a hotel to his favorit items , the hidden fild will be hotels, and then pass that field as a variable then use it in a query to get the hitel data, does this adea work? or there is a better way ?
Using If Empty With Two Items
I am trying to say if $_Post and $_Session are empty set the variable $dcparent to equal 1, but it doesn't like what I am doing. if(isset($_POST['dcparent'])) { $dcparent = mysql_real_escape_string($_POST['dcparent']); } if(isset($_SESSION['dcparent'])) { $dcparent = mysql_real_escape_string($_SESSION['dcparent']); } if(empty($_POST['dcparent']) && (empty($_SESSION['dcparent'])) { $dcparent = 1; }
Multiple Cart Items
I've created a shopping cart application using php 4.06 and postgres. a problem i had was that when i added the same item twice it was adding an extra item as opposed to adding the quantities together. i did manage to sort this out to an extent but my only solution means using a block of code for each item which has made my script very long and i'm pretty sure has made the script somewhat unreliable. I would appreciate it greatly if someone could offer a solution to this, this is my code for adding items to the cart: PHP Code:
Finding @ In A String, And Other Items
Ok - I want to check a string for @ in it (Im checking to see if a string that should contain an email holds a @ ) How would I go about this? preg_match? ereg? strstr? Examples? Also - how would I find any non alpha numeric characters in a string so I can give the user an error message. I dont want any characters besides alpha-numeric in the strings.
Multiple Items Of Same Name In Session?
I have a shopping cart where I can add tshirt designs to the cart. The designs are added to a php session object called cart. The object 'cart' consists of the design name, color and the quantity. The probem is that if someone adds the same design to the cart again then it just increments the quantity of the existing design with the same name instead of adding another instance of it to the cart. How can I have multiple instances of the same design with the same name in the cart at the same time. One thing I thought of was to append some sort of incrementing id to the design name before it is added to the cart. Thus the next time the design is added it would have a new id appended and the resulting name would be different.
Dynamic Form Items
I am trying to create A form that its fields will depend on a form menu. for example. /***********************************************/ <form name="form1" method="post" action=""> <select name="select"> <option value="1">option 1</option> <option value="2">option 2</option> <option value="3">option 3</option> </select> Text field 1<input type="text" name="textfield"> Text Field 2<input type="text" name="textfield2"> Text Field 3 <input type="text" name="textfield3"> Text Field 4 <input type="text" name="textfield4"> <input type="submit" name="Submit" value="Submit"> </form> /***********************************************/ When the option 1 is selected only the textfields 1 and 2 to appear, when option 2 is selected only textfields 1 and 3 to appear and so on... any combination I would like. I tried puting the textfields in "if" statments but i don't like it. its too messy PHP and HTML code. Any Ideas of how this could be done better ? If someone did something similar before and has a relative link it would be good as well.
Number Of Items In A Cart
I am working with a session and a 'cart' (note that I do not really know what I am doing though). I was wondering if there is some easy way (function) to work out how many items I have in my 'basket' / 'cart', because then I could call this function from anywhere to show the user just how many items are on order
Only Allow X Number Of Items To Be Checked
I have a function that renders out tag categories, and then all the tags within said category. Each tag has a checbox beside it, i am wondering if it's possible to only allow a user to check 4 tags. Here is the function: Code:
Count Of How Many Items Are In Database
I am wanting to create an select menu for displaying the order of the item on a page. I am guessing that I need to get the count of how many items are in the db and them put them into a select menu. Does anyone know how to do this or can point me in the right direction?
Changing Items After A Date
What I have is a table (code below) and it is for an events page. What I want is after the date has gone, it changes the whole row to grey. ( #666666 ). Code:
Deleting Items From A List
When i click one of the delete buttons, the form submits, but nothing happens. I'm pretty sure i'm doing something stupid with the form buttons, but I've been staring at it too long...any takers? Code:
Multiple Items In Foreach()
Can someone tell me what im doing wrong with the code bellow please? I get print_ticket called lots of times, with 1 as the hash,name,ticket_no responce. (i have chequed that the query is returning the right results). $return = pg_query($pg_connection, $query); $data = pg_fetch_array($return); foreach ( $data as $temp ) { echo print_ticket ($temp['hash'],$temp['name'],$temp['ticket_no']); }
Seperating Search Items
When conducting a php sql search i get some great results, however i want to expand my results so that when multiple search terms are added it will display all relevant fields. $query = "SELECT * FROM Mixes WHERE dj LIKE '%$var%' OR event LIKE '%$var%' OR tracklist LIKE '%$var%' OR date LIKE '%$var%' ORDER BY event ASC"; From the above search i can only get single results from 1 field. I want to be able to seperate the search term into individual items that can be referrenced in the database. So for example i search for a dj name and also an event they play at i get zero results, however if i search for them individually i get the results i want. How do i expand the code to display the result of both the dj and the event or any of the other fields? I presume that i need to be able to set each search item into an individual variable and then use them to search.
Adding Items To A List Or Menu
Not sure if it is a php question but since i am working in php here it is. Ho can i add items to (the item label=visual text and the value=index number) a list object on a website. I am having a list with 4 items and i would like to add the text from a textfield (textfield1.value) to the list object so it will hold 5 items.
Dynamic List Items Repeating Themselves
I'm working on this online magazine, and each page (well, other than the front page) has a menu included on the right-hand side consisting of articles divided into three sections: articles, columns, reviews. For some reason, whenever I click on one of these article links, that link takes the place of the first link in the section. You can see what I mean here: PHP for the included right_menu.php PHP Code:
Adding List Items To A Database
Not sure if this is javascript or php so i put it in both newsgroups, sorry if it's the wrong group. I wrote (with help) a code to put several items in a list object (select) and I would like to add the items in this list to a database. I know how to add a selected item to the database but how can i put al the items tot the database. I need somekind of loop wich go's through the list.
Count Number Of Items In Each Category
I'm trying to list my categories and how many items are in each category. I'm not much on sub queries. How can I combine these two items. I'd like to display the category and the corresponding number of items in each ....
Create String With Checkbox Items
I'm creating a php script to interface with a database that will contain work requests for my office. Each job needs to be assigned to a person, possibly more than one person. The database field for this is named 'assigned_to' and will contain some data similar to "dave, randy, scott" for people who worked on the job. Does that sound reasonable? Code:
How To Pull Only Unique Items From Database?
I have a table like this: date, author, title, content now I want to grab the 3 latest items from this table from 3 DIFFERENT authors. I want this: -article by jim -article by sally -article by john Not this: -article by jim -article by jim -article by sally even if the two latest articles happen to be by jim, lets only grab the first one and move on. So basically I need (in pseudo-sql/plaintext): select title from contenttable where author=unique order by date limit 3 I've got everything code-wise except the "author=unique" part, how do I do that?
Seperator Instead Of A Comma For Listed Items In DB?
I'm making a recipe database, and need to have DB fields in mySQL that will have lists of values that would get sent to an array to be worked on. I anticipate that at times a comma will need to be used in the value itself. So, what's a commonly used symbol or something that people tend to use as a separator of a list that would then be used in the split() function to send the elements into an array?
Print All Selected Items From Dropdown??
I have a program that allows users to select a 'New Graduate' membership, and for each one selected, they get a free tshirt. I've got that working using a 'is_new_grad' function that I created. So, if they select 2, they see 2 dropdowns to select the sizes of them. It then sends an email w/ the membership info and the shirt sizes selected. However, when the email is being sent, it's only returning the size of the LAST item selected in from the drop-downs. Example: if I sign up for four of these memberships and select four different tshirt sizes (1 Medium, 1 Lg, 1 XL, and 1 XXL), the info in the email is all XXL: Code:
Updating Multiple Items With One Form
I am using a do while loop to run through a list of items on my page. Say I have 5 items on the page and each has one field that the user can input information to. Is there a way to do an update where it will update all records on the page with one submit form?
Displaying Multiple Items From Database
what i have is a page that has four sections. what i want to have is when the page opens, in that page i want the lastest two items for each section from a database to be displayed. the items to be displayed are an image, a title and a description. but i also want the description to be shortend to say about 25-30 words or about 100 chars, if thats easier? so in the end i have 4 sections, each showing the lastest two items for each section. would the best way to do this be to have a seperate table in the database for each of the sections? or would i be able to do it from one table? would i have to creat a query for each of the sections? e.g: SELECT * FROM table WHERE section=section
|