Hi, I need help for this problem that i'm trying to solve for a while. How do i submit the value into database and view value ?
Here's the code:
if ($id_pac && $id_rej && $data && $id_kon && $lekarz) {
// tworzymy zapytanie
$id_mat = (isset($_POST['id_mat'])) ? 1 : 0;
$query = "INSERT INTO `rejestr` (`id_pac`, `id_mat`,`id_rej`, `data`, `id_kon`, `lekarz`) VALUES ('$id_pac', '$id_mat','$id_rej', '$data', '$id_kon', '$lekarz')";
if(mysql_query($query)) echo 'Pomyślnie wyedytowano pacjenta!<br />';
}
else {
echo 'Nie podałeś wszystkich danych!';
}
}
$result = mysql_query("SELECT * FROM `pacjent` WHERE `id_pac`='".$_GET['rej']."'");
$row = mysql_fetch_array($result);
echo '<h2>Numer pacjenta: <font color="red">', stripslashes($row['id_pac']),
'</font></h2>';
echo '<strong>PESEL:</strong> ', stripslashes($row['pesel']), '<br />';
echo '<strong>Data urodz.:</strong> ', stripslashes($row['data_urodz']),
'<br />';
echo '<h3>',stripslashes($row['imie']), ' '
,stripslashes($row['nazwisko']), '</h3>';
echo '<h3>',stripslashes($row['ulica']),'</h3>';
echo '<h3>',stripslashes($row['kod']), ' '
,stripslashes($row['miejscowosc']), '</h3>';
echo '<form action="rejestracja.php" method="POST">
<table style="width:600px;" class="tab1"><tr>
<td>Numer zlecenia:<br /><td>
<input type="text" name="id_rej" style="width:50px;"></td>
<td>Numer pacjenta:<br /><td>
<input type="text" name="id_pac" style="width:50px;"><br /></td></tr>
<tr><td>Data rejestracji:<td> <input type="text" name="data" style="width:150px;" ></td>
<td>Lekarz zlecający: <td><input type="text" name="lekarz" style="width:150px;"></td></tr>
<tr><td>Jedn zlecająca:<br /><td>
<select name="id_kon">';
require('config.php');
$result = mysql_query("SELECT * FROM kontrahent");
while($row = mysql_fetch_array($result))
{
echo '<option value="'.$row['id_kon'].'">'.stripslashes($row['nazwa_kodu']).'</option>';
}
echo '</select><br />
<tr><td>';
$result2 = mysql_query("SELECT * FROM badania");
while ($row=mysql_fetch_assoc($result2))
{
echo '<input type="checkbox" name=id_mat[] value='.$row["nazwa"].'</input>'.$row["nazwa"].'<br>';
}
echo ' </td>
<td><br /><input type="submit" name="ok" value="Dodaj"></td></tr></table>
</form>';
?>
TABLE
CREATE TABLE `kontrahent` (
`id_kon` int(11) NOT NULL auto_increment,
`nazwa_kodu` varchar (12) NOT NULL,
`nazwa_k` varchar(40) NOT NULL,
`kod_p` varchar(6) NOT NULL,
`miasto` varchar(25) NOT NULL,
`ulica` varchar(25) NOT NULL,
`grupa` varchar(3) NOT NULL,
PRIMARY KEY (`id_kon`)
) ENGINE=MyISAM ;
CREATE TABLE `badania` (
`id_mat` int(11) NOT NULL auto_increment,
`kod_bad` varchar (10) NOT NULL,
`nazwa` varchar (25) NOT NULL,
`material` varchar (15) NOT NULL,
`cena` decimal (6, 2) NOT NULL,
PRIMARY KEY (`id_mat`)
) ENGINE=MyISAM ;
CREATE TABLE `rejestr` (
`id_rej` int(11) NOT NULL,
`id_pac` int(11) NOT NULL,
`id_kon` int(11) NOT NULL,
`id_mat` int(11) NOT NULL,
`data` date NOT NULL,
`lekarz` varchar (40) NOT NULL,
PRIMARY KEY (`id_rej`),
KEY (`id_pac`),
KEY (`id_kon`),
KEY (`id_mat`)
) ENGINE=MyISAM ;
CREATE TABLE `pacjent` (
`id_pac` int(11) NOT NULL auto_increment,
`imie` varchar (20) NOT NULL,
`nazwisko` varchar(30) NOT NULL,
`pesel` char(11) NOT NULL,
`data_urodz` varchar(10) NOT NULL,
`plec` varchar (1) NOT NULL,
`miejscowosc` varchar (25) NOT NULL,
`kod` varchar(6) NOT NULL,
`ulica` varchar(25) NOT NULL,
PRIMARY KEY (`id_pac`)
) ENGINE=MyISAM ;
I am writing a script patient registration and marketing of research results. I want to lent me a check value using the checkbox to mysql and displays what value.Sorry for poor English.Thank you for your help.