Jump to content
php.lv forumi

Recommended Posts

Posted

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>

Posted

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>';

}

×
×
  • Create New...