473,385 Members | 1,402 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.

Why can't I save the data from the LIST/MENU ???

yuukiizawa
Here's the code::

[alternatif.php]
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $namakoneksi = mysql_connect("localhost","root","") or die ("Failed Connect");
  3. mysql_select_db("tanamanobat",$namakoneksi);
  4.  
  5. if (isset($_GET['pesan']))
  6. {
  7. echo $_GET['pesan'];
  8. }
  9. ?> <center> <?php
  10. $sqlTampil ="SELECT * FROM penyakit ORDER BY kd_penyakit";
  11. $qryTampil = mysql_query($sqlTampil) or die ("query failed".mysql_error());while ($dataTampil=mysql_fetch_array($qryTampil))
  12. ?> <form action="http://bytes.com/?menu=alternatif" method="post"> <select name="nm_penyakit"> <option value="" selected="selected">Choose Disease Name</option> <?php
  13. $sqlTampil ="SELECT * FROM penyakit ORDER BY kd_penyakit";
  14. $qryTampil = mysql_query($sqlTampil) or die ("gagal query".mysql_error());
  15. while ($dataTampil=mysql_fetch_array($qryTampil)) {
  16. ?> <option value="<?php echo $dataTampil['kd_penyakit']; ?>"> <?php echo $dataTampil['nm_penyakit']; ?> </option> <?php } ?> </select> <input type="submit" value="search" name="mysearch"/> </form> <?php
  17. if(isset($_POST['mysearch']))
  18. {
  19. $nm_penyakit=$_POST['nm_penyakit'];
  20. $sqlTampil2 ="SELECT * FROM penyakit WHERE kd_penyakit='".$nm_penyakit."'";
  21. $qryTampil2 = mysql_query($sqlTampil2) or die ("query failed".mysql_error());
  22. ?> <form action="http://bytes.com/alternatif_aksi.php?menu=alternatif&act=in put" method="post"> <table border="0" cellpadding="10" cellspacing="15" align="center"> <?php
  23. while ($dataTampil2=mysql_fetch_array($qryTampil2)) {
  24. ?> <tr><td colspan="40" bgcolor="#333333" align="center"><font color="#FFFFFF" face="Tahoma, Geneva, sans-serif" size="-1">Alternative of Herbal Plants</font></td> </tr> <tr> <td><input type="checkbox" name="cebo1" value="<?php echo $dataTampil2['to1']; ?>"/></td> <td><font color="#009900" face="Tahoma, Geneva, sans-serif" size="-1"><?php echo $dataTampil2['to1']; ?></font></td> </tr> <tr> <td><input type="checkbox" name="cebo2" value="<?php echo $dataTampil2['to2']; ?>"/></td> <td><font color="#009900" face="Tahoma, Geneva, sans-serif" size="-1"><?php echo $dataTampil2['to2']; ?></font></td> </tr> <tr> <td><input type="checkbox" name="cebo3" value="<?php echo $dataTampil2['to3']; ?>"/></td> <td><font color="#009900" face="Tahoma, Geneva, sans-serif" size="-1"><?php echo $dataTampil2['to3']; ?></font></td> </tr> <tr> <td><input type="checkbox" name="cebo4" value="<?php echo $dataTampil2['to4']; ?>"/></td> <td><font color="#009900" face="Tahoma, Geneva, sans-serif" size="-1"><?php echo $dataTampil2['to4']; ?></font></td> </tr> <tr> <td><input type="checkbox" name="cebo5" value="<?php echo $dataTampil2['to5']; ?>"/></td> <td><font color="#009900" face="Tahoma, Geneva, sans-serif" size="-1"><?php echo $dataTampil2['to5']; ?></font></td> </tr> <td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td> </tr> <td><font color="#009900" face="Tahoma, Geneva, sans-serif" size="-1"></font></td> </tr> <?php } } ?> </table> <table> <tr> <td><input type="submit" value="save" /></td> <td><input type="reset" value="refresh" /></td> <td><input type="button" value="  Batal  " onclick=self.history.back() class='back_inline'></td> </tr> </table> </form> </center>
  25.  

