SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast chitara's Avatar
    Join Date
    Dec 2005
    Posts
    63
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    script not woking for delete, edit & page limit

    Hi
    After change the server apache to IIS scripts are not working. Can anyone tell me why?


    my file is as follows:

    ***[
    * My first file- view_category_in.php>>
    <body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
    <div align=center>
    <?php
    //$cat_dir = "cat_photo";
    //include ('../include/newsession.php');
    include('../include/db.php');
    //include('header.php');
    echo "<link href=../../images/style.css type=text/css rel=stylesheet>";

    // to delete the row
    $del=$_GET['delete'];
    if(isset($del))
    {
    $sql = "delete from category_tab where cat_id=$del";
    @mysql_query ($sql, $link);
    }

    // to edit the row
    $cmd=$_GET['cmd'];
    if(!isset($cmd))
    {
    $sql = "UPDATE category_tab SET cat_name='$c_name',cat_details='$description',position='$position',status='$status' WHERE cat_id=$id";
    @mysql_query ($sql, $link);
    }

    ?>

    <table width="80%" border="0" cellspacing="1" cellpadding="1">
    <TR bgcolor=#006699>
    <TD align=center colspan=9><FONT face=verdana SIZE="2" COLOR="white"><B> Category List</B></TD>
    </TR>

    <TR bgcolor="#FFF7E1">
    <TD class=body><center><B>Id</B></center></TD>
    <TD class=body><center><B>Category Heading</B></center></TD>
    <TD class=body><center><B>Details</B></center></TD>
    <TD class=body><center><B>Action</B></center></TD>
    </TR>

    <?php
    $page_name=$_GET['view_category_in.php'];// The page name

    if(!isset($start)) { // This variable is set to zero for the first page
    $start = 0;
    }

    $pg = ($start - 0);
    $limit = 10; // No of records to be shown per page.
    $this = $pg + $limit;
    $back = $pg - $limit;
    $next = $pg + $limit;
    //echo $this;
    //echo $back;
    //echo $next;
    $query_cat="select * from category_tab order by cat_id desc";
    $result_cat=mysql_query($query_cat);
    $num_cat=mysql_num_rows($result_cat);

    echo "<font class=body>Total Category = $num_cat</font>";

    $result = mysql_query( "select * from category_tab limit $pg, $limit");
    $nr = mysql_num_rows( $result );
    echo mysql_error();

    while( $row = mysql_fetch_array( $result ) )
    {
    if($bgcolor=='#f1f1f1'){$bgcolor='#FFF0E1';}
    else{$bgcolor='#f1f1f1';}
    ?>

    <TR>

    <TD class=body bgcolor=<?php print "$bgcolor";?> id='title'><center>&nbsp;<?php print $row["cat_id"]; ?></center></TD>
    <TD class=body bgcolor=<?php print "$bgcolor";?> id='title'><center>&nbsp;<?php print $row["cat_name"]; ?></center></TD>
    <TD class=body bgcolor=<?php print "$bgcolor";?> id='title'><center>&nbsp;<?php print $row["cat_details"]; ?></center></TD>
    <TD class=body bgcolor=<?php print "$bgcolor";?> id='title'><center>&nbsp;<a class=mail href= "view_category_in.php?delete=<?php print $row["cat_id"]; ?>" target=_self>Delete</a> / <a class=mail href="edit_category_in.php?cmd=edit&id=<?php print $row["cat_id"];?>" target=_self>Edit</a></center></TD>
    </TR>

    <?
    } // end of the while loop


    // Start the buttom links with Prev and Next link with page numbers
    echo "<BR><table align = 'center' width='50%'><tr><td align='left' width='30%'>";
    // if our variable $back is equal to 0 or more then only we will display the link to move back
    if($back >=0) {
    print "<a class=visa href='$page_name?start=$back'>PREV</a>";
    }
    // Let us display the page links at center. We will not display the current page as a link
    echo "</td><td align=center width='30%'>";
    $i=0;
    $l=1;
    for($i=0;$i < $num_cat;$i=$i+$limit){
    if($i <> $pg){
    echo " <a class=mail href='$page_name?start=$i'>$l</a> ";
    }
    else { echo "<font face='Arial' style='font-size: 8pt; color=#FF0033'>$l";} /// Current page is not displayed as link and given font color red
    $l=$l+1;
    }

    echo "</td><td align='right' width='30%'>";
    // If we are not in the last page then Next link will be displayed. Here we check that
    if($this < $num_cat) {
    $next=$_GET['next'];
    print "<a class=visa href='$page_name?start=$next'>NEXT</a>";}
    echo "</td></tr></table>";

    ?>

    </table>

    </div>
    </body>
    </html>


    *My second file=edit_category_in.php >>


    <?php

    include('../include/db.php');

    echo "<link href=../../images/style.css type=text/css rel=stylesheet><script language='JavaScript' type='text/javascript' src='../editor/wysiwyg.js'></SCRIPT>";

    //session_start();
    //echo "<br>&nbsp;&nbsp;&nbsp;&nbsp;<font class=body>Welcome $session[userid] !!!<br><br>";


    ?><div align=center>

    <br><br>

    <?
    $cmd=$_GET['cid'];
    //If cmd has not been initialized
    if(!isset($cmd))
    {
    //display all the news
    $result = mysql_query("select * from category_tab order by cat_id");

    //run the while loop that grabs all the news scripts
    while($r=mysql_fetch_array($result))
    {
    //grab the title and the ID of the news
    $pnam=$r["cat_name"];//take out the project name

    }
    }
    ?>


    <?
    if($_GET["cmd"]=="edit" || $_POST["cmd"]=="edit")
    {
    if (!isset($_POST["submit"]))
    {
    $id = $_GET["id"];
    $sql = "SELECT * FROM category_tab WHERE cat_id=$id";
    $result = mysql_query($sql);
    $myrow = mysql_fetch_array($result);
    ?>

    <form action="<?php echo $PHP_SELF; ?>" method="post" enctype="multipart/form-data">
    <input type=hidden name="id" value="<?php echo $myrow["cat_id"] ?>">
    <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="53%" id="AutoNumber1">
    <tr>
    <td class=title_online width="117%" colspan="3"><CENTER>Edit News: <?php echo $myrow["cat_name"];?></CENTER><br></td>
    </tr>
    <tr>
    <td class=body vAlign=top width="48%" align="right">News Heading&nbsp;&nbsp;</td>
    <td width="55%">
    <INPUT class=body style="WIDTH: 220px" name=cnam value="<?php echo $myrow["cat_name"];?>" size="20"></td>
    <td width="3%">&nbsp;</td>
    </tr>
    <tr>
    <td width="48%" align="right">&nbsp;</td>
    <td width="55%">&nbsp;</td>
    <td width="3%">&nbsp;</td>
    </tr>

    <tr>
    <td class=body vAlign=top width="48%" align="right">Category Details&nbsp;&nbsp;</td>
    <td width="55%">
    <textarea id="textarea1" name="desc" style="height: 170px; width: 500px;"><? echo $myrow["cat_details"];?>
    </textarea>
    <script language="javascript1.2">
    generate_wysiwyg('textarea1');
    </script>
    </td>
    <td width="3%">&nbsp;</td>
    </tr>
    <tr>
    <td width="48%" align="right">&nbsp;</td>
    <td width="55%">&nbsp;</td>
    <td width="3%">&nbsp;</td>
    </tr>

    <tr>
    <td class=body vAlign=top width="48%" align="right">Status&nbsp;&nbsp;</td>
    <td width="55%">
    <INPUT class=body style="WIDTH: 220px" name="stat" value="<? echo $myrow['status'];?>"></td>
    <td width="3%">&nbsp;</td>
    </tr>
    <tr>
    <td width="48%" align="right">&nbsp;</td>
    <td width="55%">&nbsp;</td>
    <td width="3%">&nbsp;</td>
    </tr>

    <tr>
    <td class=body vAlign=top width="48%" align="right">Position&nbsp;&nbsp;</td>
    <td width="55%">
    <INPUT class=body name="pos" style="WIDTH: 220px" value="<? echo $myrow['position'];?>"></td>
    <td width="3%">&nbsp;</td>
    </tr>
    <tr>
    <td width="48%" align="right">&nbsp;</td>
    <td width="55%">&nbsp;</td>
    <td width="3%">&nbsp;</td>
    </tr>

    <tr>
    <td width="48%">&nbsp;</td>
    <td width="55%">
    <input type="hidden" name="cmd" value="edit">
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    &nbsp;&nbsp;&nbsp;<input class=button type=submit value=submit name=submit></td>
    <td width="3%">&nbsp;</td>
    </tr>
    </table></form>

    <?
    }
    if ($_POST["$submit"])
    {
    $cat = $_POST["cnam"];
    $des = $_POST["desc"];
    $posi=$_POST["pos"];//take out the project id
    $sta=$_POST["stat"];//take out the project id


    $sql = "UPDATE category_tab SET cat_name='$cat',cat_details='$des',status='$sta',position='$posi' WHERE cat_id=$id";

    $result = mysql_query($sql);
    echo "<center><img border='0' src='../../images/templete/gap.gif' width='20' height='100'><font class=title_online>Thank you! Information of<br><font color=red>$cat</font><br> has been updated.</font><br><img border='0' src='../../images/templete/gap.gif' width='20' height='100'><a class=mail href=index.php target=_top><< back</a></center>";
    }
    }



    ?>



    ]***



    my table is like...

    CREATE TABLE `gen_page_tab` (
    `gn_pg_id` int(11) NOT NULL auto_increment,
    `gn_pg_name` varchar(100) default NULL,
    `gn_pg_type` varchar(100) default NULL,
    `gn_pg_details` text,
    `date` varchar(25) default NULL,
    `status` varchar(25) default NULL,
    `position` varchar(25) default NULL,
    PRIMARY KEY (`gn_pg_id`)
    );



    please tell me where is the problem??

  2. #2
    SitePoint Wizard
    Join Date
    Oct 2001
    Location
    Tucson, Arizona
    Posts
    1,858
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you're going to post five pages of code, could you at least put it in between the appropriate code tags. Also, what exactly isn't working with your site? Are you getting blank pages, PHP errors, server errors, etc.?

  3. #3
    SitePoint Enthusiast chitara's Avatar
    Join Date
    Dec 2005
    Posts
    63
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    in 'view_category_in.php' page five rows are coming in the first page but when I am going for the next page its not working.

  4. #4
    SitePoint Enthusiast chitara's Avatar
    Join Date
    Dec 2005
    Posts
    63
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok its working!!!

    Thanks guys to be with me:-)


Bookmarks

Posting Permissions

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