Jump to content
php.lv forumi

Db ierakstu atteloshana no vairakam tabulam


Chapman

Recommended Posts

<?php	
$link = mssql_connect($host, $username, $password);
mssql_select_db('SecKeyPrior');
$nod_query = mssql_query('SELECT Id_Nod, Nod_Nos From S_Nod');
$users_querry = mssql_query('SELECT Id, F_Name, S_Name From S_Users');
?>
<html>
<head>
	<script type="text/javascript">
		function nod()
		{
		var no_list=document.getElementById("nod_list");
		document.getElementById("adm_nod").value=nod_list.options[nod_list.selectedIndex].text;
		}
	</script>
	<script type="text/javascript">
		function users()
		{
		var users_list=document.getElementById("users_list");
		document.getElementById("adm_nod").value=users_list.options[users_list.selectedIndex].text;
		}
	</script>
</head>
<body>



<center>
<table  class="In" border="1">
<tr>
	<td width="250" align="center">
		<form>
			<table border="1" cellpadding="0" cellspacing="0">

				<tr>
					<td width="50">	
						Nodaļa:
					</td>
					<td>
						<select id="nod_list" onchange="nod()">
							<?php
								while ($row = mssql_fetch_assoc($nod_query)) 
								{  	
							?>
							 <option>
								<?php  echo $row["Nod_Nos"];?>
							 </option>
								<?php }?>
						</select>


					</td>
				</tr>
				<tr>
					<td>
						Vārds:
					</td>
					<td>
						<input type="text" id="adm_f_name" >

					</td>	
				</tr>
				<tr>
					<td>
						Uzvārds:
					</td>
					<td>
						<input type="text" id="adm_l_name" >	

					</td>
				</tr>
			</table>
			</td>
			<td align="center">
			<table border="1" cellpadding="0" cellspacing="0">

				<tr>
					<th width="200">	
						Lietotāji
					</th>
					<th width="200">	
						Lietoāji Online
					</th>
				</tr>
				<tr>
					<td>	
						<select  id="users_list" onchange="users()" size="4">
						 <option>viens123123</option>
						 <option>divi</option>
						 <option>tris</option>
						 <option>cetri</option>
						 <option>pieci</option>
						</select>
					</td>
					<td>	
						<select size="4">
						 <option>viens123123</option>
						 <option>divi</option>
						 <option>tris</option>
						 <option>cetri</option>
						 <option>pieci</option>
						</select>
					</td>
				</tr>
			</table>
		</form>
	</td>
</tr>

liet tāda, ka tāpat kā nodaļas gribu attēlot lietotājus, bet problēmas sākas ar to, ka lietotāja vārds un uzvārds tiek glabāts DB atsevišķos laukos, bet man tos vajag attēlot kopā.

Edited by Chapman
Link to comment
Share on other sites

kapec tu vnk nevari

 

SELECT id(s) tabula1 LEFT JOIN tabula2 ON tabula1.id=tabula2.id

?

cik saprotu, shis ir domāts, ja ir atsevišķas tabulās, bet man Vards, Uzvards tiek glabadi viena tabula bet ka atsevišķi lauki!

Link to comment
Share on other sites

labi, to es pats uztaisiju:

<?php	
$link = mssql_connect($host, $username, $password);
mssql_select_db('SecKeyPrior');
$nod_query = mssql_query('SELECT Id_Nod, Nod_Nos From S_Nod');
$users_query = mssql_query('SELECT Id, F_Name, S_Name From S_Users');
$users_on_query = mssql_query('SELECT Id, F_Name, S_Name From S_Users Where');
?>
<html>
<head>
	<script type="text/javascript">
		function nod()
		{
		var no_list=document.getElementById("nod_list");
		document.getElementById("adm_nod").value=nod_list.options[nod_list.selectedIndex].text;
		}
	</script>
	<script type="text/javascript">
		function users()
		{
		var users_list=document.getElementById("users_list");
		document.getElementById("adm_users_list").value=users_list.options[users_list.selectedIndex].text;
		}
	</script>
</head>
<body>






<center>
<table  class="In" border="1">
<tr>
	<td width="250" align="center">
		<form>
			<table border="1" cellpadding="0" cellspacing="0">

				<tr>
					<td width="50">	
						Nodaļa:
					</td>
					<td>
						<select id="nod_list" onchange="nod()">
							<?php
								while ($row = mssql_fetch_assoc($nod_query)) 
								{  	
							?>
							 <option>
								<?php  echo $row["Nod_Nos"];?>
							 </option>
								<?php }?>
						</select>

						<!--<p>N: <input type="text" id="adm_nod" size="20"></p>-->
					</td>
				</tr>
				<tr>
					<td>
						Vārds:
					</td>
					<td>
						<input type="text" id="adm_users_list" >

					</td>	
				</tr>
				<tr>
					<td>
						Uzvārds:
					</td>
					<td>
						<input type="text" id="adm_l_name" >	

					</td>
				</tr>
			</table>
			</td>
			<td align="center">
			<table border="1" cellpadding="0" cellspacing="0">

				<tr>
					<th width="200">	
						Lietotāji
					</th>
					<th width="200">	
						Lietoāji Online
					</th>
				</tr>
				<tr>
					<td>	
						<select  id="users_list" onchange="users()" size="4">
						<?php
								while ($row = mssql_fetch_assoc($users_query)) 
								{  	
							?>
							 <option>
								<?php  echo $row["F_Name"].' '.$row["S_Name"]?>
							 </option>
								<?php }?>
						</select>
					</td>

problema rodas tur, ka es gribu vardu un uzvardu atseviskos input laukos attelot:

ipjkndt5qt2mxv8acpih.jpg

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...