[alternatif_aksi.php]
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $namakoneksi = mysql_connect("localhost","root","") or die ("Failed Connection");
  3. mysql_select_db("tanamanobat",$namakoneksi);
  4.  
  5. ?> <?php
  6. $menu=$_GET['menu'];
  7. $act=$_GET['act'];
  8.  
  9. // Input Alternatif
  10. if ($menu=='alternatif' AND $act=='input')
  11. {
  12. if (isset($_POST['cebo1']))
  13. {
  14. $kd_altrntf = $_POST['kodealter'];
  15. $nm_penyakit = $_POST['nm_penyakit'];
  16. $cbo1 = $_POST['cebo1'];
  17. $cbo2 = $_POST['cebo2'];
  18. $cbo3 = $_POST['cebo3'];
  19.  
  20. echo "kd_penyakit : ".$kd_altrntf."<br />";
  21. echo "nm_penyakit : ".$nm_penyakit."<br />";
  22. echo "alt1 : ".$cbo1."<br />";
  23. echo "alt2 : ".$cbo2."<br />";
  24. echo "alt3 : ".$cbo3."<br />";
  25.  
  26. $tambah=mysql_query("INSERT INTO alternatif VALUES('$kd_altrntf','$nm_penyakit','$cbo1','$cbo2 ','$cbo3')"); }
  27. if ($tambah)
  28. //{ header ('location:index.php?menu=alternatif&pesan=Choosing is done');
  29. exit();
  30. // }
  31. else
  32. // { header ('location:index.php?menu=alternatif&pesan=Choosing Failed');
  33. exit();
  34. }
  35. //}
  36. ?>
  37.  

And also, I still don't get the way to saving data from checkboxes randomly checked...

Can somebody help to solve these? Thankyou :)
Sep 26 '12 #1

✓ answered by Rabbit

It's probably because the form that submits to the page alternatif_aksi.php doesn't have nm_penyakit or kodealter in its post data.

You can save checkbox data anyway you want. Some people use y/n to indicate checked or not. Some spell it out as yes/no. Some use 0/1. There are many variations, you just have to pick one that you like.

9 1944
Rabbit
12,516 Expert Mod 8TB
It's probably because the form that submits to the page alternatif_aksi.php doesn't have nm_penyakit or kodealter in its post data.

You can save checkbox data anyway you want. Some people use y/n to indicate checked or not. Some spell it out as yes/no. Some use 0/1. There are many variations, you just have to pick one that you like.
Sep 26 '12 #2
which one do you mean with "doesn't have nm_penyakit or kodealter in its post data." ?
Expand|Select|Wrap|Line Numbers
  1.  // Input Alternatif
  2. if ($menu=='alternatif' AND $act=='input')
  3. {
  4. if (isset($_POST['cebo1']))
  5. {
  6. $kd_altrntf = $_POST['kodealter'];
  7. $nm_penyakit = $_POST['nm_penyakit'];
  8. $cbo1 = $_POST['cebo1'];
  9. $cbo2 = $_POST['cebo2'];
  10. $cbo3 = $_POST['cebo3'];
  11.  
That ones?

but the CHECKBOX's contain is from different FIELD in database.. so that I can't use array calling in there.

Expand|Select|Wrap|Line Numbers
  1. <td><input type="checkbox" name="cebo1" value="<?php echo $dataTampil2['to1']; ?>"/></td>
  2. <td><font color="#009900" face="Tahoma, Geneva, sans-serif" size="-1"><?php echo $dataTampil2['to1']; ?></font></td></tr>
  3. <tr><td><input type="checkbox" name="cebo2" value="<?php echo $dataTampil2['to2']; ?>"/></td> <td><font color="#009900" face="Tahoma, Geneva, sans-serif" size="-1"><?php echo $dataTampil2['to2']; ?></font></td></tr>
  4. <tr><td><input type="checkbox" name="cebo3" value="<?php echo $dataTampil2['to3']; ?>"/></td> <td><font color="#009900" face="Tahoma, Geneva, sans-serif" size="-1"><?php echo $dataTampil2['to3']; ?></font></td></tr>
  5. <tr><td><input type="checkbox" name="cebo4" value="<?php echo $dataTampil2['to4']; ?>"/></td> <td><font color="#009900" face="Tahoma, Geneva, sans-serif" size="-1"><?php echo $dataTampil2['to4']; ?></font></td></tr>
  6. <tr><td><input type="checkbox" name="cebo5" value="<?php echo $dataTampil2['to5']; ?>"/></td> <td><font color="#009900" face="Tahoma, Geneva, sans-serif" size="-1"><?php echo $dataTampil2['to5']; ?></font></td></tr>
  7. <tr><td><font color="#009900" face="Tahoma, Geneva, sans-serif" size="-1"></font></td> </tr> <?php } } ?> </table> <table> <tr> <td><input type="submit" value="save" /></td> <td><input type="reset" value="refresh" /></td> <td><input type="button" value="  Batal  " onclick=self.history.back() class='back_inline'></td> </tr> </table> </form> </center>
  8.  
