Here's the code::
[alternatif.php] -
<?php
-
$namakoneksi = mysql_connect("localhost","root","") or die ("Failed Connect");
-
mysql_select_db("tanamanobat",$namakoneksi);
-
-
if (isset($_GET['pesan']))
-
{
-
echo $_GET['pesan'];
-
}
-
?> <center> <?php
-
$sqlTampil ="SELECT * FROM penyakit ORDER BY kd_penyakit";
-
$qryTampil = mysql_query($sqlTampil) or die ("query failed".mysql_error());while ($dataTampil=mysql_fetch_array($qryTampil))
-
?> <form action="http://bytes.com/?menu=alternatif" method="post"> <select name="nm_penyakit"> <option value="" selected="selected">Choose Disease Name</option> <?php
-
$sqlTampil ="SELECT * FROM penyakit ORDER BY kd_penyakit";
-
$qryTampil = mysql_query($sqlTampil) or die ("gagal query".mysql_error());
-
while ($dataTampil=mysql_fetch_array($qryTampil)) {
-
?> <option value="<?php echo $dataTampil['kd_penyakit']; ?>"> <?php echo $dataTampil['nm_penyakit']; ?> </option> <?php } ?> </select> <input type="submit" value="search" name="mysearch"/> </form> <?php
-
if(isset($_POST['mysearch']))
-
{
-
$nm_penyakit=$_POST['nm_penyakit'];
-
$sqlTampil2 ="SELECT * FROM penyakit WHERE kd_penyakit='".$nm_penyakit."'";
-
$qryTampil2 = mysql_query($sqlTampil2) or die ("query failed".mysql_error());
-
?> <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
-
while ($dataTampil2=mysql_fetch_array($qryTampil2)) {
-
?> <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>
-
[alternatif_aksi.php] -
<?php
-
$namakoneksi = mysql_connect("localhost","root","") or die ("Failed Connection");
-
mysql_select_db("tanamanobat",$namakoneksi);
-
-
?> <?php
-
$menu=$_GET['menu'];
-
$act=$_GET['act'];
-
-
// Input Alternatif
-
if ($menu=='alternatif' AND $act=='input')
-
{
-
if (isset($_POST['cebo1']))
-
{
-
$kd_altrntf = $_POST['kodealter'];
-
$nm_penyakit = $_POST['nm_penyakit'];
-
$cbo1 = $_POST['cebo1'];
-
$cbo2 = $_POST['cebo2'];
-
$cbo3 = $_POST['cebo3'];
-
-
echo "kd_penyakit : ".$kd_altrntf."<br />";
-
echo "nm_penyakit : ".$nm_penyakit."<br />";
-
echo "alt1 : ".$cbo1."<br />";
-
echo "alt2 : ".$cbo2."<br />";
-
echo "alt3 : ".$cbo3."<br />";
-
-
$tambah=mysql_query("INSERT INTO alternatif VALUES('$kd_altrntf','$nm_penyakit','$cbo1','$cbo2 ','$cbo3')"); }
-
if ($tambah)
-
//{ header ('location:index.php?menu=alternatif&pesan=Choosing is done');
-
exit();
-
// }
-
else
-
// { header ('location:index.php?menu=alternatif&pesan=Choosing Failed');
-
exit();
-
}
-
//}
-
?>
-
And also, I still don't get the way to saving data from checkboxes randomly checked...
Can somebody help to solve these? Thankyou :)
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
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.
which one do you mean with "doesn't have nm_penyakit or kodealter in its post data." ? -
// Input Alternatif
-
if ($menu=='alternatif' AND $act=='input')
-
{
-
if (isset($_POST['cebo1']))
-
{
-
$kd_altrntf = $_POST['kodealter'];
-
$nm_penyakit = $_POST['nm_penyakit'];
-
$cbo1 = $_POST['cebo1'];
-
$cbo2 = $_POST['cebo2'];
-
$cbo3 = $_POST['cebo3'];
-
That ones?
but the CHECKBOX's contain is from different FIELD in database.. so that I can't use array calling in there. -
<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>
-
<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>
-
cebo1 to cebo5 will placed different Field in database..
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.
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...
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.
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 :)
My monitor at work is small so I still couldn't read it when I zoomed in. Either way, glad you got it working.
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.
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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,...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
| |