Dropdown mysql pomoc

imam dropdown list i kad stavim u mysql query insert into, nema u bazi podataka niceg, prazno je, dok za username, password, email bude ono sta upisem tijekom registracije ? jednom sam uspio al sad ne znam vise :sa:

pod maincategories i subcategories je to, i to mi nece uci u bazu iako iz dropdown lista odaberem ono sta zelim :S

if(isset($_POST[“reggumb”]))
{
$check = mysqli_query($conn,“SELECT * FROM korisnici WHERE username =’”.$username."’");
$numrows = mysqli_num_rows($check);
if($numrows == 0)
{
$password=($password);
$ins = mysqli_query($conn, “INSERT INTO korisnici (id, username, password, email, date, maincategories, subcategories) VALUES (’’, '”.$username."’ , ‘".$password."’ , ‘".$email."’, ‘".$date."’,’".$maincategories."’,’".$subcategories."’ ) ;");
if($ins)
echo “eeeeee”;
}

}

Sta ti ovo znači?

Prva stvar; ispiši ove varijable $maincategories i $subcategories
Druga stvar; daj html
Treća stvar; di definiraš sve ove varijable za kategorije username i pwd?

e, nisam ti dao cijeli kod, jer prije mj dan sam imao isti problem, ali sam ga uspio rijesiti, nesto sam prcko po mysql query insert into, a ovo sta znaci ? to nista ne znaci jer i ja to gledam sa cudjenjem…

<?php $obj->displayMaincategories(); ?> <?php $obj->displaySubcategories(); ?>

evo cod za dropdown

<?php Class Main { const maincategory = "animals"; protected $maincategories = array("animals"=>"Animals", "cars"=>"Cars"); protected $subcategories = array( "animals"=>array("dog"=>"Dog", "cat"=>"Cat", "horse"=>"Horse", "pig"=>"Pig"), "cars"=>array("honda"=>"Honda", "ferrari"=>"Ferrari", "toyota"=>"Toyota", "ford"=>"Ford") ); public function displayMaincategories(){ if(isset($_POST['maincategory'])){ foreach ($this->maincategories as $key=>$value) { if ($key == $_POST['maincategory']){ echo "$value"; }else { echo "$value"; } } } else { foreach ($this->maincategories as $key=>$value) { if ($key == self::maincategory) { echo "$value"; }else { echo "$value"; } } } } public function displaySubcategories() { if(isset($_POST['maincategory'], $_POST['subcategory'])) { $selected = $this->subcategories[$_POST['maincategory']]; foreach ($selected as $key=>$value){ if ($key == $_POST['subcategory']){ echo "$value"; }else { echo "$value"; } } }else { $selected = $this->subcategories[self::maincategory]; foreach ($selected as $key=>$value) { echo "$value"; } } } } $obj = new Main(); ?>

<!doctype html>

Untitled Document

ne znam sta je ovo, zasto ovako izgleda, nece mi se neki kodovi prikazat ovdje

<?php $obj->displayMaincategories(); ?> <?php $obj->displaySubcategories(); ?>

rijeseno, rijesenje se krilo u tvom odgovoru :slight_smile:


Copyright © 2020 WM Forum - AboutContact - Sponsored by: Mydataknox & Profit Monkey