Jump to content
php.lv forumi

for cikls


Chapman

Recommended Posts

es zinu, es pec tam vnk sakartoju kodu.

a taa rakstu uz "atro"

mazliet kods no php.net piemeriem:

<?php
// Send a select query to MSSQL
$query = mssql_query('SELECT [username], [name] FROM [php].[dbo].[userlist]');

// Check if there were any records
if (!mssql_num_rows($query)) {
   echo 'No records found';
} else {
   // The following is equal to the code below:
   //
   // while ($row = mssql_fetch_row($query)) {

   while ($row = mssql_fetch_array($query, MSSQL_NUM)) {
       // ...
   }
}

// Free the query result
mssql_free_result($query);
?>

jautajums tieshi par:

($row = mssql_fetch_array($query, MSSQL_NUM))

kas par MSSQL_NUM?

kas tas ir ko un ko "ziema ēd" jeb ko dara?

pašlaik ejoshais kods būtu šāds:

<?php	
$link = mssql_connect($host, $username, $password);
mssql_select_db('SecKeyPrior');
$nod_query = mssql_query('SELECT Id_Nod, Nod_Nos From S_Nod');

//naw masīvā ierakstīšanas koda, tāpēc prasu padomu jums
$nod_skaits = mssql_num_rows($nod_query);
echo $nod_skaits;
?>
<html>
<head>
	<script type="text/javascript">
		function nod()
		{
		var mylist=document.getElementById("myList");
		document.getElementById("favorite").value=mylist.options[mylist.selectedIndex].text;
		}
	</script>
</head>
<form>
Nodaļa:
<select id="myList" onchange="nod()">
<?php
	for ( $a = 1; $a <= $nod_skaits; $a++ )
	{
?>
 <option>
 <?php /*masīva elementa izvade*/  ?>
 </option>
 <?php }?>
</select>
<p>N: <input type="text" id="favorite" size="20"></p>
</form>

kā man labāk ierakstīt Nod_nos elementus masīvā?

Edited by Chapman
Link to comment
Share on other sites

es arii rakstu uz atro :/ bet man nesagada problemas visu sakartot uzreiz

pietam es nevaru normali pastradat ja kods ir izmetats uz visam pusem uzreiz jaiet pipet un jasez php.lv jo negribas neko darit, tieksim ta ir sobrid :/ besi :D kods ir izmetats, ir jastrada bet besis jo tagad jakarto lai vareut kautko dariit.

Link to comment
Share on other sites

viss... dab;uju gatavu:

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






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

				<tr>
					<td width="50">	
						Nodaļa:
					</td>
					<td>
						<select id="myList" 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>
						<!--Vārda input-->

					</td>	
				</tr>
				<tr>
					<td>
						Uzvārds:
					</td>
					<td>
						<!--Uzvārda input-->	

					</td>	
				</tr>
			</table>
		</form>
	</td>
</tr>

reuzltāts:

8rsxia4oa6u8l2zjiynn.jpg

Edited by Chapman
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...