cebo1 to cebo5 will placed different Field in database..
Sep 27 '12 #3
https://plus.google.com/u/0/11563884...ts/JoasPzRkpez

That's link to the problems
The image named GNASHING of TEETH... would you mind to see it?
Sep 27 '12 #4
Rabbit
12,516 Expert Mod 8TB
Yes, that's the form that is missing the data I mentioned.

I have no idea what you're trying to say about the combo boxes, that has no bearing on the missing data.
Sep 27 '12 #5
About checkbox:

In Disease FORM, I have 5 values which I saved it in disease table named to1, to2, to3, to4 and to5. example: Apples -->to1, Carrot -->to2, until to5...

And then,
I call them (apple&friends) in Alternatif FORM using checkbox like in the image.
I made 3 fields in alternatif table named cbo1, cbo2 and cbo3 for saving the chosen one (I limited it just for 3 plants).

How can I save the data from checkbox randomly?
Example:
  • Apple
  • Carrot
  • Cherry
  • Spinach
  • Cabbage
then I want to chose only Carrot and Cabbage...
Sep 27 '12 #6
Rabbit
12,516 Expert Mod 8TB
That picture is too small for me to read the text on there.

I'm not sure what you mean by save it randomly. You should want to avoid random as much as possible. But if you're talking about how to map the 5 checkboxes to 3 fields in your table, the answer is you shouldn't. Your data is not normalized and that's why it's making it so difficult for you to query and update your data. You should really have another table for their checkbox choices. It would have two fields, a foreign key to the main table and their choice. If they make 3 choices, then there would be 3 rows in the choice table.
Sep 27 '12 #7
about the picture, you can click to make it zoomed

Yes, I want to map the 5 checkboxes to 3 fields...
Well, then you were so helpful. Thankyou so much for the solution :)
Sep 28 '12 #8
Rabbit
12,516 Expert Mod 8TB
My monitor at work is small so I still couldn't read it when I zoomed in. Either way, glad you got it working.
Sep 28 '12 #9
They only give you one tiny monitor? That sucks. Everyone should just know that devs, coders, and programmers should have at least two large wide-screens.
Sep 28 '12 #10

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

Similar topics

5
by: Derek | last post by:
Let's say I have a dynamic list/menu, which gets its values from a database table, for example a list of contact people where the value is an ID number and the label is the name. However, if the...
1
by: ARobi | last post by:
I edit data from a form by using docmd.close acform, formname, acsaveyes. The form closes properly and returns the control to the father form as it should be. The problem is that when from the...
1
by: Julia | last post by:
Hi, Is it possible to save ArrayList or other type in a resource file? I need to populate a list box with a predefined options and I would like to save them in a resource file I also don't...
0
by: Paul | last post by:
I am considering creating an app that will have an increasing number of items about which there's information. As info is added about a different new item (they're medicines, but that's not...
1
by: Michael | last post by:
Hi Everyone, I have a simple page right now to save an PO info to the server. I get the following error: "ExecuteNonQuery requires the command to have a transaction when the connection assigned...
4
by: fizzyfozzy | last post by:
Hi, I am trying to figure out how to show or hide a selection of divs on my page depending on what is selected from a list/menu item, using css & javascript. I have tried to use the script...
5
by: jmartmem | last post by:
Greetings, I am using Dreamweaver CS3 to design an ASP page that contains an Insert Record Form. Within this form are two list/menu form fields that I would like to "synchronize". In other words,...
1
by: jagjitsurfer | last post by:
hi, I am using datagrid view in my solution which displays data from a table of database. I allows users to directly update, insert or delete data from data grid view, but i can't save the data...
2
by: tamasu | last post by:
Hi, I am retrieving a selected item from a list/menu component on an HTML page. The said value is passed as a parameter to a method initiated through <jsp:useBean. I am aware that when...
1
by: amel86 | last post by:
Hello, I have a problem. I need to do multiple list menu which is populate each other when selected. The problem is my code run perfect on my localhost server but when i upload to the server the...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.