Hi,
I've done pagination and i've used session variable. When i click the Page 2 and when i echo the search_string its giving me the search_string along with some junk characters!
I gave the search string as AC3 and it displays as below:
a:1:{i:0;s:3:"AC3";}
My code is as below:
<HTML>
<HEAD>
<TITLE>Search</TITLE>
</HEAD>
<BODY background=images/ltgray_lines1.gif text=000000 >
<br><br>
<Form name="searchhome" enctype="multipart/form-data" method="get" action="">
<?
session_start();
if (isset($_GET['search']))
{
$_SESSION['$search_string'] = $_GET['search'];
}
echo "Search string is " . $_SESSION['$search_string'] . "<br>";
$Limit = 75; //Number of results per page
$page=$_GET["page"]; //Get the page number to show
If($page == "") $page=1; //If no page number is set, the default page is 1
$search_items = explode(" ",$_SESSION['$search_string']);
for($i=0;$i<10;$i++)
{
//$search_items[$i]= trim($search_items[$i]);
if(preg_match('/\bac3\+|ac3([a-z]{1,4})+\b/i',$search_items[$i])) $search_items[$i] = ddp;
if(preg_match('/\baac([a-z]{1,4}+)\b/i',$search_items[$i])) $search_items[$i] = "aac+";
//echo "$search_items[$i]<br>";
}
?>
<hr>
  <FONT size=+1 >Results for: </FONT> <FONT size=+1 face="century gothic" COLOR=ff0000>  
