gkazhus Posted June 8, 2010 Report Share Posted June 8, 2010 (edited) Ka lai uztaisa chekboxi kuru iekekseejot DB vertiba nomainaas uz true (1) un kad nav iekekseets tad ir false(0)? Edited June 8, 2010 by gkazhus Quote Link to comment Share on other sites More sharing options...
m8t Posted June 8, 2010 Report Share Posted June 8, 2010 Labak izmanto radio buttons: http://www.homeandlearn.co.uk/php/php4p10.html Bet janu tomēr gribi checkboxes: http://www.homeandlearn.co.uk/php/php4p11.html Quote Link to comment Share on other sites More sharing options...
Klez Posted June 8, 2010 Report Share Posted June 8, 2010 njem palīgā javascript <input type="checkbox" onclick="javscript:kekseejam()" ... function kekseejam() { id = document.getElementById('elementa_id'); //taisaam ajax pieprasiijumu // ja ir = true, tad ir iekekseets, ja false, tad izkekseets } Quote Link to comment Share on other sites More sharing options...
gkazhus Posted June 8, 2010 Author Report Share Posted June 8, 2010 Labak izmanto radio buttons: http://www.homeandlearn.co.uk/php/php4p10.html Bet janu tomēr gribi checkboxes: http://www.homeandlearn.co.uk/php/php4p11.html Ir tā ka šī standarta metode man neder, jo es no DB izvelku konkrētā gadījumā banerus kas atrodas DB, kurus ieķeksējot tie parādīsies baneru joslā, tie kas nav ieķeksēti neparādās. Pievienojot jaunu baneri uzreiz tiek parādīts baneris ar visu čekboxi. Quote Link to comment Share on other sites More sharing options...
m8t Posted June 8, 2010 Report Share Posted June 8, 2010 (edited) Es nesapratu kas tev tur ir par problēmu kādēļ tieši neder. Edited June 8, 2010 by m8t Quote Link to comment Share on other sites More sharing options...
gkazhus Posted June 8, 2010 Author Report Share Posted June 8, 2010 (edited) Es nesapratu kas tev tur ir par problēmu kādēļ tieši neder. Taatad: 1. automātiski tiek atlasiiti visi esoshie baneri kas ir ieladeti DB 2. blakām pievienots čekboksis katram banerim kuru ieķeksējot konkrētā banera vērtība DB nomainās uz 1 neieķeksējot 0 Līdzīgi kā šeit http://www.homeandlearn.co.uk/php/php4p11.html bet lai kods nav jāraksta katram banerim atsevīšķi Edited June 8, 2010 by gkazhus Quote Link to comment Share on other sites More sharing options...
m8t Posted June 8, 2010 Report Share Posted June 8, 2010 $query = "SLECT... FROM ... WHERE..."; while($row = mysql_fetch_array($query)) { echo '<img src="'.$row["bannera_bilde"].'" />'; if($row["public_banner"] == 1) { echo 'Rādīt publiski...<br /> 'Jā <input type="checkbox" name="pub" value="1" checked/><br />'. 'Nē <input type="checkbox" name="pub" value="0" />'; } else { echo 'Rādīt publiski...<br /> 'Jā <input type="checkbox" name="pub" value="1" /><br />'. 'Nē <input type="checkbox" name="pub" value="0" checked/>'; } echo '<br />'; } Aptuveni tā Quote Link to comment Share on other sites More sharing options...
marcis Posted June 8, 2010 Report Share Posted June 8, 2010 (edited) m8t, ko tu tur murgo? <input type="checkbox" name="public[]" value="<?=$row['id'];?>"<?if($row['public'] == 1){?> checked="ckecked"<?}?> /> Ja čekboksis nebūš iečekots, tad mainīgais nenosūtīsies. if(getenv('REQUEST_METHOD') == 'POST'){ mysql_query("UPDATE `banneri` SET public=0"); if(!empty($_POST['public']) && is_array($_POST['public'])) mysql_query("UPDATE `banneri` SET public=1 WHERE id IN (".implode(',', array_map('intval', $_POST['public'])).")"); } Edited June 8, 2010 by marcis Quote Link to comment Share on other sites More sharing options...
xPtv45z Posted June 8, 2010 Report Share Posted June 8, 2010 if($row["public_banner"] == 1) { echo 'Rādīt publiski...<br /> 'Jā <input type="checkbox" name="pub" value="1" checked/><br />'. 'Nē <input type="checkbox" name="pub" value="0" />'; } else { echo 'Rādīt publiski...<br /> 'Jā <input type="checkbox" name="pub" value="1" /><br />'. 'Nē <input type="checkbox" name="pub" value="0" checked/>'; } Šo visu tak var aizstāt ar, nav jau nekādi radio button. Un arī jēga atkārtot vienu un to pašu, ja faktiski mainās tikai checked vērtība echo '<input type="checkbox" name="pub[]" value="1"'.($row["public_banner"] == 1?' checked="checked"':null).' /><br />'; Quote Link to comment Share on other sites More sharing options...
m8t Posted June 8, 2010 Report Share Posted June 8, 2010 Ehh, tā ir, ja visur izmanto radio buttons. Līdz šim nav bijusi īpaša vajadzība no checkboxiem :) Quote Link to comment Share on other sites More sharing options...
marcis Posted June 8, 2010 Report Share Posted June 8, 2010 Forši tev. Man arī ir visādi kodi. Nu un? Quote Link to comment Share on other sites More sharing options...
gkazhus Posted June 10, 2010 Author Report Share Posted June 10, 2010 Kas man shajaa kodaa ir nepareizi? DB updeitojas tikai uz 0 <input type="checkbox" name="active" value="<?=$row['id'];?>"<?if($row['active'] == 1){?> checked="ckecked"<?}?> /> <? if(getenv('REQUEST_METHOD') == 'POST'){ $sql ="UPDATE `right_side_banners` SET active=1"; if(!empty($_POST['active']) && is_array($_POST['active'])) $sql="UPDATE `right_side_banners` SET active=1 WHERE id IN (".implode(',', array_map('intval', $_POST['active'])).")"; $rs = mysql_query($sql); } ?> Quote Link to comment Share on other sites More sharing options...
briedis Posted June 10, 2010 Report Share Posted June 10, 2010 Esi paskatījies, ko satur $_POST['active'] ? Un vispār saproti, kas notiek tur tajā WHERE nosacījumā ? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.