hello i have a problem that's maybe difficult to descripe,
i have an application, that simulates a pizza store. i have a page "bestellungen" ("orders") in which i have some javascript.(the head,javascript and body i declare in page.php, from which the other ("sub")pages "extends".
right now, everything works, but now, i want to add to the javascript some php code. (in the "main" page.
in the page "bestellungen" ("orders") i read from the database
$sql="Select * FROM pizzen_arten";
$data=$this->_database->query($sql); //alle daten in data gespeichert
while($reihe = $data->fetch_array()){
$lfdnr=$reihe[2];
$this->pizza_name[$lfdnr] =$reihe[0];
$this->pizza_preis[$lfdnr] =$reihe[1];
$this->pizza_id[$lfdnr] =$reihe[2];
}
then in the same page i add all pizzas
foreach ($this->pizza_id as $tmp) //alle pizzen durchgehen über id, (id in tmp speichern)
{
//echo " überall wo " ist ein \ davor
echo "<img src=\"pizzen/pizza-".$this->pizza_name[$tmp].".png\" width=\"50\" height=\"50\" alt=\"Pizza ".$this->pizza_name[$tmp]."\" id=\"".$this->pizza_name[$tmp]."\" onclick=\"hinzu('".$this->pizza_name[$tmp]."')\" /> ".$this->pizza_name[$tmp]." ".$this->pizza_preis[$tmp]." €";
echo "<p/>"; //vor variable " string beenden . für "+" dann var, dann string weiter
//this das aktuelle obj, der schleife, davon pizzaname (ist ein array! kein attribut), an der stelle tmp
}
the method "hinzu(id)" is declared in "page.php"
function hinzu (pizza)
{
NeuerEintrag = new Option(pizza, pizza, false, false);
document.getElementById("warenkorbfeld").options[document.getElementById("warenkorbfeld").length] = NeuerEintrag ;
ETO;
foreach ($this->pizza_id as $tmp)
{
if ($this->pizza_name[tmp]==pizza) //array durchgehen gucken, wann der übergabe parameter ==einem pizzanamen
echo "gesamtbetrag=gesamtbetrag"+$this->pizza_preis[$tmp];
}
/*if (pizza=="Margherita")
{
gesamtbetrag = gesamtbetrag + 4;
}
if (pizza=="Salami")
{
gesamtbetrag = gesamtbetrag + 4.50;
}
if (pizza=="Hawaii")
{
gesamtbetrag = gesamtbetrag + 5.50;
}*/
echo <<< ETO
document.getElementById('gesamtbetrag').innerHTML=gesamtbetrag ;
}
at first the method was without php-code, now by using php-code it doesn't work.
i suggest there might be a problem with "$this" or "pizza" but i'm not quite sure wether i implemented the php code right.
thanks in advance
$thisis referring to. You will need to start doing step-by-step debugging to find the root of the problem. For example,echo "gesamtbetrag=gesamtbetrag"+$this->pizza_preis[$tmp];will probably not do what you intend - look at the generated source code in your browser, you will find that a plus sign is (probably) missing. Etc. etc. Please try to walk through the code and describe more clearly what the problem is.