Mam niekolko tabuliek, kde stlpce tvoria hodnoty vysky a riadky hodnoty sirky objektu. A naplnou databazy su ceny.
Cize nieco taketo:
MinSirka | 500 | 601 | 701 | 801 | ...
500 | 123 | 565 | ... ...
601 | 234 | 653 | ... ...
701 | 453 | .... ... ...
801 | 543 | .... ... ...
...
Problem nie je pri vyberani cien z tabulky, to ide v poriadku. Problem nastava pri ich updatovani, pretoze samotne query musi vyzerat nejak takto
UPDATE tabulka SET $vyska = $cena WHER MinSirka = $sirka aby to malo nejaky zmysel a tych UPDATEov neboli stovky... Ale nefunguje to. Problem je prave s tym $vyska...
Neviete mi poradit ako to vyriesit?
Fórum › MySQL
Trosku netradicny problem s UPDATE



A ja mam collum_name v premennej v PHP a potrebujem ju do toho query vlozit, len neviem ako.
no predsa tak isto ako vysku a cenu
$query="UPDATE tabulky SET $vyska = $cena WHERE $coulmn_name=$sirka";


"Boze, dopraj mi, prosim ta, petdesiat rokov prace a zabavy, a potom nahlu smrt v spanku." J. Grisham
To som skusil, nefunguje to... vypise, ze mysql_query je neplatne, alebo nieco v tom zmysle. (to s chybou neplati, $query s UPDATE mi prekrylo $query so SELECT...)olgo píše:#
##A ja mam collum_name v premennej v PHP a potrebujem ju do toho query vlozit, len neviem ako.
#no predsa tak isto ako vysku a cenu#
#$query="UPDATE tabulky SET $vyska = $cena WHERE $coulmn_name=$sirka";


a co je v $_POST[vyska]? na tom mieste ma byt nazov stlpca kam vlozis hodnotu $novaCenaPole.
btw:ten vypis som si predstavoval inak, ako vystup z:
$query="UPDATE tabulky SET $vyska = $cena WHERE $coulmn_name=$sirka";
echo $query
pouzivam to pre kontrolu ci som nespravil v dotaze preklep


"Boze, dopraj mi, prosim ta, petdesiat rokov prace a zabavy, a potom nahlu smrt v spanku." J. Grisham
$_POST[vyska] je nazov stlpca. Proste potrebujem urcit nazov stlpca cez premennu, ale nech skusam akekolvek parsovanie tak to nejde...olgo píše:#
# a co je v $_POST[vyska]? na tom mieste ma byt nazov stlpca kam vlozis hodnotu $novaCenaPole.#
#btw:ten vypis som si predstavoval inak, ako vystup z:#
##$query="UPDATE tabulky SET $vyska = $cena WHERE $coulmn_name=$sirka";#
#echo $query
#pouzivam to pre kontrolu ci som nespravil v dotaze preklep


$query = "UPDATE tabulka_vo_1 SET $_POST[vyska] = $novaCenaPole WHERE MinSirka = '$_POST[sirka]'";
dotaz vyzera takto:
UPDATE tabulka_vo_1 SET vyska = nova_cena_pole WHERE MinSirka = 'sirka'


"Boze, dopraj mi, prosim ta, petdesiat rokov prace a zabavy, a potom nahlu smrt v spanku." J. Grisham

Přidej příspěvek
Toto téma je starší jak čtvrt roku – přidej svůj příspěvek jen tehdy, máš-li k tématu opravdu co říct!
Ano, opravdu chci reagovat → zobrazí formulář pro přidání příspěvku
×Vložení zdrojáku
×Vložení obrázku
×Vložení videa
Aktuálně jsou podporována videa ze serverů YouTube, Vimeo a Dailymotion.
×






























































Uživatelé prohlížející si toto vlákno
Uživatelé on-line: 0 registrovaných, 11 hostů
Podobná vlákna
MySqli update problém — založil Marek
Win Update nebo Office Update ničí ActiveX objekty — založil Pfox
Trošku úsměvu — založil Kenvelo
Matematika trošku jinak — založil eMan
Trošku teorie...OOP — založil Honza
Moderátoři diskuze