Jump to content

Ajax Help


Sajesh Mohan

Recommended Posts

First page

 

<script language="javascript" src="ajax/ajax.js"></script>

<table width="687" border="0" cellspacing="0" cellpadding="0" align="center">

 

 

  <tr>

    <td height="10" class="normaltext"> </td>

    <td> </td>

  </tr>

  <tr>

    <td height="32" class="normaltext" align="center">Section

      <select name="ad_pos" id="ad_pos" onchange="add_ad()">

        <option value="">---Select---</option>

        <option value="Local">Local</option>

        <option value="Economy">Economy</option>

        <option value="Politics">Politics</option>

        <option value="Sports">Sports</option>

        <option value="Arts">Arts</option>

        <option value="International">International</option>

    </select><input name="ad_pos" type="hidden" value="<?php echo $ad_pos;?>" /></td>

    <td height="32" class="normaltext" align="center"> </td>

  </tr>

  <tr>

    <td height="32" class="normaltext"> </td>

    <td> </td>

  </tr>

  <tr>

    <td colspan="2"><div id="ban_pos"></div></td>

  </tr>

  <tr>

    <td height="32" class="normaltext"> </td>

    <td> </td>

  </tr>

 

</table>

 

Content page

 

<?Php

$pos=$_REQUEST['pos'];

?>

<script>

 

function confirmSubmit()

{

 

var agree=confirm("Are you sure want to Delete?");

if (agree)

return true ;

else

return false ;

}

 

</script>

<table width="631" border="0" cellspacing="0" cellpadding="0" align="center" >

  <tr>

<td colspan="3" height="30" align="left" class="page_head"> </td>

</tr>

 

  <tr>

    <td width="50"></td>

    <td width="175"></td>

    <td width="150"></td>

    <td width="100"></td>

    <td width="75"></td>

    <td width="100"></td>

  </tr>

  <tr>

  <td colspan="6" width="640">

<table width="631" align="center" cellpadding="0" cellspacing="0" class="orngbord" height="25">

  <tr >

    <td colspan="5" align="right" valign="middle"><a href="main.php?content=Ticker" class="textalign">Add  News Ticker</a> </td>

      </tr>

  <tr class="listheader">

<td width="73" align="center" valign="middle">SL.No</td>

<td width="234" align="left"> Headlines</td>

<td width="72" align="center">Status</td>

<td width="78" align="center">Edit</td>

<td width="69" align="center">Delete</td>

  </tr>

  <?php

include "dbconnect.php";

include("status.php");

$limit=1;

$page=$_REQUEST['page'];

if(empty($page)) $page=1;

$slno=($page-1)*$limit+1;

$query="select * from knews_ticker where section='$pos'";

$exe=mysql_query($query) or die(mysql_error());

$total=mysql_num_rows($exe);

if ($total==0){

?>

  <tr>

        <td colspan="8" height="25" class="normaltext_bold" align="center"> No Records Found </td>

      </tr>

      <?php

}else {

include "pagerar.php";

$pager  = Pagery::getPagerData($total, $limit, $page);

$offset = $pager->offset;

$limit  = $pager->limit;

$page  = $pager->page;

 

$query_sel="select * from knews_ticker where section='$pos' order by eco_id DESC limit $offset,$limit";

$exe_sel=mysql_query($query_sel) or die(mysql_error());

 

?><?php

while($list=mysql_fetch_object($exe_sel))

{

if($slno%2=='1')

{

$bg="#CEC3AD";

}

else

{

$bg="#EDD9B1";

}

$id=$list->eco_id;

$headlines=stripslashes(preg_replace('~\s{2,}~','',$list->heading));//$list->spotlight_heading;

 

 

?>

     

      <tr bgcolor="<?php echo $bg;?>">

          <td height="25" class="listitem" align="center" ><?php echo $slno;?></td>

                <td class="listitem" > <?php echo substr($headlines,0,240); ?></td>

                <td class="listitem" align="center" ><?php showStatus('knews_ticker','eco_id','status',$id);  //showStatus(table name,idfield,status field, id)?></td>

                <td align="center"><a href="main.php?content=Edit_Ticker&id=<?php echo $id;?>"><img src="../images/edit.gif" border="0"  title="Edit" /></a><input name="id" type="hidden" value="<?php echo $id;?>" /></td>

            <td align="center"><a href="delete_ticker.php?id=<?php echo $id;?>" onclick="return confirmSubmit()" ><img src="../images/delete.gif" border="0" title="Delete"></a></td>

          <?php

$slno=$slno+1;

}

?>

        </tr>

          <tr>

          <td colspan="6" height="15"></td>

        </tr>

 

 

          <tr>

          <td colspan="5" style="text-align:right;" height="25" bgcolor="#C2B59B">

            <?php

    if($total>$limit)

  {

$url="main.php?content=List_Ticker";

if ($total > $limit)

{

if($page>$total-5)

{

$c=$total-$page;

$page1=$page+$c;

 

}

else

{

$page1=$page+5;

}

}

if($page<6)

{

$d=6-$page;

$s=5-$d;

$page2=$page-$s;

}

else

{

$page2=$page-5;

}

 

if ($page == 1) // this is the first page - there is no previous page

{

 

  // echo "Previous";

}

else

{          // not the first page, link to the previous page

echo "<a href=\"$url&page=1\"></a>";

echo " ";

echo " ";

echo "<a href=\"$url&page=" . ($page - 1) . "\" class=\"normaltext\">Previous</a>";

}

if($page<6)

{

for ($i = 1; $i <= $pager->numPages; $i++)

{

echo " | ";

if ($i == $page)

echo "","$i";

else

echo "<a href=\"$url&page=$i\" class=\"normaltext\">$i</a>";

}

echo " | ";

}

else

{

for ($i = $page2; $i <= $page; $i++)

{

echo " | ";

if ($i == $page)

echo "$i";

else

echo "<a href=\"$url&page=$i\">$i</a>";

}

  ////

}

if ($page == $pager->numPages) // this is the last page - there is no next page

{

 

echo "";

}

else

{            // not the last page, link to the next page

 

echo "<a href=\"$url&page=" . ($page + 1) . "\" class=\"normaltext\">Next</a>";

echo "";

echo "<a href=\"$url&page=".$total."\"></a>";

}

}?>   </td>

 

    </tr>

          <tr>

            <td colspan="5" style="text-align:right;" height="25" > </td>

          </tr>

    <?php }?>

</table>

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.