Selected Item To Use For Multiple Variables
I've got a list of 'items' and those 'items' have unique 'categories'. I have 1 table for 'categories' that contains a list of category_ids and their 'category_names'. The other table is the 'item' list. And here's where I'm running into difficulty, I'd like to have the 'item' table contain the category_id from my 'categories' table as a Foreign Key and that category_id's 'category_name' in a 'category' field. I'm getting the Foreign Key, but I can't seem to grab the 'category_name' and assign it to my $category variable in the 'item' table.
I've got a page to insert items and a page to update these items. I was working with the update first. And I'm able to grab the list of categories and select the correct one, but I'm not seeing where to assign the category_name to the $category variable. Here's dropdown list: Code:
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Multiple Selected="selected" In A List.
I have a database with 1 to many and the many is a list with multiple selects in a list. When I click on a master record I have as part of my form the select statement for the multiple choice list. I want the list to highlight the multiple chosen values. here is part of the code. $dresscat = specdresscat($dresstypeid); //this is the query to get the values in the detail table $drcatrow = pg_fetch_array($dresscat);// the array for the detail table. <select name="stages[]" multiple="multiple"> <?php $allstages = allstages(); // this is a function to query my database to get the value for the list. while ($allstagerows=pg_fetch_array($allstages)) { $eachstage= $allstagerows["stageid"]; $specstage= $drcatrow["stageid"]; // this is the point I need help if ($specstage == $eachstage){ ?> <option value=<?php echo $eachstage;?> selected="selected"><?php echo allstagerows["stage"]?></option> <?php }else{ ?> <option value=<?php echo $eachstage;?>><?php echo $allstagerows["stage"]?></option> <?php } } ?> </select>
Multiple Select Box With Selected Option ...
first of all I have three tables (tournament_game, umpire_game, umpires). Updating tournament_game umpires, each game may have from two to four umpires, and those umpires can work from one to n number of games, that's why I'm using connection table umpire_game. I'd like to get selected multiple select box of umpires in game, it could be two to four options, with all umpires listed as options example: <select name=umpire_game[] size=10 multiple> <option value=$umpire_id>$umpire_name</option> <option value=$umpire_id selected>$umpire_name</option> <option value=$umpire_id selected>$umpire_name</option> <option value=$umpire_id>$umpire_name</option> <option value=$umpire_id selected>$umpire_name</option> <option value=$umpire_id selected>$umpire_name</option> PHP Code:
Option Selected Multiple Rows Logic
I am having problem getting the logic to work to get a multiple option box to get populated from the database and select the ones which are already in the database. Here is my code: PHP Code:
Sending Mail To Multiple Users (which Can Be Selected By The Sender)
I'm looking for a script to email a contact form to multiple emailadresses but that the user can choose to which people the email is being send, like for example: the user only sees a few names with checkboxes and by selecting a few of those checkboxes (with only the nicknames of the recipient(s) viewable for the user NOT the emailadress) they can select to which people they would like to send that Email.
Using Variables To Control What Is Selected In An Drop-down Menu?
I have a drop-down menu with the states. I don't necessarily want to have the menu dynamic with a database, but I want to be able to control what is selected using a variable. Code: <select name=state id=state> <option value="" selected>--</option> <option value="AL">Alabama</option> <option value="AK">Alaska</option> etc... </select>
Setting Variables For Only The Selected Items In Form
when a form has a question where the response can be one or more selections either from a series of chech box inputs or a selection list, how would i set into variables only the responses that are checked or selected so that only these values are available for exporting to a mySQL database?
Sending Multiple Variables Via URL
Hi, to send a variable in the url, I would use this syntax: address.com?variable=data What syntax do I need to use to send several variables through using the URL address?
Passing Multiple Variables Using GET
I have a problem where I need to pass two variables using GET from a form I have, to solve a page selection problem I have. The code is written that if a new visitor arrives at the front page of the site, because the page id is null, PHP loads the default design. But when I execute one of my other pages which has a form on it, because I cannot pass back the id of the page that the form is on (the "submit" GET's the desired page id only), instead of calling the new page, it executes the "null" part of the script again. Despite the GET having a different id (track), it refuses to execute because the page == null code. The variable of the page needed to be displayed is GET'ed (it's in the browser URL, and an echo statement in the PHP confirms the value GET'ed, and lack of the original page id. How can I get the code to pass both the page id and the data of the selected form item at the same time? The PHP <? if ($_GET['page'] == NULL) { echo $_GET['track']; //value passed from the HTML form echo $_GET['page']; //value of the page id include ("index2.php"); } elseif ($_GET['page'] == index) { header ("Location: /index.php"); } elseif ($_GET['page'] != index) { include ("html/".$_GET['page'].".shtml"); } elseif ($_GET['track'] == a01-t01) { include ("html/lyrics/".$_GET['track'].".htm"); } ?> The form HTML <FORM method="GET" action="../../index.php" name="myform01"> <select name="track"> <option value="a01-t01" SELECTED>Track 01</option> <option value="a01-t02">Track 02</option> <option value="a01-t03">Track 03</option> <option value="a01-t04">Track 04</option> </select> <BR><BR> <input type="submit" value="Go get the lyrics"> </FORM>
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.
Session Variables Across Multiple Pages
I'm busy fiddling with sessions under PHP5, and very quickly learned what I would have found out even sooner in the PHP manual - declaring your session variable on page1.php makes it available on page2.php (assuming that's the next page you load) but doesn't then make it available on page3.php unless you respecify it on page2.php. I'm sure there's a very good reason for it, and I know I can get around it by using a database and the session ID, but I would really like to know: why? I've already searched, but can't find any more information on the issue.
Reading Multiple Variables From One Cell
I'm currently using a text file to store some variables: $var1 = "value1"; $var2 = "value2"; $var3 = "value3"; I was thinking of writing these to a single mysql cell instead, i.e. a table contains a field called 'vars' and all the variables are written to the single mysql cell: $var1="value1"; $var2="value2"; $var3="value3"; Tricky part, how do I read the individual variables? I can read the field 'vars' as a variable, but I want the individual variables inside the 'vars' field.
Multiple Variables Set In A Cookie? NEWBIE
here is my situation; We have a form that gathers some information from a user ( name, email, street address), plus some samples of our product. what i would like to do is set a cookie that will store name, email, and what sample type they choose ( they can choose from one of three ). My plan is that when the customer returns to the site, the product specials will vary based on sample selections. I had a couple of ideas of how to do this but would like some feedback/advice from some pros. 1. A cookie sets name, email ( for list removal purposes), and sample type choosesn, I tried this a couple times and couldnt' get multiple variables, set to the cookie. 2. A mysql Database houses the customer data and a cookie sets the ID for the customer ( which is automatically set from the db), when the client returns the site reads the cookie of the customer entry, and recalls any data that the site needs.
Multiple Variables Eregi Check.....
This is an easy one I think but I just can't do it for some reson - I want to check more than one variable on the same line, not just address, but can't work out the syntax to do this... ie. So this code........ $crack=eregi("(to:)|(from:)|(cc:)|(bcc:)",$address); does this........ $crack=eregi("(to:)|(from:)|(cc:)|(bcc:)",$address and another variable); I want it so that if any of the variables meet the criteria set in the eregi function then $crack will be true (or 1).
Searching A Mysql Column Against Multiple Variables
I have an array of zipcodes which I am trying to check against a mysql table. I want to search in the column "zipcode" in a table of a bunch of entries. I want to search each rown to see if the value of the zipcode column is listed within my array. This could be said vis vera, that I want to check the mysql table to see if any of the rows have one of the values from the array inside the zipcode column. I've tried the statement "select * from table where zipcode IN ('$zipsearch')", but it seems to return an odd sequence of data. It doesn't seem thurow enough. similarly the entire statement is : select * from table where description like "%$trimmed%" OR title like "%$trimmed%" AND zipcode IN ('$zipsearch') order by date" I can't seem to get the statemtent to break up my requests right so that the logistics of teh statement are : select from table where (descriptions like variable or title like variable) AND <zipcode search problem>
Carrying Over Variables From A Form To Multiple Pages...
I have some data from text fields that are being passed over through a form that I am displaying with the $_POST superglobal. Once i have echo'd out this data onto the next page, i'd like to continue to use it on the next page. I haven't figured out how to do this properly just yet, but I'm guessing it has something to do with sessions. I have MANY variables being passed (over 100) and I'm hoping i don't have to register each one of these manually with $_SESSION[]. example. //first page (index.html) <form action="form.php" method="post"> <select name="color"><option value="blue">blue</option><option value="red">red</option> <input name="submit" type="submit"> //new page (form.php) <?php echo "Bill's favorite color is {$_POST['color']}"; ?> //// Now say I want to use this $_POST['color'] value on another page that the form.php takes you to next.....how do i continue to use this value across multiple pages? I'm assuming this is a trivial question, but i can't seem to figure it out!
Parsing Multiple Checkbox Variables Into A Database
I'm creating a page that includes check boxes that are pulled from a MySQL database. the user should then select which boxes they want, and then the values should be wrote back to the DB. however when the check boxes are returned they are all returned as the same value name, choice =1&22&choice=3%22 and so on. how can I parse this so that I can store the choices in the DB?
Insert Multiple Variables Into A Database Quickly
I've just started using PHP and have written a small script to insert 10 variables into my database, e.g: $query = "insert into items values ('".$q1."', '".$q2."', '".$q3."', '".$q4."', '".$q5."','".$q6."', '".$q7."', '".$q8."', '".$q9."', '".$q10."')"; The problem is, I will eventually need 300 questions so I don't want to list them all individually. How can change this snippet of code so that it says something along the lines of "please insert all the variables q1-q300 into the database"?
Multiple Query Variables Based On Str_word_count
I am attempting to split an input string using the str_word_count function to return multiple single word query variables. I can create an array based on $search=(str_word_count($search, 1, ?')); (I want words and/or numbers). I can extract named variables from the resulting array via $search=extract($search, EXTR_PREFIX_ALL, search); and then call each variable by $search_0 $search_1 $search_2, etc. Several issues that I am having: Since the size of the array is determined by user input. I can't hardcode $search_x, $search_y, etc. because I don't know what x, y, etc. will be. How can I produce $search_x... et al. and then hand it/them to a query string? I can echo desired output using for or while loops, (i.e. the *value* of $search_x...et al. but I can't figure out how to get them into query strings. I want my query strings to contain something like $q=" SELECT * FROM * WHERE table1.row1 LIKE '%$search_x%' OR LIKE '%$search_y%' etc..."
Eliminating Passed URL Variables For Multiple Listings On A Page
I have a page with a list of several users, each hyperlinked to another page of 'more info' about that user. The hyperlink contains the UserNumber, UserRegion, and UserStatus, and the receiving page picks up the data in the passed URL. This works well, but I'd like to eliminate the passing of these variables in the URL. One way is to make a graphic ('More Info') that can be clicked to submit a form. Each 'More info' graphic from the dynamically created page could hold the UserNumber, but how can I pass several variables with a single click? On some pages, there can be 100+ users, and I hate to have 100+ separate forms and hidden fields. I thought of using session variables, how can I know which user was clicked to set the session variables?
Posting Multiple Variables To $_POST Using HTML Forms
This is my code : <FORM ACTION="php_steptwo001.php" METHOD="POST"> <INPUT TYPE="HIDDEN" NAME="duration" VALUE=3> <INPUT TYPE="HIDDEN" NAME="banner" VALUE="test"> <INPUT TYPE="SUBMIT" VALUE"3 DAYS"> </FORM> Only the 1st Variable 'duration' gets passed!
Iterator First Item?
Let's say I have the code: foreach($data as $row) { do something with each $row } Is there a way to do something specific to the first item iterated? Pseudocode: foreach($data as $row) { if first time through iteration do something with $row else do something which each remaining $row } Is this possible? I think I could use a regular 'for' loop, using the length of the $data array as a guide, and then an 'if..else' structure to see if it is the first time through the 'for' loop, but I was looking for a more elegant solution.
Trying To Split The Item...
I'm trying to make a search thru my mySQL database, so it any keywords are found then I'm adding the details to the next item in an array that I create. I've tested the array and it is storing the information into the array properly because it echoes out all of the information correctly. My problem is that, at the beginning of each item in the array I have information that tells me what part of the database it was pulled from and the id number and also how many times the a keyword was found in that specific database entry. So you have something like this.. Code:
Get Last Item In URL String
I realize how elementary this is, I apologize. Maybe that's why I can't find the right answer. I've tried everything from EXPLODEing the string to SUBSTR_REPLACE. Can anyone tell me how to just get the last item in a URL string? Like turn this: /mydirectory/myimg.jpg into this: myimg.jpg
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?
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.
Search Item In Database
I made a function that does a case insensitive search. This works fine. But i'd like to improve that script so that it also returns items from the database that are partly similar to the search string. this is the script atm:
Delete Item From Database
I still can't figure out how to delete an item from my shoppingcart. I have tried different ways to do this, but its impossible. -a button or link that deletes a item from my database -the php script that deletes it here is a suggestion: $slett = "DELETE ID, VARE, MODELL, STR, ANTALL, PRIS, TOTALPRIS FROM USER_TRACK WHERE USER_ID = "$user_id""; But how can i assign this to a button?
Updating Item Numbers (or IDs)
After a while of deleting records in a MySQL db, there gets to be the gaps in the id numbering system. i.e. 1, 2, 3, 6, 7, 12, and so on. Is there a way to renumber the id system in a table for 1, 2, 3, 4, 5, 6, etc without manually going in and changing those numbers?
Returning Autogenerated ID On New Item
Lets say you have a form that when saved to the mysql database creates a unique incremental id. The form is just the first part of a series of things the user can do, so once the ID is created, the page would need to know immediately what this ID is. Is there a way to grab this ID instantly once it is created? Obviously if this were a sign-up for and a new user name and password are involved, you can have the user login after the initial set up and this select statement would bring back the ID. But the situation I have doesn't work like that. The way I have been dealing with this is simply to have a select statement after the initial insert that requests the record based on a couple of other fields that are likely unique. But this seems like a rather kludgy way of doing it. Is there some other solution.
What Does `Catalog`.item Like '%A-%' Mean? -MySQL?
I am looking at an old query and I cannot remember or figure out what this part of the query means: `Catalog`.item like '%A-%' It is the like '%A-%' I cannot figure out. Then entire query is:[color=blue] > SELECT * > FROM `Catalog` > WHERE `Catalog`.img_status = Ƈ' AND `Catalog`.item_type ='R' AND > `Catalog`.item like '%A-%' > ORDER BY `Catalog`.item_type[/color] And will not work without the Like part
Pulling In One Item Of Four Categories
Ive got an offers table which contains name, category_id I want to display all offers, however the first page will only display four offers (one of each category). My query is as follows so how do I do this part? Code:
Finding # Of Item From Query
I have a query that goes "SELECT item_name FROM products WHERE products.drink = 'juice'" . If I get back 12 results from this query I can make a list using a simple loop, that is fine . If I click on one of these list items I want to go to a detail page, again I can do this no probs. How do I carry over to the detail page the number that the item appeared in the original list, for example if a result was "orange" and it was the 5th one in the list, how do I carry over the number 5 to the detail page?
Populating Form Item From SQL Enum Set Rev#2
$sql = "SHOW COLUMNS FROM table LIKE 'subject' "; $qry = mysql_query($sql) or die("Query not valid: " . mysql_error()); $res = mysql_fetch_object($qry); // This returns a row with a field 'Type' containing 'enum(...)' $res->Type = str_replace('enum('', '', $res->Type); $res->Type = str_replace('')', '', $res->Type); //now the string is something like this: one','two','three $temp = explode('','',$res->Type); //temp is an array with as much elements as the enum while ($temp) print array_pop($temp); This way is much more easier using the elements since they are elements of an array. Cleaver isn't it?
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:
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.
How To Replace An Item In The Url Search String
Using PHP 4, what is the most elegant way to replace a parameter value in a url query string? I want to replace the "Order" parameter, but it could occur anywhere in the query string. myfile.php?Param1=Hi+there&Order=ColumnA&Param3=Bye+Bye myfile.php?Order=ColumnA myfile.php?Param1=Anotehr+example&Order=ColumnA after applying this function, I'd like the result of the above examples to be myfile.php?Param1=Hi+there&Order=ColumnB&Param3=Bye+Bye myfile.php?Order=ColumnB myfile.php?Param1=Anotehr+example&Order=ColumnB
Add Item To Shopping Cart Problem
i have a cart link in all of my listed products on the site. when i press this link i will generate a url like this http://www.mysite.com/index.htm?loc...art&productid=3 after i press this link the site cart.php will be included and add the wanted product to the cart, and show the cart. my problem now is after the cart is showed with the new product in it, when i press the F5 key in the browser to refresh the site, the same product will added to the cart once more, because the previous generated url is unchanged in the browser. have anyone a idea how to fix this problem?
How To Apply Css To A Table That Is The Only Item In A Php File Please
How to apply css to a table that is the only item in a php file please In the page that has just the one table that is to be included in the other 2 pages, there's some heavy css going on, plus the text in the table gets changed quite a lot on a daily basis. Usually, in my program, I can highlught the text that needs a different css applied to it and click on the css style that applies to it, but because the page only has the one table and nothing else, there's no mention of the link to the styles page?
Language Depending Item Url's
I'm using a little newsflash item on my webpage, which is some text in an iframe. I have one newsflash item in English and one in another language, newsflash-english.html and newsflash-other.html How can I serve newsflash-english.html to english surfers and newsflash-other.html to not english users ? depending on the browser language ?
|