Jump to content
php.lv forumi

sandrulis

Recommended Posts

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 :)

Link to comment
Share on other sites

$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ā

Link to comment
Share on other sites

$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 by Kemito
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...