global $wpdb;
$table_name1 = $wpdb->prefix
. 's2p_member_questions';
$table_name = $wpdb->prefix .
's2p_member_uploads';
$table_name12 = $wpdb->prefix
. 's2p_scheduling';
$count=$wpdb->get_var($wpdb->prepare("SELECT
COUNT(*) from $table_name1
inner join $table_name12 on
$table_name12.schid = $table_name1.m_id
inner join $table_name on
$table_name.mid = $table_name1.m_id
where mediatype = %s ","video"));?>
<span
color="green"><?php
echo $count;echo
"<br/>";?></span>
<?php
$perpage = 5;
$pages_count = ceil($count / $perpage);
// Get the current page or set
default if not given
$page = isset($_GET['page']) ? $_GET['page']
: 1;
$pages_count = ceil($count /
$perpage);
$is_first = $page == 1;
$is_last = $page == $pages_count;
// Prev cannot be less than one
$prev = max(1, $page - 1);
// Next cannot be larger than
$pages_count
$next = min($pages_count , $page
+ 1);
if($pages_count > 0) {
//
If we are on page 2 or higher
if(!$is_first) {
echo '<a
href="?page=1">First</a>
';
echo '<a
href="?page='.$prev.'">Previous</a>';
} echo
' <span>Page <b>'.$page.'</b> / <b>'.$pages_count.'</b></span> ';
// If we are not at the last page
if(!$is_last) {
echo '<a
href="?page='.$next.'">Next</a> ';
echo '<a
href="?page='.$pages_count.'">Last</a>';
}
$lim=(int)(($page - 1)*$perpage).",
".(int)$perpage;
?>
<?php
$rows2 = $wpdb->get_results(
$wpdb->prepare( "SELECT * from
$table_name1
inner join $table_name12 on
$table_name12.schid = $table_name1.m_id
inner join $table_name on
$table_name.mid = $table_name1.m_id
where mediatype = %s order by mop_rating desc limit
$lim
","video"),
ARRAY_A );
function myRating($str)
{
global
$wpdb;
$table_name
= $wpdb->prefix . 's2p_ratings';
$rows
= $wpdb->get_row( $wpdb->prepare( " SELECT AVG(ratings) as rat FROM
$table_name WHERE mop_id = %d ", $str ));
$x
= $rows->rat;
$y
= floor($rows->rat);
$z
= $x - $y;
$m
= number_format($rows->rat, 2, '.', '');
$html
= '';
for($i=1;$i<=$y;$i++)
{
$html
.= '<img title="Rating:'.$m.'" class="ratings"
src="'.plugins_url("ratings.png", __FILE__).'" style="float:left;
width:15px;" />';
}
if($z)
{
$html
.= '<img title="Rating:'.$m.'" class="ratings"
src="'.plugins_url("halfratings.png", __FILE__).'" style="float:left;
width:9px;" />';
}return
$html;
}?>
<div style="
font-size:12px !important;float:left;width:50%;">
<?php
$k = 1;
foreach($rows2 as $mains)
{
list($a,$b)
= explode("v=",$mains['videourl']);
?>
<div style="float:left; width:100%;
margin-top:10px; ">
<div style="float:left; width:21%;
margin-right:10px;">
<strong><a href="<?php
echo home_url('profile?mid='.$mains['schid']);?>">Rider #<?php
echo $k;?></a></strong><br />
<a href="<?php echo
home_url('profile?mid='.$mains['schid']);?>#reviewForm">Review</a><br
/><?php echo myRating($mains['schid']);?>
</div>
<div style="float:left; width:60%;
">
<div style="float:left;
width:50%;">
<iframe
width="100%"
src="//www.youtube.com/embed/<?php echo $b;?>"
frameborder="0" allowfullscreen></iframe>
</div>
<div style="float:left;
margin-left:5px;">
Zip code Area: <?php echo
$mains['zip'];?><br />
of <?php echo $mains['city'];?>
</div> </div>
</div>
<?php
$k++;
}
?> </div>
<?php
}//end pagination if
}
?>
EmoticonEmoticon