473,385 Members | 1,907 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

replace data in listbox with tht of textbox

116 100+
ok i have a list of data that gets displayed in listbox...

i want tht when i select any value in tht listbox and click on rename it should rename tht in the database with the value i provide in the text box.

i m able to get the values listed in list box...but its not renaming it .

here's my code
Expand|Select|Wrap|Line Numbers
  1. <body>
  2. <?php
  3.  
  4. $genre_name = $_POST['genre'];
  5. $genrename = 'genrename';
  6. $genrevalue = array();
  7. $genre_value = $_POST['genrename'];
  8.  
  9. $query_name = " SELECT image_category.genre FROM image_category ";
  10.     $result = mysql_query($query_name);
  11.     confirm_query($result);
  12.     $genrename_list[]=" ";
  13.  
  14.   while ($record = mysql_fetch_assoc($result)) {
  15.           $genrename_list[] = $record['genre'] ;
  16.  
  17.         }
  18.  
  19. ?>
  20. <?
  21.  
  22.  //-----------Rename genre in database ---------------------
  23.  if (isset($_POST['rename_genre'])) {
  24.  $query = "UPDATE image_category
  25.           SET image_category.genre = '$genre_name'
  26.           WHERE image_category.genre = '{$genrename_list[$genre_value]'";
  27. $result1 = mysql_query($query, $connection);
  28.  
  29. if ($result1) {
  30.             $message = "new genre has been renamed";
  31.  
  32.         }
  33.          else {
  34.          $message = "new genre could not be renamed";
  35.           }
  36. }
  37.  
  38.  ?>
  39.  
  40. <td id="page">
  41.  
  42. <form action="genre_rename.php" method="post">
  43. <table>
  44.  
  45. <td><br>
  46. <select name="genrename" maxlength="30">
  47.  
  48.         //-----------displays genre from database ---------------------
  49.  
  50.         <?php
  51.  
  52.         // Loops through the $status_list array
  53.          foreach ($genrename_list as $value => $option)
  54.         {
  55.             // Sets an attribute to show the chosen status as selected
  56.             $selected = ($genre_value == $value) ? ' selected="selected"' : '';
  57.            //$status = (isset($_get['status'])) ? $_get['status'] : "";
  58.  
  59.             // Builds an option for each acceptable status
  60.            echo '<option value="'.$value.'"'.$selected.'>'.$option.'</option>';
  61.            // echo '<option value="'.$value.'"'.$status.'>'.$option.'</option>';
  62.         }
  63.         ?>
  64.  
  65.  
  66.  </select> </td>
  67. <tr>
  68.                     <td>Genre</td>
  69.                     <td><input type="text" name="genre" maxlength="20" value="<?php echo htmlentities($genre_name); ?>" /></td>
  70.                 </tr>
  71.  
  72. <tr>
  73.                     <td colspan="2"><input type="submit" name="rename_genre" value="rename_genre" /></td>
  74.                 </tr>
  75.  
  76.             </table>
  77.  
  78. </form>
  79. </td>
  80.  
  81.  
  82.  
  83.  
  84. </body> 
  85.  
  86.  

plz tell where i m going wrong...and what i need to change where
Apr 28 '09 #1
10 2308
Ciary
247 Expert 100+
i think this is:

Expand|Select|Wrap|Line Numbers
  1. if (isset($_POST['rename_genre'])) {
  2.  
it needs to be this
Expand|Select|Wrap|Line Numbers
  1. if (isset($_POST['genre'])) {
  2.  
Apr 28 '09 #2
angelicdevil
116 100+
nope not working ... i chaned it to genre as u said ciary its not working
May 2 '09 #3
Ciary
247 Expert 100+
try this:

Expand|Select|Wrap|Line Numbers
  1. $query = "UPDATE image_category
  2. SET image_category.genre = ".$_post['genre']."
  3. WHERE image_category.genre = ".$genrename_list[$genre_value];
hope that helped.
May 4 '09 #4
angelicdevil
116 100+
its still not working
May 5 '09 #5
Ciary
247 Expert 100+
Expand|Select|Wrap|Line Numbers
  1. $selected = ($genre_value == $value) ? "selected": "'';
  2.  
i hope it works then. i'm getting out of options what can be wrong.
May 5 '09 #6
angelicdevil
116 100+
nope i have no idea where its going wrong ....its not working. if u can create a new code and see if it works as probably there;'s some small error somewhere that we r not able to see it.
May 5 '09 #7
angelicdevil
116 100+
ok i rewrote the whole script n got it to work
May 5 '09 #8
Ciary
247 Expert 100+
ok, great :)
did you find out where your previous code failed?
May 6 '09 #9
angelicdevil
116 100+
actually i cleaned up the code a lot and rewrote the whole thing.
May 6 '09 #10
Ciary
247 Expert 100+
i'm glad it works now. i hope my help was of any use
May 6 '09 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: John R. | last post by:
I want to have a listbox that shows a checkbox and a textbox. I created a user control that has a checkbox and a textbox in it and have been trying to add it to a listbox but I can't get it to...
6
by: Janaka | last post by:
Help! I have two ListBox controls on my web form. The first one gets populated on entry with values from the DB. I then use JavaScript to copy options from this ListBox to my second one. (I...
3
by: Husam | last post by:
Hi EveryBody: I made project by Vb.Net which consist the following items: 1\ Textbox 2\Button 3\Listbox When you write any thing in the textbox and press the button any text written in...
1
by: IanONet | last post by:
I have used onChange="ReplaceValues(this.options.value)" to change several textbox values when a user makes a selection from a Select List. Now I have the requirement to replace all the values...
1
by: Peter | last post by:
Hi, I'm trying to create a form that shows table rows in a listbox. Several comboboxes expand the foreign key fields into text values from the parent tables, and there are also some textboxes...
0
by: EricLondaits | last post by:
Hi, I have an ASP.NET page with a ListBox that is data bound to a table with a single field (it holds a list of valid IDs). The page also has a textBox into which you can add new valid IDs, one...
1
by: semomaniz | last post by:
I have a form where i have created the form dynamically. First i manually added a panel control to the web page. Then i added another panel dynamically and inside this panel i created tables. I have...
8
by: jh | last post by:
I'd like to copy/paste into a listbox during runtime. I can do this for a textbox but can't figure out how to accomplish this for a listbox. Any help? Thanks.
15
by: Doogie | last post by:
I have a .net app that a user currently enters a number in a text box, hits a button and a data call is executed. She wants the ability to enter in multiple numbers (up to 100). So to make...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.