Jump to content
php.lv forumi

list/menu un db


marlboro

Recommended Posts

Kā var panāk ka php automatiski no db izvelk vissus id un define ja id ir tadz ka izvilkts tad echo 'selected' shini gadijuma ja $lapa==ar tadu ka db ieraxtits

 

	<select name="lapa" onchange="document.forms['select_content'].submit();">
  <option value="0" <?php if ($lapa==0) echo 'selected';?>></option>
  <option value="1" <?php if ($lapa==1) echo 'selected';?>>Banner : 1</option>
  <option value="2" <?php if ($lapa==2) echo 'selected';?>>Banner : 2</option>
  <option value="3" <?php if ($lapa==3) echo 'selected';?>>Banner : 3</option>
  <option value="4" <?php if ($lapa==4) echo 'selected';?>>Banner : 4</option>
</select>

Link to comment
Share on other sites

Sveiks!

Vispirms atlasi rezultātu ar visiem id.

SELECT id FROM tabula ORDER BY id

Tad ciklā lasi pa vienai rindai.

while ($rinda = mysql_fetch_row($rez)){

echo '<option value="'.$rinda['id'].'"'.($rinda['id']==$lapa ? ' selected' : '').'>Banner '.$rinda['id'].'</option>';

}

Link to comment
Share on other sites

×
×
  • Create New...