Jump to content

Help in identifying where the error is


sankarkarthikeyan

Recommended Posts

Can you help me with where im going wrong here in this code this with a search function

i am see the out put with pagination view however $id is not getting captured as the link id  any help would be appreciated 

 

<form name="frmSearch" method="get" action="<?=$_SERVER['SCRIPT_NAME'];?>">

  <table id="tic">    <tr>

      <td>Ticket No | Emp ID:</td><td><input name="txtKeyword" type="text" id="txtKeyword" value="<?=$_GET["txtKeyword"];?>"></td>

      <td><input type="submit" name="submit" value="Search"></td>

    </tr>

  </table>

</form>

<?

if($_GET["txtKeyword"] != "")

{

$objConnect = mysql_connect("localhost","root","") or die(mysql_error());

$objDB = mysql_select_db("ticket");

 

$result = "SELECT * FROM data WHERE (employee LIKE '%".$_GET["txtKeyword"]."%')";

$objQuery = mysql_query($result) or die ("Error Query [".$result."]");

$Num_Rows = mysql_num_rows($objQuery);

 

 

$Per_Page = 5;  // Per Page

 

$Page = $_GET["Page"];

if(!$_GET["Page"])

{

$Page=1;

}

 

$Prev_Page = $Page-1;

$Next_Page = $Page+1;

 

$Page_Start = (($Per_Page*$Page)-$Per_Page);

if($Num_Rows<=$Per_Page)

{

$Num_Pages =1;

}

else if(($Num_Rows % $Per_Page)==0)

{

$Num_Pages =($Num_Rows/$Per_Page) ;

}

else

{

$Num_Pages =($Num_Rows/$Per_Page)+1;

$Num_Pages = (int)$Num_Pages;

}

 

 

$result .=" order  by stamp LIMIT $Page_Start , $Per_Page";

$objQuery  = mysql_query($result);

 

?>

<table id="ticket"   <tr>

<th> <div align="center">Ticket No</div></th>

                <th> <div align="center">Date</div></th>

<th> <div align="center">Issue Type</div></th>

<th> <div align="center">Status</div></th>

<th> <div align="center">view</div></th>

               

  </tr>

<?

while($row = mysql_fetch_array($objQuery))

{

?>

  <tr>

<td><div align="center"><?=$row["id"];?></div></td>

                <td><div align="center"><?=$row["stamp"];?></div></td>

<td><div align="center"><?=$row["issue"];?></div></td>

<td><div align="center"><?=$row["status"];?></div></td>

                <td><div align="center"><a href="edit.php?id='$row['id']'">Update</a></div></td>

 

 

</tr>

<?

}

?>

</table>

<br>

Total <?= $Num_Rows;?> Record : <?=$Num_Pages;?> Page :

<?

if($Prev_Page)

{

echo " <a href='$_SERVER[sCRIPT_NAME]?Page=$Prev_Page&txtKeyword=$_GET[txtKeyword]'>Back</a> ";

}

 

for($i=1; $i<=$Num_Pages; $i++){

if($i != $Page)

{

echo "[ <a href='$_SERVER[sCRIPT_NAME]?Page=$i&txtKeyword=$_GET[txtKeyword]'>$i</a> ]";

}

else

{

echo "<b> $i </b>";

}

}

if($Page!=$Num_Pages)

{

echo " <a href ='$_SERVER[sCRIPT_NAME]?Page=$Next_Page&txtKeyword=$_GET[txtKeyword]'>Next</a> ";

}

 

mysql_close($objConnect);

 

}

?>

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.