Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > PHP > PHP Forum > อยากได้โค๊ดนับจำนวนครบ แล้วเปลี่ยนสถานะอัตโนมัติ ค่ะ



 

อยากได้โค๊ดนับจำนวนครบ แล้วเปลี่ยนสถานะอัตโนมัติ ค่ะ

 



Topic : 090292



โพสกระทู้ ( 406 )
บทความ ( 0 )



สถานะออฟไลน์
Facebook



อยากได้โค๊ดนับจำนวนครบ แล้วเปลี่ยนสถานะอัตโนมัติ ค่ะ

โดยมีตาราง tb_menu และเงื่อนไขดังนี้

- ให้นับจากช่อง parent='184' พอนับครบ 5 อันและเป็นประเภท sublevel= '3' เท่านั้น แล้วให้เปลี่ยนสถานะที่เหลือ เช่น 6 ถึง n... ในช่อง published ให้เป็น= '0' โดยอ้างอิงวันเวลาใหม่และเปลี่ยนสถานะให้เป็น published= '1' ก็จะแสดงผล 1 ถึง 5 ค่ะ

ตาราง tb_menu
tb_menu

ขอบคุณค่ะ ^.^



Tag : PHP, MySQL, CakePHP







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2013-02-04 16:11:44 By : nattkhanesha View : 1219 Reply : 6
 

 

No. 1



