Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Apr 2009
    Location
    Kent, UK
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to remove the checkbox for the first instance - better description inside!

    Sorry that the title isn't very descriptive, I am creating a basic CMS script for no reason other than improving my php sql skills. (based from this - http://www.weberdev.com/get_example-4392.html)

    In the backend I have a script that shows the current web pages saved in the database, each row has an option to delete or update.

    I would like to remove the delete checkbox for the first instance only (page id 1) as this is the home page and the index script is set to load this if there is no page id in the url

    Here is my code
    PHP Code:
    <table width="775" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
      <tr>
        <td><hr size="1" noshade></td>
      </tr>
      <tr>
        <td>
          <form action="" method="post" name="" id="">
            <table width="600" border="1" align="center" cellpadding="2" cellspacing="2">
              <tr>
                <td><input name="topcheckbox" type="checkbox" class="check" id="topcheckbox" onClick="selectall();" value="ON">
    Select All &nbsp;&nbsp;&nbsp;</td>
                <td colspan="3" align="center"><a href="form.php?mode=add">Add a new page </a></td>
              </tr>
              <tr>
                <td><strong><a href="javascript:goDel()">Delete</a></strong></td>
                <td><strong>Page Title</strong></td>
                <td><strong>Link Text </strong></td>
                <td><strong>Update</strong></td>
              </tr>
              <?
              
    include("../includes/conect.php");
              
    $sql="select sn,pagename,linktext from $content order by sn";
              
    $result=mysql_query($sql,$connection) or die(mysql_error());
              while(
    $row=mysql_fetch_array($result)) {
              
    ?>
              <tr>
                <td><input name="<? echo $row['sn']; ?>" type="checkbox" class="check"></td>
                <td><? echo $row['pagename']; ?></td>
                <td><? echo $row['linktext']; ?></td>
                <td><a href="<? echo "form.php?sn=".$row['sn']."&mode=update"?>">Update</a></td>
              </tr>
              <? ?>
              <tr>
                <td><strong><a href="javascript:goDel()">Delete</a></strong></td>
                <td><strong>Page Title </strong></td>
                <td><strong>Link Text</strong></td>
                <td><strong>Update</strong></td>
              </tr>
            </table>
        </form></td>
      </tr>
    </table>
    Regards
    Jim

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,854
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    I would like to remove the delete checkbox for the first instance only (page id 1) as this is the home page and the index script is set to load this if there is no page id in the url
    I'm sorry, your description is not matching with the provided code.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    New to the CF scene
    Join Date
    Apr 2009
    Location
    Kent, UK
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Resolved:

    Replace:
    PHP Code:
              <?
              
    include("../includes/conect.php");
              
    $sql="select sn,pagename,linktext from $content order by sn";
              
    $result=mysql_query($sql,$connection) or die(mysql_error());
              while(
    $row=mysql_fetch_array($result)) {
              
    ?>
              <tr>
                <td><input name="<? echo $row['sn']; ?>" type="checkbox" class="check"></td>
                <td><? echo $row['pagename']; ?></td>
                <td><? echo $row['linktext']; ?></td>
                <td><a href="<? echo "form.php?sn=".$row['sn']."&mode=update"?>">Update</a></td>
              </tr>
    With:
    PHP Code:
              <?
              
    include("../includes/conect.php");
              
    $sql="select sn,pagename,linktext from $content order by sn";
              
    $result=mysql_query($sql,$connection) or die(mysql_error());
              while(
    $row=mysql_fetch_array($result)) {
              
    ?>
              

              <?php
              $pageid
    =$row['sn'];
              if (
    $pageid=='2')
                  echo 
    "
              <tr>
                <td>Can't Delete</td>
                <td>" 
    $row['pagename'] . "</td>
                <td>" 
    $row['linktext'] . "</td>
                <td><a href=form.php?sn=" 
    $row['sn'] . "&mode=update>Modify</a></td>
              </tr>"
                    

              else
                  echo 
    "
              <tr>
                <td><input name=" 
    $row['sn'] ." type='checkbox' class='check'></td>
                <td>" 
    $row['pagename'] . "</td>
                <td>" 
    $row['linktext'] . "</td>
                <td><a href=form.php?sn=" 
    $row['sn'] . "&mode=update>Modify</a></td>
              </tr>"
              
    ?>
    Jim


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •