Jump to content

two column results prob


adamlacombe

Recommended Posts

I am trying to get a video browse page to display videos in two columns. I have done this for a different page but cant seem to do it for this one...

 

The one that works looks like this:

<?php
$sql="SELECT * from `favorites` WHERE `username`='{$_SESSION['username']}' AND pagecat='video'";
$res=mysql_query($sql) or die(mysql_error());

if(mysql_num_rows($res) == 0){
echo "<div width='100%' class='header'>Favorites<br />"; menulinks(); echo "</div>
<div class='error'>You have no favorite videos!</div>";
}else{
echo "<table width='100%' align='center'>";
echo "<tr><td colspan='2' width='100%' class='header'>Favorites</td></tr>\n";
echo "<tr><td colspan='2' width='100%' class='header'>"; menulinks(); echo "</td></tr>\n";

$getpage=clean_up($_GET['page']);
$getpage = abs((int) ($getpage));
$total = mysql_result(mysql_query("SELECT COUNT(*) FROM favorites WHERE username='{$_SESSION['username']}' AND pagecat='video'"), 0);
$page_count = ceil($total / $resultspp);

$page = 1;
if (isset($getpage) && $getpage >= 1 && $getpage <= $page_count) {
    $page = (int)$getpage;
}
$skip = ($page - 1) * $resultspp; 

$a=0;
$fav=mysql_query("SELECT * FROM favorites WHERE username='{$_SESSION['username']}' AND pagecat='video' LIMIT $skip, $resultspp");

while($fav2=mysql_fetch_array($fav)){
$cat=clean_up($fav2[pagecat]);
$pageid=clean_up($fav2[pageid]);
   
   if ($a=='0'){echo "<tr>";}
   
   echo "<td width='50%'>";
   echo "<table width='100%'>";
   
   $res2=mysql_query("SELECT * FROM video WHERE video_id='$pageid'");
  while($favn=mysql_fetch_array($res2)){
  
      $id=clean_up($favn['video_id']);
      $views=clean_up($favn['video_views']);
      $name=clean_up($favn['video_name']);
      $thumb=clean_up($favn['video_link']);
      $metathumb=clean_up(abs($favn['video_link']));
      $des=clean_up(substr($video['game_des'], 0, 38));
      $type=clean_up($favn['video_type']);

	if($type == youtube){
		$image="<img src='http://i2.ytimg.com/vi/$thumb/default.jpg' height='45' width='45' />";
		}

	if($type == dailymotion){
		$image="<img src='http://www.dailymotion.com/thumbnail/160x120/video/$thumb.jpg' height='45' width='45' />";
		}

	if($type == metacafe){
		$image="<img src='http://s3.mcstatic.com/thumb/$metathumb.jpg' height='45' width='45' />";
		}

     
      echo "<tr>";
      echo "<td class='content' width='45'><a href=index.php?action=video&id=$id>$image</a></td>";
      echo "<td class='content' width='81%'><a href=index.php?action=video&id=$id>$name</a><br /><small>$des...<br />Watched $views Times</small></td>";
      echo "</tr>";
     
      }//end while
   
   echo "<tr><td width='81' class='content'><a href='index.php?action=favorites&type=video&go=deletev&id=$id'><small>Remove</small></a></td></tr></table>";
   echo "</td>";
   
   $a++;
   
   if ($a=='2'){echo "</tr>";$a=0;}
   
   }//end while

echo "</tr></table>";


echo "<div class='content'><center>";

if($getpage == 0 || $getpage == 1){}else{
  $plink = $getpage - 1;
  echo "      <a href='index.php?action=favorites&type=video&page=$plink'>Previous</a>       ";
}

echo "<select id='ddp' onchange='document.location=(ddp.value)'>
<option value=''>Page #</option>";
for ($i = 1; $i <= $page_count; ++$i){
    echo ' <option value="index.php?action=favorites&type=video&page=' . $i . '">' . $i . '</option>';
} 
echo "</select>";

if($getpage == $page_count){}else{
if($page_count>1){
if($getpage == 0){
  echo "       <a href='index.php?action=favorites&type=video&page=2'>Next</a>       ";
}else{
  $nlink = $getpage + 1;
  echo "       <a href='index.php?action=favorites&type=video&page=$nlink'>Next</a>       ";
}
}
}
echo "</center></div>";

} ///end if
?>

 

