SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Zealot
    Join Date
    Mar 2006
    Posts
    192
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problem with displaying the contents on the Webpage.

    Hi all,
    I'm displaying a query result of 1000+ rows in a table containing 10 columns and after executing the query on click of a button it displays only around 30 rows. Not able to figure out the problem. Any help would be appreciated. Thank you all.

  2. #2
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    are you sure your query is returning more than 30 rows?

    look at mysql_num_rows()

  3. #3
    SitePoint Zealot
    Join Date
    Mar 2006
    Posts
    192
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yeah, i'm displaying the number of rows at the starting of the page.thats how i got to know 1000+ rows are their in the query result. The execution takes some time and after some time it displays only around 30 rows. Should i post the code ?

  4. #4
    SitePoint Wizard bronze trophy devbanana's Avatar
    Join Date
    Apr 2006
    Location
    Pennsylvania
    Posts
    1,736
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah, I think we'll need to see some code. It really should be displaying everything that's returned, if you're doing it correctly.

  5. #5
    SitePoint Zealot
    Join Date
    Mar 2006
    Posts
    192
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok. code for creating the query is below.


    Code:
    <HTML>
    <HEAD>
    <TITLE>Streamware</TITLE>
    <script language="JavaScript">
    var finalquery=""
    var conditionflag=false
    
    function addstring(nam,str1)
    {
    	if((nam=="streamname") || (nam=="streamtype") || (nam=="transporttype") || (nam=="resolution"))
    	{
    		finalquery=finalquery+"%20"+nam+"%20like%20'"+str1+"'%20and"
    	}
    	else
    	{
    		finalquery=finalquery+"%20round("+nam+")=round("+str1+")%20and"
    	}
    	conditionflag=true
    }
    
    function runquery(str)
    {
    	finalquery=(finalquery.substring(0,finalquery.length-3))
    	if(conditionflag)
    	{
    		finalquery="select%20*%20from%20streams%20where%20"+finalquery
    	}
    	else
    	{
    		finalquery="select%20*%20from%20streams"
    	}
    	location.href="runquery.php?fields="+str+"&query="+finalquery
    }
    
    function goback()
    {
    	location.href="aquery.html"
    }
    
    </script>
    </HEAD>
    
    <BODY background=images/ltgray_lines1.gif text=000000>
    <center>
    <?
    $pstreamtype=$_REQUEST[pstreamtype];
    $pstreamname=$_REQUEST[pstreamname];
    $pprofile=$_REQUEST[pprofile];
    $presolution=$_REQUEST[presolution];
    $pclockrate=$_REQUEST[pclockrate];
    $pvideopid=$_REQUEST[pvideopid];
    $ppcrpid=$_REQUEST[ppcrpid];
    $paudiopid=$_REQUEST[paudiopid];
    $pvideotype=$_REQUEST[pvideotype];
    $paudiotype=$_REQUEST[paudiotype];
    $pac3bitrate=$_REQUEST[pac3bitrate];
    $pac3mod=$_REQUEST[pac3mod];
    $psamplerate=$_REQUEST[psamplerate];
    
    $sstreamtype=$_REQUEST[sstreamtype];
    $sstreamname=$_REQUEST[sstreamname];
    $sprofile=$_REQUEST[sprofile];
    $sresolution=$_REQUEST[sresolution];
    $sclockrate=$_REQUEST[sclockrate];
    $svideopid=$_REQUEST[svideopid];
    $spcrpid=$_REQUEST[spcrpid];
    $saudiopid=$_REQUEST[saudiopid];
    $svideotype=$_REQUEST[svideotype];
    $saudiotype=$_REQUEST[saudiotype];
    $sac3bitrate=$_REQUEST[sac3bitrate];
    $sac3mod=$_REQUEST[sac3mod];
    $ssamplerate=$_REQUEST[ssamplerate];
    
    $query="";
    
    if(isset($all)) 
    {
    	$query="streamtype,streamname,profile,resolution,clockrate,videopid,pcrpid,audiopid,videotype,audiotype,ac3bitrate,ac3mod,samplerate ";
    }
    else 
    {
    
    	if(isset($sstreamtype)) 
    	{
    		$query.="streamtype,";
    	}
    	if(isset($sstreamname)) 
    	{
    		$query.="streamname,";
    	}
    	if(isset($sprofile)) 
    	{
    		$query.="profile,";
    	}
    	if(isset($scategory)) 
    	{
    		$query.="category,";
    	}
    	if(isset($sresolution)) 
    	{
    		$query.="resolution,";
    	}
    
    
    	if(isset($sclockrate)) 
    	{
    		$query.="clockrate,";
    	}
    
    	if(isset($svideopid)) 
    	{
    		$query.="videopid,";
    	}
    	if(isset($spcrpid))
    	{
    		$query.="pcrpid,";
    	}
    	if(isset($saudiopid))
    	{
    		$query.="audiopid,";
    	}
    	if(isset($saudiotype)) 
    	{
    		$query.="audiotype,";
    	}
    	if(isset($svideotype)) 
    	{
    		$query.="videotype,";
    	}
    	if(isset($sac3bitrate)) 
    	{
    		$query.="ac3biterate,";
    	}
    
    	if(isset($sac3mod)) 
    	{
    		$query.="ac3mod,";
    	}
    	if(isset($ssamplerate)) 
    	{
    		$query.="samplerate,";
    	}
    }
    //echo "Query is $query";
    
    $query1=substr($query,0,strlen($query)-1);
    //echo "Query1 is $query1";
    ?>
    <Form name="createquery" enctype="multipart/form-data" method="post" action="runquery1.php?">
    <table border=0 cellpadding=4 cellspacing=1>
    
    
    
    <td valign=top align=right><tt><b>Display Fields: </b></td>
    <td valign=top>
    <?
    $qsize=strlen($query1)+1;
    if ( $qsize > 66 ) $qsize=66;
    echo "<INPUT readonly name=\"query1\" value=$query1 size=$qsize >";
    ?>
    <tr></tr><tr></tr><tr></tr><tr></tr><tr></tr><tr></tr>
     </td>
    <?
    if(isset($pstreamtype)) 
    {
    
    	$db = mysql_connect("localhost", "root", "ramki");
    	mysql_select_db("streaware",$db);
    	$username = "root";
    	$password = "ramki";
    	$db_name = "streamware";
    	$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());
    
    	$query = "SELECT * from type";
        	$result = mysql_query($query, $connection);
    
    
    	$num = mysql_numrows($result);
     ;	mysql_close();
    	if ( $num== 0 ) 
    	{
    		mysql_close();
    		exit;	
    	}
    
    	$i=0;
    	?>
    	<tr>
        <td valign=top align=right><tt><b>Stream Type</b></td>
        <td valign=top>
        <select name="streamtype">
    	<?
    	while ( $i < $num ) 
    	{
    	
    		$name=mysql_result($result,$i,"streamtype");
    		$id=mysql_result($result,$i,"streamid");
    		
    
    		?>
    		<option value=<? echo $id ?> ><? echo $name ?></option>
    		<?
    		$i++;
    	}
    	?>
    	</select><br>
        </td>
    <?
    }
    
    if(isset($pstreamname)) 
    {
    ?>
                 <tr>
                     <td valign=top align=right><tt><b>Stream Name</b></td>
                     <td valign=top><input type="text" name="streamname" size="30"><br></td>
                 </tr>
    <?
    }
    
    if(isset($pprofile)) 
    {
    ?>
     			 <tr>
                 <td valign=top align=right><tt><b>Profile</b></td>
                 <td valign=top>
      <select name="profile" >
    <option value="">Select the profile...</option>
    
    <option value="HD">HD</option>
    <option value="SD">SD</option>
    <option value="AUD">Audio only</option>
                             </select><br>
                 </td>
    <?
    }if(isset($pcategory)) {
    ?>
     			 <tr>
                 <td valign=top align=right><tt><b>Category</b></td>
                 <td valign=top>
      <select name="category" >
    <option value="NA">Select the category...</option>
    <option value="Allegro ES">Allegro ES</option>
    <option value="Customer-Echostar">Customer-Echostar</option>
    <option value=Customer-GI">Customer-GI</option>
    <option value="Customer-Motorola">Customer-Motorola</option>
    <option value="Customer-NDS">Customer-NDS</option>
    <option value="Customer-Osmosys">Customer-Osmosys</option>
    <option value="Customer-Pace">Customer-Pace</option>
    <option value="Customer-Pioneer">Customer-Pioneer</option>
    <option value="Customer-Sony">Customer-Sony</option>
    <option value="Customer-Thomson">Customer-Thomson</option>
    <option value="Customer-TimeWarner">Customer-TimeWarner</option>
    <option value="Customer-TMMBskyB">Customer-TMMBskyB</option>
    <option value="Customer-Zinwell">Customer-Zinwell</option>
    <option value="Direct TV Doctor Design">Direct TV Doctor Design</option>
    <option value="HITS">HITS</option>
    <option value="JVT Conformance ES">JVT Conformance ES</option>
    <option value="MISC">MISC</option>
    <option value="MPEG L1">MPEG L1</option>
    <option value="MPEG L2">MPEG L2</option>
    <option value="MPEG1L3">MPEG1L3</option>
    <option value="QAM 256">QAM 256</option>
    <option value="Sarnoff DirecTV"> Sarnoff DirecTV</option>
    <option value="Sarnoff IP">Sarnoff IP</option>
    <option value="Sarnoff IPB">Sarnoff IPB</option>
    <option value="Sarnoff Lipsync">Sarnoff Lipsync</option>
    <option value="Sarnoff PAL">Sarnoff PAL</option>
    <option value="Sarnoff Stress">Sarnoff Stress</option>
    <option value="Sarnoff Syntax">Sarnoff Syntax</option>
    <option value="Other">Other</option>
                             </select><br>
                 </td>
    <?
    }
    if(isset($presolution)) {
    ?>
                <tr>            
                     <td valign=top align=right><tt><b>Resolution</b></td>
                     <td valign=top><input type="text" name="resolution1" size="2">
    				 x
                     <input type="text" name="resolution2" size="2"><br></td>
                </tr>
    <?
    }
    
    if(isset($pclockrate)) {
    ?>
                 <tr>                 
                     <td valign=top align=right><tt><b>Clock Rate</b></td>
                     <td valign=top><input type="text" name="clockrate" size="10" onchange="chkclcokrate()"><br></td>
                 </tr>
    <?
    }
    if(isset($pvideopid)) {
    ?>
                 <tr>                
                     <td valign=top align=right><tt><b>Video Pid</b></td>
                     <td valign=top><input type="text" name="videopid" size="6"><br></td>
                 
                 </tr>
    <?
    }
    if(isset($ppcrpid)){
    ?>
                 <tr>                
               
                     <td valign=top align=right><tt><b>PCR Pid</b></td>
                     <td valign=top><input type="text" name="pcrpid" size="6"><br></td>
                 </tr>
    <?
    }
    if(isset($paudiopid)){
    ?>
                <tr>
                     <td valign=top align=right><tt><b>Audio Pid</b></td>
                     <td valign=top><input type="text" name="audiopid" size="6"><br></td>
                 </tr>
    <?
    }
    
    
    if(isset($pvideotype)) {
    ?>
                 <tr>                 
    			     <td valign=top align=right><tt><b>Video Type</b></td>
                     <td valign=top><input type="text" name="videotype" size="8" onchange="chkbitrate()"><br></td>
                 </tr>
    <?
    }
    if(isset($paudiotype)) {
    ?>
                 <tr>                 
    			     <td valign=top align=right><tt><b>Audio Type</b></td>
                     <td valign=top><input type="text" name="audiotype" size="8" onchange="chkbitrate()"><br></td>
                 </tr>
    <?
    }
    if(isset($pac3bitrate)) {
    ?>
                 <tr>
                     <td valign=top align=right><tt><b>AC3 Bit Rate</b></td>
                     <td valign=top><input type="text" name="ac3bitrate" size="10" onchange="chkpacketsize()"><br></td>
                 </tr>
    <?
    }
    if(isset($pac3mod)) {
    ?>
    
                 <tr>          
                     <td valign=top align=right><tt><b>AC3 Mod</b></td>
                     <td valign=top><input type="text" name="ac3mod" size="8" onchange="chkaspectratio()"><br></td>
                 </tr>
    <?
    }
    if(isset($psamplerate)) {
    ?>
                 <tr>                 
    	             <td valign=top align=right><tt><b>Sample Rate</b></td>
    		         <td valign=top><input type="text" name="samplerate" size="10" onchange="chkframerate()"><br></td>
                 </tr>
    <?
    }
    
    //echo "<tr><td><input type=\"button\" value=\"RUN\" onclick=\"runquery('$query1')\"></td><td><input type=\"reset\"></td><td><input type=\"button\" value=\"BACK\" onclick=\"goback()\"></td></tr>";
    ?>
    		<tr>
                 <td valign=top align=left> </td>
                 <td valign=top>
    			 <input type="submit" value="Run" >
    
    
                 <input type="reset" value="Clear">
                 </td>   
    		</tr>
    
    </TABLE>
    </center>
    </FORM>
    </BODY>
    </HTML>
    and...... the display code is below:

    Code:
    <?php
    error_reporting(E_ALL); 
    ?>
    
    <HTML>
    <HEAD>
    <TITLE>Search</TITLE>
    </HEAD>
    <BODY background=images/ltgray_lines1.gif text=ffffff link=ffffff vlink=ff0000>  <br>
    <?php
    
    //if ( $streamname ) { 
    //$streamname=substr($streamname,0,strlen($streamname)-3);
    //$query="";$query.="streamname,";
    
    //$streamname=sprintf("This is a test %s %s",$streamname, "ddd"	);
    //$streamname.="sasdaasadsdas";
    //echo"streamname==$streamname== ++$query1+";
    //}
    
    
    $streamtype=$_REQUEST[streamtype];
    $streamname=$_REQUEST[streamname];
    $profile=$_REQUEST[profile];
    $resolution1=$_REQUEST[resolution1];
    $resolution2=$_REQUEST[resolution2];
    $clockrate=$_REQUEST[clockrate];
    $videopid=$_REQUEST[videopid];
    //echo "the value of videopid is $videopid";
    $pcrpid=$_REQUEST[pcrpid];
    $audiopid=$_REQUEST[audiopid];
    $videotype=$_REQUEST[videotype];
    $audiotype=$_REQUEST[audiotype];
    $ac3bitrate=$_REQUEST[ac3bitrate];
    $ac3mod=$_REQUEST[ac3mod];
    $samplerate=$_REQUEST[samplerate];
    $query= $_REQUEST[query];
    //echo "-------- $query-------";
    $query1= $_REQUEST[query1];
    //echo "-------- $query1-------";
    
    $query2="where ";
    
    if($query1=="all" ) {
        $query1="streamtype,streamname,resolution,clockrate,videopid,videotype,pcrpid,audiopid,audiotype,samplerate,ac3mod,ac3bitrate";
    }
    
    //----------  rkiran changed  typeid to streamid 23-3-06 -------------------------- 
    //$query1=str_replace("streamtype","typeid",$query1);
    $query1=str_replace("streamtype","streamid",$query1);
    //--------------------------------------------------
    
    
    
    if (isset($streamid) ) {
    $query2=sprintf("%s streamid='%s' and",$query2, $streamtype);
    }
    
    if (isset($streamname) ) {
    	if ($streamname == "" ) $temp="%";
    	else {
    		$temp=str_replace(" ","%",$streamname);
    		$temp=str_replace("*","%",$temp);
    	}
    $query2=sprintf("%s streamname like '%s' and",$query2, $temp);
    }
    
    if ( isset($profile) ) {
    	if ($profile != "")  $query2=sprintf("%s profile='%s'  and",$query2,  $profile);
    	else  $query2=sprintf("%s profile like '%s'  and",$query2,"%");
    }
    
    
    if (isset($resolution1) ) {
    $temp1=str_replace(" ","%",$resolution1);
    $temp2=str_replace(" ","%",$resolution2);
    $query2=sprintf("%s resolution like '%s%sx%s%s' and",$query2, "%", $temp1, $temp2, "%");
    
    }
    
    if (isset($clockrate) ) {
    $temp=str_replace(" ","",$clockrate);
    $temp=str_replace("*","",$temp);
    if ($temp!="" ) 
       $query2="$query2 round(clockrate)=round($temp) and";
    } 
    
    if (isset($videopid) ) {
    $temp=str_replace(" ","%",$videopid);
    $temp=str_replace("*","%",$temp);
    $query2=sprintf("%s videopid like '%s%s%s' and",$query2, "%", $temp, "%");
    //echo "---------$query2---------------";
    }
    
    if (isset($pcrpid) ) {
    $temp=str_replace(" ","%",$pcrpid);
    $temp=str_replace("*","%",$temp);
    $query2=sprintf("%s pcrpid like '%s%s%s' and",$query2, "%", $temp, "%");
    }
    
    if (isset($audiopid) ) {
    $temp=str_replace(" ","%",$audiopid);
    $temp=str_replace("*","%",$temp);
    echo "the value of temp is $temp";
    $query2=sprintf("%s audiopid like '%s%s%s' and",$query2, "%", $temp, "%");
    }
    
    if (isset($videotype) ) {
    $temp=str_replace(" ","",$videotype);$temp=str_replace("*","%",$temp);
    $query2=sprintf("%s videotype like '%s%s%s' and",$query2, "%", $temp, "%");
    }
    
    if (isset($audiotype) ) {
    $temp=str_replace(" ","",$audiotype);$temp=str_replace("*","%",$temp);
    $query2=sprintf("%s audiotype like '%s%s%s' and",$query2, "%", $temp, "%");
    }
    
    if (isset($ac3bitrate) ) {
    $temp=str_replace(" ","",$ac3bitrate);$temp=str_replace("*","%",$temp);
    $query2=sprintf("%s ac3bitrate like '%s%s%s' and",$query2, "%", $temp, "%");
    }
    
    if (isset($ac3mod) ) {
    $temp=str_replace(" ","",$ac3mod);$temp=str_replace("*","%",$temp);
    $query2=sprintf("%s ac3mod like '%s%s%s' and",$query2, "%", $temp, "%");
    }
    
    if (isset($samplerate) ) {
    $temp=str_replace(" ","",$samplerate);$temp=str_replace("*","%",$temp);
    $query2=sprintf("%s samplerate like '%s%s%s' and",$query2, "%", $temp, "%");
    }
    
    
    
    
    $query2=substr($query2,0,strlen($query2)-3);
    
    //echo"=====$query2====";
    $query=sprintf("SELECT * from streams %s order by streamname",$query2);
    echo "===$query===";
    //echo "===$query1===";
    
    $db = mysql_connect("localhost", "root", "ramki");
    mysql_select_db("streamware",$db);
    $username = "root";
    $password = "ramki";
    $db_name = "streamware";
    $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());
    //$query1=strtr($query,"\'","%'");
    //$query=str_replace("like %'","like '%",$query1);
    $result = mysql_query($query, $connection);
    //echo "\nQuery: $query\nResult: $result";
    
    //echo "Results obtained are $result";
    
    if($result==0)
    {
    	echo "<font color=black><center><h3>Please Check: Your inputs are INVALID</h3></center></font>";
    	exit;
    }
    
    $num=mysql_numrows($result);
    
    if ($num==0)
    {
    	echo"<font color=black><center><h3>No Results Found</h3></center></font>";
    	exit;
    }
    
    if(strlen($query1)<=0)
    {
    	echo "<font color=black><center><h3>No Field Selected</h3></center></font>";
    	exit;
    }
    echo "<font color=black><center><h4><b>Total Records Found:$num</b></h4></center></font>";
    
    mysql_close();
    
    $ifields=split(",",$query1);
    
    
    $i=0;
    $bgc="black";
    echo "<center><font size=9 face=\"book antiqua\"><table cellspacing=1 border=3><tr bgcolor=000000><th>Sl #</th>";
    echo "<th>StreamId</th>";
    echo "<th>Directory Path</th>";
    echo "<th>Name</th>";
    echo "<th>For Details</th>";
    
    foreach($ifields as $field)
    {
    	if ($field=="typeid")
    	{
    	}
    	else 
    	{ 
    		if ($field=="streamname") 
    		{
    		}
    		else 
    		{
    		echo "<th>$field</th>";
    		}
    	}	
    }
    
    while ($i<=$num-1) 
    {
    	$type=mysql_result($result,$i,"streamid");
    	$directory=mysql_result($result,$i,"directoryid");
    	//$type=mysql_result($result,$i,"typeid");
    	$streamname=mysql_result($result,$i,"streamname");
    	$streampath=mysql_result($result,$i,"streampath");        
    
    	$querytype = "SELECT * from type where id=$type";
    	$resulttype = mysql_query($querytype, $connection);
    	$typename=mysql_result($resulttype,0,"name");
    
    	//$dirname = "SELECT * from directory where id=$directory and typeid=$type";
    	//$resulttype = mysql_query($dirname, $connection);
    	//$directoryname=mysql_result($resulttype,0,"name");
    
    	echo "<tr bgcolor=$bgc><td>$i</td>";
    	echo "<td>$type</td>";
    	echo "<td>$streampath</td>";
    	echo "<td>$streamname</td>";
    	echo "<td><a href=\"details.php?type=$type&directory=$streampath&name=$streamname\" target=main>Click Here </a></td>";
    
    	foreach($ifields as $field)
    	{
    		if ($field=="type"  || $field=="streamname" ) 
    		{
    		  // Do Nothing.
    		} 
    		else 
    		{
    
    			$value=mysql_result($result,$i,$field);
    			$Hex="";
    			if ( $field=="pcrpid" || $field=="audiopid" || $field=="videopid" ) 
    			{
    				if ( hexdec($value) !=0 ) $Hex="0x";
    			} 
    			else if ( $field=="ac3bitrate" || $field=="samplerate" ) 
    			{
    				if ( $value="0.000000") $value="";
    			}
    
    			echo "<td>$Hex$value</td>";
    		}
    	}
    	$next=$i+1;
    	if ($i%2==0)
    	{
     		$bgc="gray";
    	}
    	else
    	{
     		$bgc="black";
    	}
    	$i++;
    }
    echo"</table></font></center>";
    
    ?>
    </BODY>
    </HTML>

  6. #6
    SitePoint Wizard bronze trophy devbanana's Avatar
    Join Date
    Apr 2006
    Location
    Pennsylvania
    Posts
    1,736
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Your code is extremely, very hard to follow And that is an understatement. It also seems that, if I am understanding it correctly, it is very insecure.

    In any case, you are closing the mysql result before you even attempt to display the result. That is most likely why you're only getting part of the data. Secondly, you should probably do something like:

    PHP Code:
    while ($row mysql_fetch_array($result))
    {
        
    // ...

    instead of doing what you are doing with using mysql_result(). I'd recommend using mysql_fetch_array() instead.


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
  •