Jump to content
php.lv forumi

Atlasīt id pec izveleta nosaukuma.


edw

Recommended Posts

Sveiki,

 

pienemsim, ka man ieks sql ir sada tabula

 

+----+--------------+

| id | nosaukums |

+----+--------------+

| 1 | viens |

| 2 | divi |

| 3 | triis |

| 4 | chetri |

| 5 | pieci |

+----+--------------+

 

 

ar drop down box palidzibu atlasu "nosaukums" vertibas.

 

Bet tagad vajag panakt, lai izveloties drop down boxa, piemeram, "divi " tiktu definets mainigais "x", kas saja gadijuma butu 2, un ja izvelos " triis" - x=3 utt.

 

 

Seit bus tas, ko esmu jau uztaisijis

 

 $query = "SELECT id, nosaukums FROM $tabula ORDER BY id ASC";
$result = mysql_query($query);



<select size="1"  name="nosaukums" >
	  <?php

	  while ($row = mysql_fetch_object($result)) {
	  ?>
	  <option><?php echo $row->nosaukums;?></option>
	  <?
	  }?>

	  </select>

Link to comment
Share on other sites

×
×
  • Create New...