โพสกระทู้ ( 1,439 )
บทความ ( 0 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Facebook

ไม่ได้ตรวจสอบโค้ดนะครับ เขียนตามแนวความคิดที่ว่า

Code (PHP)
$q=mysql_query("select * from tb_menu where  parent='184' and sublevel='3' limit 5"); // ดึง 5 ตัว เงื่อนไข parent=184 and sublevel=3
$i=0;
while($r =mysql_fetch_array($q)){
$i++;
$sq_ex[]=$r['id'];  // เก็บค่าไอดี 5 ตัวไว้
mysql_query("update tb_menu  set published='$i' , check_out_time=now() where id='$r[id]' ");  // วนลูป  update ค่า 5 ตัวที่ดึงเก็บค่าเรียง published 1-5 
}

$count=count($sq_ex);
if($count>0){
 for($i=0;$i<$count;$i++){ // วนลูปสร้างตัวแปร in 
   if($i>0) $in.=',';
   $in.="'{$sq_ex[$i]}'";
  }
mysql_query("update tb_menu set published='0' where  parent='184' and sublevel='3' and id not in ($in) "); // id ที่ไม่ใช่ 5 ตัวระบุไว้ ให้ published = 0
}








แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-02-04 19:30:27 By : xbeginner01
 


 

No. 2



โพสกระทู้ ( 406 )
บทความ ( 0 )



สถานะออฟไลน์
Facebook

หนูใส่แล้ว Error ค่ะ ^.^

Code (PHP)
<?php session_start();?>
<?php require_once('../../include/connect_cms.php'); ?>
<?php require_once('../../include/function_cms.php'); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Administrator Intranet Kingfisher Holdings Ltd.</title>
<link href="../css/box-backoffice.css" rel="stylesheet" type="text/css" />
<link href="../css/text-backoffice.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="box-start">
<div id="top">
<? require_once "../toolbar.php"; ?>
<br />
<br />
<div id="boxweb1"></div>
<div id="boxweb2">
  <table width="980" border="0" cellpadding="0" cellspacing="0">
    <tr>
        
      <td width="200" align="left" valign="top">
      <div style="margin:0px 0px; width:210px;">
 <? require_once "../menu_m_right.php"; ?>
      </div>

      <td width="710" align="right" valign="top">
<!-- /////////////////////////////// From Webpage /////////////////////////////// -->
    
<!-- CheckAll Delete-->
<script language="JavaScript">
    function ClickCheckAll(vol)
    {
        var i=1;
        for(i=1;i<=document.frmdelete.hdnCount.value;i++)
        {
            if(vol.checked == true)
            {
                eval("document.frmdelete.chkDel"+i+".checked=true");
            }
            else
            {
                eval("document.frmdelete.chkDel"+i+".checked=false");
            }
        }
    }

    function onDelete()
    {
        if(confirm('Do you want to delete ?')==true)
        {
            return true;
        }
        else
        {
            return false;
        }
    }
</script>
<!-- CheckAll Delete-->

        <table id="broder-table" width="750" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#E9E9E6">
            <tr> 
                </tr>
                    <tr> 
                        <td> 
      <table width="100%" border="0" cellspacing="1" cellpadding="1">
<!--
      <div align="center">      
        <div id="broder-table1" align="left" style="width: 725px">
      <form id="frmSearch" name="frmSearch" method="get" action="<?=$_SERVER['SCRIPT_NAME'];?>"><span class="style2"> Filter (ID Doc. or Title)</span>
      <input name="txtsearch" type="text" class="input_box" id="txtsearch" size="35" value="<?php echo @$_GET['txtsearch']?>" />
      <input type="submit" name="button2" id="button2" value="Search" />
      </form>
            </div>
      </div>
   -->   
      <div align="center">      
        <div id="broder-table1" align="left" style="width: 725px" font-size="1px" font-family="Verdana, Arial, Helvetica, sans-serif">
               <span class="style2"> (A) Add Article</span>
            | <span class="style2"> (F) Add Attach File</span>
            | <span class="style2"> (L) Add Link URL</span>
            | <img width="15" height="15" border="0" align="absmiddle" src="../images/icons_backoffice/tick_F1.png"><span class="style2"> Enabled </span>
            | <img width="15" height="15" border="0" align="absmiddle" src="../images/icons_backoffice/publish_x.png"><span class="style2"> Disabled </span>
            | <img width="15" height="15" align="absmiddle" src="../images/icons_backoffice/notes_edit.png"><span class="style2"> Edit</span>
            | <img width="15" height="15" align="absmiddle" src="../images/icons_backoffice/delete_f2.png"><span class="style2"> Delete</span>
            | <img width="15" height="15" border="0" align="absmiddle" src="../images/icons_backoffice/detail_an.png"> Preview
            </div>
      </div>

<!-- CheckAll Delete-->
      <!--<form name="frmdelete" action="a_ebdeleteall.php" method="post" OnSubmit="return onDelete();">-->
<!-- CheckAll Delete-->
                  <tr> 
                    <td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr> 
        <td height="16"><table width="100%" border="0" cellspacing="1" cellpadding="1">
            <tr> 
                </tr>
                    <tr> 
                        <td> 
    <tr bgcolor="#003399">
      <th height="36" colspan="14" bgcolor="" scope="col" align="center">
      
<?php 
  $id_menu  = $_REQUEST['id']; //GET MENU

  $sql_t = "select * from jos_menu where menutype = 'menuright' and id ='$id_menu' ";
  $query_t  = mysql_query($sql_t)or die(mysql_error());
  $row_t  = mysql_fetch_array($query_t);
?>
          <span class="style1"><p class="head1"><?php echo $row_t["name"]; ?></p></span></th>
    </tr>
      <tr class="head1" bgcolor="#0066CC">
      <!--<th align="center" class="head1" width="4%"><div align="center"><input name="CheckAll" type="checkbox" id="CheckAll" value="Y" onClick="ClickCheckAll(this);"></div></th>-->
      <th align="center" class="head1" width="4%">No.</th>
      <th align="center" class="head1" width="40%">Title</th>
      <th align="center" class="head1" width="7%">Type</th>
      <th align="center" class="head1" width="11%">Modified</th>
      <th align="center" class="head1" width="19%">On Click, Open in</th>
      <th align="center" class="head1" width="6%">Status</th>
      <th align="center" class="head1" width="6%">Order</th>
      <th align="center" colspan="4" bgcolor="#FFFF99">
      <a href="a_insert_article.php?id_menu=<? echo $id_menu; ?>"><font size="2" color="#FF0000">A</font></a>
      <font color="#333333" >| </font> 
      <a href="a_insert_file.php?id_menu=<? echo $id_menu; ?>"><font size="2"  color="#FF0000">F</font></a>
      <font color="#333333" >| </font> 
      <a href="a_insert_link.php?id_menu=<? echo $id_menu; ?>"><font size="2"  color="#FF0000">L</font></a>
    </tr>      
<?php 

  $sql = "select * from jos_menu where menutype = 'menuright' and parent = '$id_menu' and sublevel = '3' and checked_out = '".$_SESSION["s_group"]."' order by ordering asc";

  $result = mysql_query($sql)or die(mysql_error());
  $total = mysql_num_rows($result);

  $pagesize = 50; // Per Page
  $page = 1;
  
  $total_page = ceil($total/$pagesize);

  if (isset($_GET[page]))
    $page = $_GET[page];
    
  $start = ($page-1)*$pagesize;
  
  $sql .= " limit $start,$pagesize";

  $result = mysql_query($sql);
  $num = mysql_num_rows($result);
 ?>
<!-- CheckAll Delete-->
<?
    $i = 0;
    $i<=$num; 
    while($row = mysql_fetch_array($result))
    {
    $color=(@$color=="#ffffff")?"#f0f0f0":"#ffffff";
    $i++; 
?>
<!-- CheckAll Delete-->
      <tr bgcolor="<?php echo $color?>">
      <!--<th align="center"><input type="checkbox" name="chkDel[]" id="chkDel<?=$i;?>" value="<?=$row["id"];?>"></th>-->
      <th align="center"><span class="style2"><?php echo $i+$start ?></span></th>
      <th align="left"><span class="style2"><?php echo mb_substr($row["name"], 0, 35, 'utf-8'); ?></span></th>
      <th align="center"><span class="style2"><?php echo linktype($row["rgt"]); ?></span></th>
      <th align="center"><span class="style2"><?php echo modifiedshortdate($row["checked_out_time"]) ?></span></th>
      <th align="center"><span class="style2"><?php echo linkwindow($row["browserNav"]) ?></span></th>
      <th align="center">
      <?php if ($_SESSION["s_level"] ==104){?>
      <? if($row['published'] == 1){?>
            <a href="a_published.php?id=<? echo $row['id']; ?>&id_menu=<? echo $id_menu; ?>&active=0"><img src="../images/icons_backoffice/tick.png" alt="Update" width="15" border="0" title="Enabled" /></a>
      <? } else { ?>
            <a href="a_published.php?id=<? echo $row['id']; ?>&id_menu=<? echo $id_menu; ?>&active=1"><img src="../images/icons_backoffice/publish_x.png" alt="Update" width="15" border="0" title="Disabled" /></a>
      <? } ?>
      <? } elseif ($_SESSION["s_level"]==107){?>
      <? if($row['published'] == 1){?>
            <? $row['id']; ?><img src="../images/icons_backoffice/tick.png" alt="Update" width="15" border="0" title="Enabled" />
      <? } else { ?> 
            <? $row['id']; ?><img src="../images/icons_backoffice/publish_x.png" alt="Update" width="15" border="0" title="Disabled" />
      <? } ?><? } ?>
      </th>

      <th align="center"><span class="style2"><?php echo $row["ordering"] ?></span></th>

      <?php if ($row["rgt"] == '4'){?>
      <th align="center" width="2%">
      <a href="../p_menu/article_detailfrom.php?id=<?php echo $row["alias"]?>&id_menu=<? echo $id_menu; ?>"><img src="../images/icons_backoffice/detail_an.png" alt="Update" width="15" border="0" title="Preview" /></a>
      </th>
      <? } elseif ($row["rgt"] == '5'){?>
      <th align="center" width="2%">
      <a href="../p_menu/file_detailfrom.php?id=<?php echo $row["id"]?>&id_menu=<? echo $id_menu; ?>"><img src="../images/icons_backoffice/detail_an.png" alt="Update" width="15" border="0" title="Preview" /></a>
      </th>
      <? } elseif ($row["rgt"] == '6'){?>
      <th align="center" width="2%">
      <a href="../p_menu/link_detailfrom.php?id=<?php echo $row["id"]?>&id_menu=<? echo $id_menu; ?>"><img src="../images/icons_backoffice/detail_an.png" alt="Update" width="15" border="0" title="Preview" /></a>
      </th>
	  <? } ?>
      
      <?php if ($row["rgt"] == '4'){?>
      <th align="center" width="2%">
      <a href="a_update_article.php?id=<?php echo $row["alias"]?>&id_menu=<? echo $id_menu; ?>"><img src="../images/icons_backoffice/notes_edit.png" alt="Update" width="15" border="0" title="Edit" /></a>
      </th>
      <? } elseif ($row["rgt"] == '5'){?>
      <th align="center" width="2%">
      <a href="a_update_file.php?id=<?php echo $row["id"]?>&id_menu=<? echo $id_menu; ?>"><img src="../images/icons_backoffice/notes_edit.png" alt="Update" width="15" border="0" title="Edit" /></a>
      </th>
      <? } elseif ($row["rgt"] == '6'){?>
      <th align="center" width="2%">
      <a href="a_update_link.php?id=<?php echo $row["id"]?>&id_menu=<? echo $id_menu; ?>"><img src="../images/icons_backoffice/notes_edit.png" alt="Update" width="15" border="0" title="Edit" /></a>
      </th>
	  <? } ?>
      
      <?php if ($row["rgt"] == '4'){?>
      <th width="2%"><a href="#" onclick="javascript: if(confirm('Delete Menu Article <?php echo "\'".$row["name"]."\'" ?> ???')){window.location='article_delete.php?id=<?php echo $row["alias"]?>&id_menu=<? echo $id_menu; ?>&id_menu=<? echo $id_menu; ?>';}"><img src="../images/icons_backoffice/delete_f2.png"  width="15" border="0" title="Delete" /></a>
      </th>
      <? } elseif ($row["rgt"] == '5'){?>
      <th width="2%"><a href="#" onclick="javascript: if(confirm('Delete Menu Link <?php echo "\'".$row["name"]."\'" ?> ???')){window.location='file_delete.php?id=<?php echo $row["id"]?>&id_menu=<? echo $id_menu; ?>&id_menu=<? echo $id_menu; ?>';}"><img src="../images/icons_backoffice/delete_f2.png"  width="15" border="0" title="Delete" /></a>
      </th>
      <? } elseif ($row["rgt"] == '6'){?>
      <th width="2%"><a href="#" onclick="javascript: if(confirm('Delete Menu Link <?php echo "\'".$row["name"]."\'" ?> ???')){window.location='link_delete.php?id=<?php echo $row["id"]?>&id_menu=<? echo $id_menu; ?>&id_menu=<? echo $id_menu; ?>';}"><img src="../images/icons_backoffice/delete_f2.png"  width="15" border="0" title="Delete" /></a>
      </th>
	  <? } ?>
      