But I want that to work with this code:

<?php
function centercontent() {
global $resultspp;

$cat=clean_up(numeric_only($_GET['cat']));
$getpage=clean_up($_GET['page']);
$getpage = abs((int) ($getpage));
$total = mysql_result(mysql_query("SELECT COUNT(*) FROM video WHERE video_cat='$cat'"), 0);
$page_count = ceil($total / $resultspp);

$page = 1;
if (isset($getpage) && $getpage >= 1 && $getpage <= $page_count) {
    $page = (int)$getpage;
}
$skip = ($page - 1) * $resultspp;

$result = mysql_query("SELECT * FROM video WHERE video_cat='$cat' LIMIT $skip, $resultspp"); 

$cc = mysql_query("SELECT * FROM video_cat WHERE vid_id='$cat'"); 
$c = mysql_fetch_array($cc);
$catname=clean_up($c[vid_cat]);

if(mysql_num_rows($result) == 0){
echo "<div class='header'>$catname Videos</div>
<div class='error'>There are no $catname videos!</div>";
}else{

echo "<div class='header'>$catname Videos</div>";

echo "<table align='center' width='100%' class='content'>";
while ($row = mysql_fetch_array($result)) {
$link=clean_up($row[video_link]);
$metalink=clean_up(abs($row[video_link]));
$id=clean_up($row[video_id]);
$name=clean_up($row[video_name]);
$description=clean_up($row[video_des]);
$views=clean_up($row[video_views]);
$type=clean_up($row[video_type]);

	if($type == youtube){
		$img="<img src='http://i2.ytimg.com/vi/$link/default.jpg' height='71' width='71' />";
		}

	if($type == dailymotion){
		$img="<img src='http://www.dailymotion.com/thumbnail/160x120/video/$link.jpg' height='71' width='71' />";
		}

	if($type == metacafe){
		$img="<img src='http://s3.mcstatic.com/thumb/$metalink.jpg' height='71' width='71' />";
		}

echo "
<tr align='center' width='100%' valign='top'> 
      <td align='left' width='71'><span> 
$img
</span></td> 
      <td><b>
        <a href='index.php?action=video&id=$id'>$name</a></b>
<br /><small>$description<br />
Watched $views Times</small></td> 
    </tr>";
}

echo "</table><div class='content'><center>";
if($getpage == 0 || $getpage == 1){}else{$plink = $getpage - 1;echo "      <a href='index.php?action=browsev&cat=$cat&page=$plink'>Previous</a>       ";}

echo "<select id='ddp' onchange='document.location=(ddp.value)'><option value=''>Page #</option>";for ($i = 1; $i <= $page_count; ++$i){echo ' <option value="index.php?action=browsev&cat='.$cat.'&page=' . $i . '">' . $i . '</option>';}echo "</select>";

if($getpage == $page_count){}else{if($page_count>1){if($getpage == 0){echo "       <a href='index.php?action=browsev&cat=$cat&page=2'>Next</a>       ";}else{$nlink = $getpage + 1;echo "       <a href='index.php?action=browsev&cat=$cat&page=$nlink'>Next</a>       ";}}}
echo "</center></div>";

}

};

$cat=clean_up($_GET['cat']);
$cc = mysql_query("SELECT * FROM video_cat WHERE vid_id='$cat'"); 
while($c = mysql_fetch_array($cc)) {
$catname=clean_up($c[vid_cat]);


$title="$tt_browsevideo";
$title = str_replace("[videocatname]", "$catname", $title);
$metakeywords="$mtk_browsevideo";
$metakeywords = str_replace("[videocatname]", "$catname", $metakeywords);
$metadescription="$mtd_browsevideo";
$metadescription = str_replace("[videocatname]", "$catname", $metadescription);
}
?>

 

so the first code has the two column results but it pulls info from the favorites table and the from the video table but I want a page with the two column results and pulling info from only the video table where cat=$_GET[cat]

 

I hope I explained it ok..

 

Thanks in advanced,

Adam

Link to comment
https://forums.phpfreaks.com/topic/172218-two-column-results-prob/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.