PHP - Selecting Table From A Dropdown List
Hi,
I've got a basic sign up form but I want a drop down list which will list different catergories that relate to different tables which when selected will input the sign up information into that table which was selected from the catergory drop down. This is the signup form <html><head><title>Birthdays Insert Form</title> <style type="text/css"> td {font-family: tahoma, arial, verdana; font-size: 10pt } </style> </head> <body> <table width="300" cellpadding="5" cellspacing="0" border="2"> <tr align="center" valign="top"> <td align="left" colspan="1" rowspan="1" bgcolor="64b1ff"> <h3>Insert Record</h3> <form method="POST" action="test.php"> <? print "Enter Company Name: <input type=text name=company_name size=30><br>"; print "Enter Contact Name: <input type=text name=contact_name size=30><br>"; print "Enter Telephone: <input type=text name=telephone size=20><br>"; print "Enter Fax: <input type=text name=fax size=30><br>"; print "Enter Email: <input type=text name=email size=30><br>"; print "Enter Address: <input type=text name=address1 size=20><br>"; print "Enter Address: <input type=text name=address2 size=30><br>"; print "Enter Postcode: <input type=text name=postcode size=30><br>"; print "Enter Town / City: <input type=text name=town_city size=20><br>"; print "Enter Website: <input type=text name=website size=30><br>"; print "Enter Company Type: <select name='table'> <option>stationary</option><option>reception</option></select><br>"; print "<br>"; print "<input type=submit value=Submit><input type=reset>"; ?> </form> </td></tr></table> </body> </html> This is the part which I can't figure out and is probably totally wrong! Im trying to use this script to sort the drop down list to then run the correct script to insert the form data. <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Hello!</title> </head> <body> <?php if($_POST['table']=='stationary' 'birthdays_insert_record.php') else if($_POST['table']=='reception' 'insert_reception.php') ?> </body> </html> This is the script which works! that inserts the form data into a specific table <html><head><title>Birthdays Insert Record</title></head> <body> <? /* Change db and connect values if using online */ $company_name=$_POST['company_name']; $contact_name=$_POST['contact_name']; $telephone=$_POST['telephone']; $fax=$_POST['fax']; $email=$_POST['email']; $address1=$_POST['address1']; $address2=$_POST['address2']; $postcode=$_POST['postcode']; $town_city=$_POST['town_city']; $website=$_POST['website']; $db="myflawlesswedding"; $link = mysql_connect('localhost', 'root' , ''); if (! $link) die(mysql_error()); mysql_select_db($db , $link) or die("Select Error: ".mysql_error()); $result=mysql_query("INSERT INTO reception (company_name, contact_name, telephone, fax, email, address1, address2, postcode, town_city, website) VALUES ( '$company_name', '$contact_name', '$telephone', '$fax', '$email', '$address1', '$address2', '$postcode', '$town_city', '$website')") or die("Insert Error: ".mysql_error()); mysql_close($link); print "Record added"; ?> <form method="POST" action="birthdays_insert_form.php"> <input type="submit" value="Insert Another Record"> </form> <br> <form method="POST" action="birthdays_dbase_interface.php"> <input type="submit" value="Dbase Interface"> </form> </body> </html> I hope somebody can help me out here! or can point me in a better way to sort this problem! Thanks for any advice! Similar TutorialsHi? im just a beginner in php i just want to ask how to insert a data into a table from a dropdown list. I have concatenate the itemid and description to form the dropdown list. But when i viewed my item_table the itemid and description columns are null. can you help me with this.. this is my php code for the dropdown list... <?php $query = "SELECT CONCAT(itemid,' ', '-',' ', description) AS Item FROM item_table"; $result = mysql_query($query) or die(mysql_error()); $dropdown = "<SELECT CONCAT(itemid,' ' '-',' ', description) AS Item FROM item_table>"; while($row = mysql_fetch_assoc($result)) { $dropdown .= "\r\n<option value='{$row['Item']}'>{$row['Item']}</option>"; } $dropdown .= "\r\n</select>"; echo $dropdown; ?> this my code for inserting data into the item_table... <?php if(isset($_POST ['submit'])) { $itemid = $_POST['itemid']; $description = $_POST['description']; $datein = $_POST['datein']; $qtyin = $_POST['qtyin']; $unitprice = $_POST['unitprice']; $unit = $_POST['unit']; $category = $_POST['category']; $empid = $_POST['empid']; $message =''; if(($itemid && $description == "")||($itemid && $description == null)) { header("location:IncomingEntry.php?msg=Incorrect"); exit(); } else { $link = mysql_connect('localhost', 'root', '') or die(mysql_error()); $db_selected = mysql_select_db('inventory', $link); $message=''; $query = "INSERT INTO incoming_table (itemid , description, datein, qtyin, unitprice, unit, category, empid) VALUES ('".$itemid."', '".$description."', '".$datein."', '".$qtyin."', '".$unitprice."', '".$unit."', '".$category."', '".$empid."')"; if (!mysql_query($query,$link)) { die('Error: ' . mysql_error()); } header("location: IncomingEntry.php?msg=1 record added"); } } ?> Hello everyone !!! I am sorry if my vocabulary is not exact because english is not my first language. Also i am a newbie at PHP. I am doing this project for myself and if it work might be able to use it at work. But i am doing this to learn. I have been stuck on this problem for 2 weeks and i can t figure it out on my own. Ihave spend many hours searching forums but no success. Oh yeah i almost forgot some part of code are from me, some are scripts from internet i adapted. I have a form with a dropdown menu and when i submit the form the value selected in the dropdown would be inserted in a table. The problem i have is that whatever the value i select it always inserts the last value of the dropdown in the table??? The form is made with the dropdown as an include. It is populated with values from an another table. Here is the code for the dropdown list: Code: [Select] <form> <select name="nom_pcu_form" method="post"> <?php $SQL = "SELECT * FROM pcu ORDER BY nom_pcu"; $res = mysql_query($SQL); while($val=mysql_fetch_array($res)) { $nom=$val["nom_pcu"]; $prenom=$val["prenom_pcu"]; $nom_complet = $prenom . $nom; echo "<option>".$val["nom_pcu"].", ".$val["prenom_pcu"]."</option>\n"; $nom_pcu_form="".$val["nom_pcu"].", ".$val["prenom_pcu"].""; } ?> </select> </form> Here is the part of the form wich calls the dropdown: Code: [Select] <form name="form2" method="post" action="Grille ecoute Permanent.php"> <p>Nom : <?php include 'liste_deroulante_pcu.php' ;?> <p>no carte appel <input name="no_carte_appel" type="text" id="no_carte_appel"> </p> <?php echo date("Y/m/d"); ?> </form> And this is the part where it is inserted in the table: Code: [Select] <?php if($_POST['doSubmit'] == 'Create') mysql_query("INSERT INTO grille_ecoute_pcu_permanent (`user_name`,`nom_pcu`,`no_carte_appel`,`question_1`,`question_2`,`question_3`,`question_4`, `question_5`,`question_6`,`question_7`,`question_8`,`question_9`,`question_10`,`question_11`,`question_12`,`question_13`,`question_14`,`question_15`, `question_16`,`question_17`,`question_18`,`question_19`,`question_20`,`question_21`,`question_22`,`question_23`,`question_24`,`question_25`,`question_26`, `question_27`,`question_28`,`question_29`) VALUES ('$user_name','$nom_pcu_form','$no_carte_appel','$question_1','$question_2','$question_3','$question_4','$question_5','$question_6', '$question_7','$question_8','$question_9','$question_10','$question_11','$question_12','$question_13','$question_14','$question_15','$question_16','$question_17', '$question_18','$question_19','$question_20','$question_21','$question_22','$question_23','$question_24','$question_25','$question_26','$question_27','$question_28', '$question_29') ") or die(mysql_error()); Note:$user_name and all $question are inserted correctly in the table. $nom_pcu_form is the dropdown and it only records the last value of the dropdown even if it s not the value selected. $no_carte_appel are not recorded at all thanks for your time I have a sql query similar to below in a .php file.
$sql = "select id,organisation,price from table where category = '$category';
These are the four unique values of the category column for your reference.
"A-t1"
"B-t1"
"C-t1"
"D-t1"
Now I want to create a dropdown list or listbox in .php file with option to select multiple values. If customer selects multiple values, it should fetch query for the selected categories.
E.g. dropdown list should be similar to below :
"A-t1"
"B-t1"
"C-t1"
"D-t1"
If an user selects "A-t1" and "C-t1", it should give output/query for the selected categories.
Hi all I am having some problems with the logic behind a simple idea. Basically I have a list which returns the names of players from a json request, what I simply want to do is for the user to click on the name which then activates it, so basically they can then run a command directed at that name, so something like Code: [Select] Names a b c[onlick select] d Action Ban Thanks Hi, basically, here's the deal: I have a lit of checkboxes that are added by the admin (there's an unlimited amount, just depends on how many are added). Then, those are put in a form, in which the user picks whichever ones need to be chosen and those values get sent to a MySQL table. Here's the code that displays the checkboxes Code: [Select] <?php $sql="SELECT * FROM category ORDER BY categoryID ASC"; $result=mysql_query($sql); while($row=mysql_fetch_array($result)){ echo "<input type='checkbox' id='". $row['categoryName'] ."' name='licensed[]' value='" . $row['categoryID'] ."' /><label for='". $row['categoryName'] ."'><br>" . $row['categoryName'] ."</label><br>"; } ?> What I'm making now, is an edit form where whichever checkboxes were checked, will show up checked in the edit form. But I'm not really sure how to go about this, since there is only one actual input tag in the code, I can't select the different ones. I also have this SQL query which selects whichever boxes were inputted into the DB Code: [Select] $sql2="SELECT * FROM category, categoryInfo WHERE category.categoryID = categoryInfo.categoryID AND categoryInfo.parentID = $parentID"; $result2=mysql_query($sql2); Where $parentID is the ID of whichever form you're editing. But yes, I'm basically not really sure how to go about this and would like some help figuring this out Thanks for your time Hi All ,
I have a small table with 4 fields namely Day_ID, Dues, Last_Visit, Points. where Day_ID is an auto-increment field. The table would be as follows:
Day_ID -- Dues --- Last_Visit --- Points.
1 --------- 900 -------- 1/12 -------- 6
2 --------- 700 -------- 4/12 -------- 7
3 --------- 600 -------- 7/12 -------- 5
4 --------- 600 -------- 9/12 -------- 6
5 --------- 600 -------- 10/12 ------- 6
6 --------- 600 -------- 14/12 ------- 6
So this is the record of a person's visit to say a club. The last row indicates the last date of his visit to the club. His points on this date are 6. Based on this point value of 6 in the last row I want to retrieve all the previous BUT adjoining all records that have the same Points i.e. 6.
So my query should retrieve for me, based on the column value of Points of the last row (i.e. Day_ID - 6 ), as follows:
4 --------- 600 -------- 9/12 -------- 6
5 --------- 600 -------- 10/12 ------- 6
6 --------- 600 -------- 14/12 ------- 6
This problem stated above had been completely resolved, thanks to a lot of help from Guru Barand by this following query :-
$query = "SELECT cv.day_id, cv.dues, cv.last_visit, cv.points FROM clubvisit cv WHERE last_visit >= ( SELECT MAX(last_visit) FROM clubvisit WHERE points <> ( SELECT points as lastpoints FROM clubvisit JOIN ( SELECT MAX(last_visit) as last_visit FROM clubvisit ) as latest USING (last_visit) ) )";I am using this and it works perfectly except that now there is a slight change in the table because the criteria for points is now dependent on more than one column cv.points and is more like cv.points1, cv.points2, cv.points3 etc. So now I need to make a selection based on each of these cv.points columns. As of now I can still get the results by running the query multiple times for each of the cv.points columns ( seperately for cv.points1, cv.points2, cv.points3) and it works correctly. However I am wondering if there is a better way to do this in just one go. This not only makes the code repetitive but also since the queries are interconnected, involves the use of transactions which I wish to avoid if possible. The values that I require for each of the cv.point columns is 1. day_id of the previous / old day on which the cv.points value changed from the current day value, and 2. cv.points on that old/ previous day. So for example if the table is as below: Day_ID -- Dues --- Last_Visit --- Points1 --- Points2. 1 --------- 900 -------- 1/12 ----------- 9 ------------ 5 2 --------- 600 -------- 4/12 ----------- 6 ------------ 6 3 --------- 400 -------- 7/12 ----------- 4 ------------ 7 4 --------- 500 -------- 9/12 ----------- 5 ------------ 8 5 --------- 600 -------- 10/12 ---------- 6 ------------ 8 6 --------- 600 -------- 11/12 ---------- 6 ------------ 8 7 --------- 600 -------- 13/12 ---------- 6 ------------ 7 8 --------- 500 -------- 15/12 ---------- 5 ------------ 7 9 --------- 500 -------- 19/12 ---------- 5 ------------ 7 Then I need the following set of values : 1. day_id1 -- Day 7, points1 ---- 6, days_diff1 -- (9-7 = 2) . // Difference between the latest day and day_id1 2. day_id2 -- Day 6, points2 ---- 8, days_diff2 -- (9-6 = 3) 3. day_id3 -- .... and so on for other points. Thanks all ! I have a table called users with a fieldname called service_id. In a table called services I have id and name. I want to query the users table and, based on the service_id, display the name of the service (which is stored in the services table). However, when I try this code I get No records returned. I later echo out under a while statement $row['name']; or $row['id'] $query = "SELECT users.username, users.lname, users.fname, users.service_id, services.name, services.id FROM users, services WHERE users.inst_id = '".$userarray['inst_id']."' and users.id !='".$userarray['id']."' and users.service_id = services.id "; Hi All, I am trying to pull a record from my table using the date of birth column (which is a date column) like so.. Code: [Select] $birthday = ('1936-08-21'); $query = "Select * from my_table where dob = $birthday"; $result = mysql_query($query); while ($row = mysql_fetch_array($result)){ echo "Name is - " .$row['name']; } I know there is a record in the table with a date of birth(dob) value of 1936-08-21 but it does not return any records ? thanks for looking, Tony Hi, I am trying to call the data from Mysql but I am getting an empty drop down list, this is the code: mysql: Code: [Select] create table years ( yearID integer auto_increment, year varchar(30), primary key (yearID) ); insert into years (yearID, year) values ('1', '2007-2008'); insert into years (yearID, year) values ('2', '2008-2009'); insert into years (yearID, year) values ('3', '2009-2010'); insert into years (yearID, year) values ('4', '2010-2011'); insert into years (yearID, year) values ('5', '2011-2012'); insert into years (yearID, year) values ('6', '2012-2013'); PHP: Code: [Select] <?php require_once('../Connections/connection.php'); ?> <?php $result = @mysql_query( "select yearID, year, from sss.years"); print "<p>Select a year:\n"; print "<select name=\"yearID\">\n"; while ($row = mysql_fetch_assoc($result)){ $yearID = $row[ 'yearID' ]; $year = $row[ 'year' ]; print "<option value=$yearID>$year\n"; } print "</select>\n"; print "</p>\n"; ?> Thank you! Hey, I have the following coding: Quote <? $dbuser="*******"; $dbpass="*******"; $dbname="virtuda_db"; //the name of the database $chandle = mysql_connect("localhost", $dbuser, $dbpass) or die("Connection Failure to Database"); mysql_select_db($dbname, $chandle) or die ($dbname . " Database not found. " . $dbuser); $mainsection="license"; $query1="select name from license"; $result = mysql_db_query($dbname, $query1) or die("Failed Query of " . $query1); //do the query while($thisrow=mysql_fetch_row($result)) { $i=0; while ($i < mysql_num_fields($result)) { $field_name=mysql_fetch_field($result, $i); echo $thisrow[$i] . " "; //Display all the fields on one line $i++; } echo "<br>"; //put a break after each database entry } ?> How would I set up this so that instead of just "listing" them out on new lines, it would list the results into a drop down list? Thanks! Hi i'm new to php. I want to get all the values of dropdown list on another page wether selected or not. Hi. I am using this script to populate a dropdown list box from sql, it works but does anyone know how to sort the list in alphabetical order? $sql="SELECT * FROM Fish WHERE ***** = '".$_GET['stocktype']."'"; $result=mysql_query($sql); $options=""; while ($row=mysql_fetch_array($result)) { $ID=$row["ID"]; $Stock=$row["Commonn"]; $Options.="<OPTION VALUE=\"$ID\">".$Stock; } <SELECT NAME='stock1'> <OPTION VALUE='$Options'>$Options</option> </SELECT> I'm trying to sort this dropdown box. It reads from a directory, and lists the file name in the dropdown box. Here's the tricky part... the filename is listed differently in the dropdown than in the directory by using explode(). I want to sort it though since it's still being sorted by the directory listings... For example: Filename starts out as: 123_abc_567.pdf then gets listed as abc_123_567.pdf in the dropdown, but it's still getting sorted as if it were 123_abc_567.pdf How can I do that? Here's my code: // Define the full path to folder from root $path = "C:/Work_Orders/"; // Open the folder $dir_handle = @opendir($path) or die("Unable to open $path"); echo "<form method=\"POST\" action='".$_SERVER['PHP_SELF']."' name='selectworkorder'><select name='ordernumber2'>"; // Loop through the files while ($file = readdir($dir_handle)) { //Remove file extension $ext = strrchr($file, '.'); if($ext !== false) { $file = substr($file, 0, -strlen($ext)); } if($file == "." || $file == ".." || $file == "index.php" ) continue; //explode file name $changedordernumber = explode("_",$file); //put in new order $changedordernumber = $changedordernumber[1]."_".$changedordernumber[0]."_".$changedordernumber[2]; $changedordernumber=trim($changedordernumber,"_"); //list options echo "<option name='$file' value='$file'>$changedordernumber</option>\n"; } echo "</select><input type='submit' value='Change' name='submit'/></form></div>"; // Close closedir($dir_handle); Hey Guys, I know it may seem pretty simple, but im having trouble populating a drop down list. Here is my code at the moment, but what it's doing is displaying the names all in one value, where it should be in separate select values. *Note that i have only done it to the first one. See attachment. 'AntonMatt' are next to each other, they should be separate select values. Code: [Select] <? $id = $_GET['id']; $selectplayers="SELECT * FROM players WHERE club='$club' AND team='$team'"; $player=mysql_query($selectplayers); ?> <table class='lineups' width="560" cellpadding="5"> <tr> <td colspan="2">Starting Lineup</td> <td colspan="2">On the Bench</td> </tr> <tr> <td width="119"> </td> <td width="160"> </td> <td width="69"> </td> <td width="160"> </td> </tr> <tr> <td>Prop</td> <td><select name="secondary" style="width: 150px"> <option value='' selected="selected"><? while($rowplayer = mysql_fetch_array($player)) { echo $rowplayer['fname']; } ?></option> </select></td> <td>16.</td> <td><select name="secondary16" style="width: 150px"> <option value='' selected="selected">Secondary Position</option> </select></td> </tr> <tr> <td style="padding-top: 8px;">Hooker</td> <td style="padding-top: 8px;"><select name="secondary2" style="width: 150px"> <option value='' selected="selected">Secondary Position</option> </select></td> <td style="padding-top: 8px;">17.</td> <td style="padding-top: 8px;"><select name="secondary17" style="width: 150px"> <option value='' selected="selected">Secondary Position</option> </select></td> </tr> </table> </div> </div> If I can get this fixed, I will have completed all but the admin login for this project - my first php/mysql project. Here is what I need. I have a list_records.php that list all the records in the table 'links' and the category each entry is in from the table 'categories'. Here are my table structures. Code: [Select] -- Table structure for table `categories` -- DROP TABLE IF EXISTS `categories`; CREATE TABLE IF NOT EXISTS `categories` ( `id` int(11) NOT NULL AUTO_INCREMENT, `categories` varchar(37) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=40 ; -- -------------------------------------------------------- -- -- Table structure for table `links` -- DROP TABLE IF EXISTS `links`; CREATE TABLE IF NOT EXISTS `links` ( `id` int(4) NOT NULL AUTO_INCREMENT, `catid` int(11) DEFAULT NULL, `name` varchar(255) NOT NULL DEFAULT '', `url` varchar(255) NOT NULL DEFAULT '', `content` varchar(255) NOT NULL DEFAULT '', PRIMARY KEY (`id`), KEY `catid` (`catid`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=35 ; On the update.php file, I have a form that lets me make changes to the record. Here is the codes for update.php Code: [Select] <? include "menu.php" ?> <? include "db.php" ?> <?php $id=$_GET['id']; $sql = "select * from links where id =$id"; $query = mysql_query($sql); while ($row = mysql_fetch_array($query)){ $id = $row['id']; $catid = $row['catid']; $name = $row['name']; $url = $row['url']; $content = $row['content']; //we will echo these into the proper fields } mysql_free_result($query); ?> <table width="65%" align="center"> <tr><td align="left"> <form action="updated.php" method="post"> <input type="hidden" value="<?php echo $id; ?>" name="id"/> <br> <b>Website Name:</B><br> Change the name of the website listing.<br> <input type="text" value="<?php echo $name; ?>" name="name"/> <br> <br> <b>URL:</b><br> Change the URL of the website listing.<br> <input type="text" value="<?php echo $url; ?>" name="url"/> <br> <br> <b>Description:</b><br> Change the description of the website listing.<br> Limit 255 characters.<br/> <textarea name="content" cols="45" rows="4" wrap="soft"><?php echo($content);?></textarea> <br> <?php $result = mysql_query("SELECT id, categories FROM categories") or die(mysql_error()); while ($row = mysql_fetch_array($result)) { $id = $rows["id"]; $categories=$row["categories"]; $options.= '<option value="'.$row['id'].'">'.$row['id'].'-'.$row['categories'].'</option>'; }; ?> <SELECT NAME=catid> <OPTION VALUE=selected><? echo $catid; ?><? echo $options; ?></OPTION> </SELECT> <?php mysql_close(); ?> <div align="center"> <input type="submit" value="submit changes"/> </div> </form> <br> </td></tr></table> The part of he code I need help with is Code: [Select] <?php $result = mysql_query("SELECT id, categories FROM categories") or die(mysql_error()); while ($row = mysql_fetch_array($result)) { $id = $rows["id"]; $categories=$row["categories"]; $options.= '<option value="'.$row['id'].'">'.$row['id'].'-'.$row['categories'].'</option>'; }; ?> <SELECT NAME=catid> <OPTION VALUE=selected><? echo $catid; ?><? echo $options; ?></OPTION> </SELECT> I want it to default to the category that the entry is in. If you look, you will see in the select portion that I I have Code: [Select] <$ echo $catid; ?> which echos the proper category ID, but if I use Code: [Select] <? echo $categories; ?> it echos Writing, which is the last category in the list. Yet, the $options echo the catid and it corresponding category. How can I get the default option to echo BOTH the catid and category name while also listing all the other categories so that the records can be moved to a new category is needed? Any help will be appreciated. Thank you in advance. i have been trying to get this code to get a list of usernames from a database and i have now got that to work but when i try and save it it saves all the usernames from the drop down list and not just the one i have selected how can i get it to just use the one i have selected Code: [Select] <?php include "connect.php"; //connection string include("include/session.php"); print "<link rel='stylesheet' href='style.css' type='text/css'>"; print "<table class='maintables'>"; print "<tr class='headline'><td>Post a message</td></tr>"; print "<tr class='maintables'><td>"; // Write out our query. $query = "SELECT username FROM users"; // Execute it, or return the error message if there's a problem. $result = mysql_query($query) or die(mysql_error()); $dropdown = "<select name='username'>"; while($row = mysql_fetch_assoc($result)) { $dropdown .= "\r\n<option value='{$row['username']}'>{$row['username']}</option>"; } $dropdown .= "\r\n</select>"; if(isset($_POST['submit'])) { $name=$session->username; $yourpost=$_POST['yourpost']; $subject=$_POST['subject']; $to=$dropdown; if(strlen($name)<1) { print "You did not type in a name."; //no name entered } else if(strlen($yourpost)<1) { print "You did not type in a post."; //no post entered } else if(strlen($subject)<1) { print "You did not enter a subject."; //no subject entered } else { $thedate=date("U"); //get unix timestamp $displaytime=date("F j, Y, g:i a"); //we now strip HTML injections $subject=strip_tags($subject); $name=strip_tags($name); $yourpost=strip_tags($yourpost); $to=strip_tags($to); $insertpost="INSERT INTO forumtutorial_posts(author,title,post,showtime,realtime,lastposter,name) values('$name','$subject','$yourpost','$displaytime','$thedate','$name','$to')"; mysql_query($insertpost) or die("Could not insert post"); //insert post print "Message posted, go back to <A href='forum.php'>Forum</a>."; } } else { print "<form action='newtopic.php' method='post'>"; print "Your name:<br>"; print "$session->username<br>"; print "User to send to:<br>"; print "$dropdown"; print "Subject:<br>"; print "<input type='text' name='subject' size='20'><br>"; print "Your message:<br>"; print "<textarea name='yourpost' rows='5' cols='40'></textarea><br>"; print "<input type='submit' name='submit' value='submit'></form>"; } print "</td></tr></table>"; ?> MOD EDIT: Changed PHP manual link [m] . . . [/m] tags to [code] . . . [/code] tags. I have the following code currently: Code: [Select] <?php foreach ((array)$node->field_buy_at as $item) { ?> <?php print $item['view'] ?> <?php } ?> I would like to make the list a drop down with a link so that when a user selects, he goes to a new page. I tried the following: Code: [Select] <select name="select"> <?php foreach ((array)$node->field_buy_at as $item) { ?> <?php $url = $node->field_buy_at[0]['url']; $store = $item['view']; ?> <? echo "<option value='$url'>$store</option>";?> <?php } ?> </select> I'm pretty sure it's this "$url = $node->field_buy_at[0]['url'];" that I don't have correct. Alright, so I have an xml file differences.xml that is being parsed in XML. This is what the xml looks like: <item code="lM" name="dog"> <cost>5000</cost> <Start>12/15/2010</Start> <End>01/13/2011</End> </item> <item code="lF" name="cat"> <cost>5000</cost> <Start>04/15/2010</Start> <End>04/23/2011</End> </item>[/ I want to have the item names (dog, cat) show in a dropdown menu so that I can select these items for editing before storing in my mysql database. This is the php code I have so far: <?PHP $xml = simplexml_load_file("differences.xml"); $object = $xml->xpath("//item"); echo '<SELECT name=object>'; foreach ($object['name'] as $key => $value) { echo '<OPTION value='.$value.'> '.$value; } echo '</select>'; ?> I do have a dropdown list but there are no values inside it (it is empty). Can anyone help me figure out why? I do have this code that does work which lists the items in plaintext (not in a dropdown) so hopefull this will help us out: <?PHP $xml = simplexml_load_file("differences.xml"); $object = $xml->xpath("//item"); $count = count($object); $i = 0; while($i < $count) { echo '<h1>'.$object[$i]['name'].'</h1>'; $i++; } ?> This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=316599.0 |