<!-- Entry Not Found -->
    <?
      }
    if($num <= 0){
    ?>
     <tr class="comment">
        <td height="30" colspan="14" align="center" valign="middle">Entry Not Found</td>
     </tr>
<!-- Entry Not Found -->
<!-- CheckAll Delete-->
<?
    }
?>
<!-- CheckAll Delete-->
</table>
<!-- CheckAll Delete-->
     <tr class="delete_all">
      <td  class="head1" height="4">
          <!--<div align="left"><input type="submit" name="btnDelete" value="Del"><input type="hidden" name="hdnCount" value="<?=$i;?>">
          </div>--></td>
     </tr>
<!-- CheckAll Delete-->
</table>
</form>
<br />

<div align="left"><strong>
    Page : 
<?php    for ($i=1; $i<=$total_page; $i++){
     if ($i==$page)
         echo " $i ";
    else
         //echo " <a href='?page=$i'>$i</a> ";
		 echo "[ <a href='$_SERVER[SCRIPT_NAME]?page=$i&txtsearch=$_GET[txtsearch]'>$i</a> ]";

    if ($i!=$total_page)
         echo " | ";
     }
?>
<br />
Total : <?php echo $total ?>  items
</strong><br />
</div>

    <tr> 
    </tr>
           </table>
         </table>
      </table>
    