<?php echo $_SESSION['$search_string'];
?>
</FONT>
<hr><br><br>
<?
if($_SESSION['$search_string'] == "")
{
echo "<center><h3>Invalid Entry! <br><br> Provide a valid search option and try again.</h3></center>";
//echo '<br><center><input type="reset" value="Go Back" onclick="resetstr()"></center>';
exit;
}
?>
<center>
<table><tr><td>
<!-- Search </td><td> -->
<?
$fields = "";
foreach($search_items as $value)
{
//if(preg_match('/\b(?:mpeg\d{?-}\D|es|ec3|asf)\b/i',$value) || preg_match('/\b(?:mpeg|es|ec3|asf)\b/i',$value))
if(preg_match('/\b(?:mpeg|es|ec3|asf)\b/i',$value))
{
$fields.="stream_type like '$value%' and ";
//echo "field streamtype is $fields<br>";
}
else
{
//echo "value is sddds $value sdffds<br>";
$fields.= "stream_name like '$value%' and ";
}
}
$username = "root";
$password = "";
$db_name = "stream1";
$hostname = "localhost";
$connection = mysql_connect("$hostname", "$username", "$password") or die("Invalid Login:".mysql_error());
$db = @mysql_select_db($db_name) or die("Unable to select database:".mysql_error());
$fields=trim($fields);
$fields=substr($fields,0,strlen($fields)-3);
$query = "Select TTTT.* from (Select stream_name,TTT.*,stream_id,stream_prgm_count,stream_location,remarks,duration from (Select TT.*,pcr_sid,pcr_prgm_num,pcr_pid from (Select *,case when audio_sid is NULL then video_sid ELSE audio_sid END as SID,case when audio_prgm_num is NULL then video_prgm_num ELSE audio_prgm_num END as PRNO from (Select audio_sid,audio_prgm_num,video_sid, video_prgm_num, from audio a left join video v on(audio_sid=video_sid and audio_prgm_num=video_prgm_num) union select audio_sid,audio_prgm_num,video_sid,video_prgm_num,audio_pid,audio_type,audio_sr,audio_mode,audio_bitrate, exp_aud_result,asmoke,arelese,aprstreams,video_pid,video_type,video_userdata,video_resolution,video_chroma_format,video_aspect_ratio,video_frame_rate,video_bitrate,exp_vid_result,vrelese,aprstreams,vprstreams from video v left join audio a on (audio_sid=video_sid and audio_prgm_num=video_prgm_num))T)TT left join pcr_info p on (TT.SID=p.pcr_sid and TT.PRNO=p.pcr_prgm_num))TTT left join stream s on (s.stream_id=TTT.SID))TTTT where $fields group by stream_name order by stream_name";
$result = mysql_query($query, $connection);
if($result==0)
{
echo "<font color=black><center><h3>Please Check: Your inputs are INVALID</h3></center></font>";
exit;
}
$num=mysql_num_rows($result);
echo "<font color=black><center><h4><b>Total Records Found:$num</b></h4></center></font>";
$NumberOfPages=ceil($num/$Limit);
//echo "Number of Pages is" . $NumberOfPages . "<br>" ;
$query = "Select TTTT.* from (Select stream_name,TTT.*,stream_id,stream_prgm_count,stream_location,stream_mux_bitrate,stream_size,stream_packet_size, stream_type,source,remarks,duration from (Select TT.*,pcr_sid,pcr_prgm_num,pcr_pid from (Select *,case when audio_sid is NULL then video_sid ELSE audio_sid END as SID,case when audio_prgm_num is NULL then video_prgm_num ELSE audio_prgm_num END as PRNO from (Select audio_sid,audio_prgm_num,video_sid,video_prgm_num,audio_pid,audio_type,audio_sr,audio_mode,audio_bitrate,exp_aud_result,asmoke,arelese,
aprstreams,video_pid,video_type,video_userdata,video_resolution,vprstreams from audio a left join video v on(audio_sid=video_sid and audio_prgm_num=video_prgm_num) union select audio_sid,audio_prgm_num,video_sid,video_userdata,video_resolution,video_chroma_format,video_aspect_ratio,
from video v left join audio a on (audio_sid=video_sid and audio_prgm_num=video_prgm_num))T)TT left join pcr_info p on (TT.SID=p.pcr_sid and TT.PRNO=p.pcr_prgm_num))TTT left join stream s on (s.stream_id=TTT.SID))TTTT where $fields group by stream_name order by stream_name LIMIT " . ($page-1)*$Limit . ",$Limit" ;
$result = mysql_query($query, $connection);
$num=mysql_num_rows($result);
if ($num==0)
{
echo "<br><br><br><br>";
echo"<font color=black><center><h3>No Results Found</h3></center></font>";
exit;
}
$i=0;
$bgc=100000;
echo"<center><font size=1 face=\"book antiqua\"><table cellspacing=1 border=3><tr bgcolor=CC3333><th><font color=white><b>Sl#</b></font></th><th><font color=white><b>Stream Name</b></font></th><th><font color=white><b>Video_Type</b></font></th><th><font color=white><b>Audio_Type</b></font></th><th><font color=white><b>Video Pid</b></font></th><th><font color=white><b>Audio Pid</b></font></th><th><font color=white><b>For Details</b></font></th></tr></font>";
while ($i<$num)
{
$id= mysql_result($result,$i,"stream_id");
$name=mysql_result($result,$i,"stream_name");
$resolution=mysql_result($result,$i,"video_resolution");
$aspectratio=mysql_result($result,$i,"video_aspect_ratio");
$profile=mysql_result($result,$i,"profile");
$type=mysql_result($result,$i,"");
//$directory=mysql_result($result,$i,"directoryid");
$directory=mysql_result($result,$i,"stream_location");
$expaud=mysql_result($result,$i,"exp_aud_result");
$expvid=mysql_result($result,$i,"exp_vid_result");
$next=$i+1;
//if ($i%2==1)
//{
//$bgc="gray";
//}
//else
//{
$bgc="white";
//}
$Hex1="";
$Hex2="";
$Hex3="";
if($videopid<4294967295)
{
if (($videopid) != 0 )
{
$Hex1="0x";
$videopid= dechex($videopid);
$videopid=$Hex1.$videopid;
}
}
if($pcrpid<4294967295)
{
if (($pcrpid) != 0 )
{
$Hex2="0x";
$pcrpid= dechex($pcrpid);
$pcrpid=$Hex2.$pcrpid;
}
}
if($audiopid<4294967295)
{
if (($audiopid) != 0 )
{
$Hex3="0x";
$audiopid= dechex($audiopid);
$audiopid=$Hex3.$audiopid;
}
}
if($audiotype=="AACPLUS")
{
$audiotype="AAC+";
}
$directory = addslashes($directory);
echo "<font size=0.5><tr bgcolor=$bgc><td>$next</td><td><a href=javascript:void(0); onclick=\"javascript:window.open('$directory')\" target=main title=\"Click to view the File location\">$name</a></td><td><center>$videotype</center></td>";
if($audiotype == 'DDP')
{
echo "<td><center>AC3+</center></td>";
}
else
{
echo "<td><center>$audiotype</center></td>";
}
echo "<td><center>$videopid</center></td><td><center>$audiopid</td></center><td><a href=\"aqcompletedetails.php?directory=$directory&streamname=$name&prognumb=$pprognumb&videopid=$videopid&audiopid=$audiopid&pcrpid=$pcrpid&streamid=$id&atype=$audiotype&vtype=$videotype\" target=main target=main title=\"Click to view complete details\"><center>Click Here</center></a></td></tr>";
$i++;
}
echo"</table></center>";
//echo "Number of Pages is" . $NumberOfPages . "<br>" ;
$Nav="";
$search_items=serialize($search_items);
for($i = 1 ; $i <= $NumberOfPages ; $i++)
{
if($i == $page)
{
$Nav .= "<B>$i </B>";
}
else
{
$Nav .= "<A HREF=\"search_home.php?page=" . $i . "&search=" .urlencode($search_items) . "\">$i</A>";
}
}
$Nav = trim($Nav);
//echo "Nav = $Nav<br>";
if($Nav != "1"){
echo "<BR><BR><br><center><font size=3>Pages : " . $Nav . "</font></center>";
}
echo "</font>";
mysql_close();
unset($_SESSION[$search_string]);
?>
<table>
<tr>
<td valign=top align=left> </td>
<td valign=top><br>
</td>
</tr>
</td></tr></table></FORM>
</center>
</BODY>
</HTML>
Your help will be much appreciated.
Thanks,
Ramki