sandrulis Posted April 27, 2012 Report Share Posted April 27, 2012 Sveiki, kārtējo reizi griežos pie jums jo nezinu kā, lai izdara ko gribu izdarīt :) Mysql tabula languages : id - name - short 1 - English - eng 2 - Latviešu - lv forma: sadala pēc šis tabulas <input type=text name='eng'> <input type=text name='lv'> kad notiek submit: $results=mysql_query("SELECT * FROM languages ORDER BY priority ASC"); while($rows = mysql_fetch_array($results)) {xxx} pārbauda vai ir postets un vai nav tukšs if(isset($_POST[$rows['short'].'_name']) AND !empty($_POST[$rows['short'].'_name']) {} ja nav, tad : mysql_query("INSERT INTO products ('{$rows['short']}') VALUES ('{$_POST[$rows['short']]}')"); protams, ka nav pareizi jo viņš iemet divus dažādus ierakstus: id-eng id-lv bet kā lai iemet visu zem viena ieraksta id-eng-lv Ceru ka sapratāt manu domu :) Quote Link to comment Share on other sites More sharing options...
anonīms Posted April 28, 2012 Report Share Posted April 28, 2012 $languages = array(); $results=mysql_query("SELECT * FROM languages ORDER BY priority ASC"); while($rows = mysql_fetch_array($results)) { if(!empty($_POST[$rows['short'].'_name'])) { $languages[] = $_POST[$rows['short'] } } if(!empty($languages)) { $languages = 'id-'.implode("-",$languages); // kverijs. } Ja pareizi sapratu, tad kkā tā Quote Link to comment Share on other sites More sharing options...
Kemito Posted April 28, 2012 Report Share Posted April 28, 2012 (edited) $languages = array(); $results=mysql_query("SELECT * FROM languages ORDER BY priority ASC"); while($rows = mysql_fetch_array($results)) { if(!empty($_POST[$rows['short'].'_name'])) { $languages[] = $_POST[$rows['short'] } } if(!empty($languages)) { $languages = 'id-'.implode("-",$languages); // kverijs. } Ja pareizi sapratu, tad kkā tā Ja dod kodu, tad esi tik laipns un piedomā pie sintakses. $languages[] = $_POST[$rows['short'] Uz $languages[] = $_POST[$rows['short']]; Edited April 28, 2012 by Kemito Quote Link to comment Share on other sites More sharing options...
sandrulis Posted April 28, 2012 Author Report Share Posted April 28, 2012 Liels palides, vakarā notestēšu un pielāgošu manam projektiņam :) Quote Link to comment Share on other sites More sharing options...
daGrevis Posted April 28, 2012 Report Share Posted April 28, 2012 Nu kods jau nav jākopī-peisto; dots, lai tikai saprastu how-to. Quote Link to comment Share on other sites More sharing options...
anonīms Posted April 28, 2012 Report Share Posted April 28, 2012 daGrevis +1. Es uz ātro vnk parādīju, ka var izmantot array ar implode Quote Link to comment Share on other sites More sharing options...
Kemito Posted April 28, 2012 Report Share Posted April 28, 2012 TaD jAw vArĒJi tO pIEminĒT aR, jO tAčU pArAsTi kOOdu dOd pAReiZU. Quote Link to comment Share on other sites More sharing options...
daGrevis Posted April 28, 2012 Report Share Posted April 28, 2012 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.