BioHazard94
P[r]oland
Hi I would get help for my PHP script
I want to be a form with two fields in a TXT field enter the autor in two field title song.
Unfortunately I can not do this on two tables.
In the base i have tabels nuta and there nuta and the autor of the column and would like to after entering the data lent it to the database and display the fields of text!
Chcę aby był to formularz z 2 polami TXT w 1 pole wpisuję Wykonawcę a w 2 pole Tytuł piosenki.
Niestety nie potrafię zrobić tego na 2 tabelki.
W bazie mam TABELE nuta i tam kolumny piosenka i autor i chciałbym aby po wpisaniu danych dodawało się to do bazy i wyświetlało nad polami textu !
PHP:
<?php
// informacje na temat bazy
$host = 'XXX';
$user = 'XXX';
$password = 'XXX';
$dbName = 'XXX';
// polaczenie i wybór bazy danych
$polacz = mysql_connect($host, $user, $password) or die(mysql_error());
$db = mysql_select_db($dbName, $polacz) or die(mysql_error());
// wprowadzanie do bazy nowego wpisu po wciśnięciu przycisku submit
if (isset($_POST['nutka']) && trim($_POST['nutka']) != ”) {
$nutka = $_POST['nutka'];
$sql = "INSERT into nuta (piosenka) VALUES ('$nutka')";
$rezultat = mysql_query($sql, $polacz) or die(mysql_error());
}
// 2 wprowadzanie do bazy nowego wpisu po wciśnięciu przycisku submit
if (isset($_POST['a']) && trim($_POST['a']) != ”) {
$nutka = $_POST['a'];
$sql = "INSERT into nuta (autor) VALUES ('$a')";
$rezultat = mysql_query($sql, $polacz) or die(mysql_error());
}
// pobierabie wartości z tabeli "nuta"
$sql = "SELECT piosenka FROM nuta";
$rezultat = mysql_query($sql, $polacz) or die(mysql_error());
while ($lista = mysql_fetch_array($rezultat)) {
echo $lista['piosenka']. "<br />";
}
// 2 pobierabie wartości z tabeli "nuta"
$sql = "SELECT autor FROM nuta";
$rezultat = mysql_query($sql, $polacz) or die(mysql_error());
while ($lista = mysql_fetch_array($rezultat1)) {
echo $lista['autor']. "<br />";
}
// formularz
echo <<<FORMULARZ
<br /> Tytuł piosenki: <br />
<form action = "index.php" method = "post">
<input type = "text" name = "nutka" maxlength="20" size = "20">
<input type = "text" name = "a" maxlength="20" size = "15">
<input type = "submit" value = "Zaproponuj piosenkę">
</form>
FORMULARZ;
?>
I want to be a form with two fields in a TXT field enter the autor in two field title song.
Unfortunately I can not do this on two tables.
In the base i have tabels nuta and there nuta and the autor of the column and would like to after entering the data lent it to the database and display the fields of text!
Chcę aby był to formularz z 2 polami TXT w 1 pole wpisuję Wykonawcę a w 2 pole Tytuł piosenki.
Niestety nie potrafię zrobić tego na 2 tabelki.
W bazie mam TABELE nuta i tam kolumny piosenka i autor i chciałbym aby po wpisaniu danych dodawało się to do bazy i wyświetlało nad polami textu !