<!-- /////////////////////////////// From Webpage /////////////////////////////// -->
      </td>
    </tr>
  </table>
</div>
<div id="boxweb3"></div>
<? require_once "../footer.php"; ?>
</body>
</html>

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-02-05 10:16:29 By : nattkhanesha
 

 

No. 3



โพสกระทู้ ( 1,439 )
บทความ ( 0 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Facebook

ไปใส่ตรงไหนครับ แล้ว error อะไรครับ

* ฐานข้อมูลคล้ายๆ ของ joomla เลย ไปแกะโค้ด joomla มาหรอครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-02-05 15:17:09 By : xbeginner01
 


 

No. 4



โพสกระทู้ ( 406 )
บทความ ( 0 )



สถานะออฟไลน์
Facebook

ใช่คะ แกะโค้ดทำทั้งระบบเลย 555+
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-02-05 17:10:22 By : nattkhanesha
 


 

No. 5



โพสกระทู้ ( 3,155 )
บทความ ( 0 )

สมาชิกที่ใส่เสื้อไทยครีเอท Hall of Fame 2012

สถานะออฟไลน์


ลองดูน่ะครับ ยังไม่ได้ทดสอบโค้ดเลย
$maxrow = 100;
$sql="select id from tb_menu where parent='184' and sublevel='3' order by id desc limit 5,$maxrow";
$res = mysql_query($sql) or die(mysql_error());
while($data = mysql_fetch_row($res)){
   $outerid[] = $data[0];
}
$outeridString = implode("," , $outerid);

$sql = "update tb_menu set published='0' where id in ($outeridString)";
$res = mysql_query($sql) or die(mysql_error());

//โค้ดข้างบนนี้ช่วยแก้ไขเรื่อง 
//  "  ให้นับจากช่อง parent='184' พอนับครบ 5 อันและเป็นประเภท sublevel= '3' เท่านั้น แล้วให้เปลี่ยนสถานะที่เหลือ เช่น 6 ถึง n... ในช่อง published ให้เป็น= '0'"
//ส่วน เงื่อนไขต่อไปนี้ ผมไม่เข้าใจครับ  "โดยอ้างอิงวันเวลาใหม่และเปลี่ยนสถานะให้เป็น published= '1' ก็จะแสดงผล 1 ถึง 5 ค่ะ"


แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-02-06 00:27:26 By : sakuraei
 


 

No. 6



โพสกระทู้ ( 406 )
บทความ ( 0 )



สถานะออฟไลน์
Facebook

หนูใส่โค๊ดไม่ถูกค่ะ

Code (PHP)
$maxrow = 100;
$sql="select id from tb_menu where parent='184' and sublevel='3' order by id desc limit 5,$maxrow";
$res = mysql_query($sql) or die(mysql_error());
while($data = mysql_fetch_row($res)){
   $outerid[] = $data[0];
}
$outeridString = implode("," , $outerid);

$sql = "update tb_menu set published='0' where id in ($outeridString)";
$res = mysql_query($sql) or die(mysql_error());


แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-02-07 15:28:12 By : nattkhanesha
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : อยากได้โค๊ดนับจำนวนครบ แล้วเปลี่ยนสถานะอัตโนมัติ ค่ะ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 01
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่