Witam. Jak zrobić coś takiego. Mamy skrypt który tworzy kategorie i tworzy do nich linki.
<?php
require("config.php");
echo"<form method='POST' action='dodaj.php'>
Dodaj kategorie: <input type='text' name='kat'><br>
<input type='submit' value='Wyślij'>
</form>";
$kategoria=$_POST['kat'];
$query = "INSERT INTO `kategoria` (kat) VALUES ( '$kategoria')";
$query3 = mysql_query ("SELECT * FROM `kategoria` WHERE `kat` = '" . $_GET['kategoria'] . "'");
{
print $field['column'] . '<br />'; }
?>
A teraz chce zrobić tak. Dodajemy wpis:
<?php
require("config.php");
echo"<form method='POST' action='index.php'>
Tytuł strony: <input type='text' name='tytul'><br>
Opis: <textarea name='opis' cols='40' rows='10'></textarea>
Słowa kluczowe: <input type='text' name='kluczowe'><br>
E-mail: <input type='text' name='email'><br>
Adres: <input type='text' name='adres'><br>
<input type='submit' value='Wyślij'>
</form>";
$tytul=$_POST['tytul'];
$opis=$_POST['opis'];
$kluczowe=$_POST['kluczowe'];
$email=$_POST['email'];
$adres=$_POST['adres'];
$query = "INSERT INTO `wpis` (tytul, opis, kluczowe, email, adres) VALUES ( '$tytul','$opis','$kluczowe','$email','$adres')";
?>
Daje jeszcze install.php
<?
require("config.php");
$zapytanie = "CREATE TABLE `wpis` (
`id` int(11) NOT NULL auto_increment,
`tytul` char(30) collate utf8_polish_ci NOT NULL default '',
`opis` char(30) collate utf8_polish_ci NOT NULL default '',
`kluczowe` char(30) collate utf8_polish_ci NOT NULL default '',
`email` char(30) collate utf8_polish_ci NOT NULL default '',
`adres` char(30) collate utf8_polish_ci NOT NULL default '',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci AUTO_INCREMENT=3 ;";
$zapytanie2 = "CREATE TABLE `kategoria` (
`id` int(11) NOT NULL auto_increment,
`kat` char(30) collate utf8_polish_ci NOT NULL default '',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci AUTO_INCREMENT=3 ;";
if($instaluj == true) {
echo "Utworzyłem tabelę <b>Kategoria</a>"; }
else
{
echo "<b>Nie</b> Utworzyłem tabeli <b>Kategoria</b>"; }
?>
I chcę dodać do formularza pole wyboru kategorii. Tylko problem w tym aby wybierał kategorie, z tabeli kategorie z pola kat., a po tym chcę aby tworzył link index.php?kategoria=nazwakategorii&nazwa wpisu
Czekam na sugestie. Pozdro.