Jump to content


Photo

Want to insert this HTML, into this script...


  • Please log in to reply
3 replies to this topic

#1 davinci

davinci
  • Members
  • PipPip
  • Member
  • 29 posts

Posted 07 March 2006 - 05:38 AM

Want to insert this HTML header:
<div class="title">Videos</div>

Into this script without it repeating in the loop:
<?php

include 'library/config.php';
include 'library/opendb.php';

$id = $_GET['id'];

if ($id == "") {

$rowsPerPage = 6;
$pageNum = 1; 
if(isset($_GET['page']))
{
    $pageNum = $_GET['page'];
}
$offset = ($pageNum - 1) * $rowsPerPage; 

$query = "SELECT id, name, path, title, thumbnail, playcount, DATE_FORMAT(entry_date, '%M %D %Y') FROM upload2 ORDER BY id DESC LIMIT $offset, $rowsPerPage";
$result = mysql_query($query) or die('Error, query failed');
while($row = mysql_fetch_array($result)) { ?>

<div align="center">

<table cellpadding="2" width="75%"  border="0" cellspacing="0" cellpadding="0"><tr>

<td width="50%">

<a href="<?php echo $_SERVER['PHP_SELF'] ?>?id=<?= $row['id'];?>"><IMG BORDER="0" img src="media/thumbs/<?=$row['thumbnail'];?>" height="80" width="80"><p>

</a></td>
<td width="50%">

<a href="<?php echo $_SERVER['PHP_SELF'] ?>?id=<?= $row['id'];?>"><b><?php echo $row['title'];?></b></a><br>Added on <?=$row['date'];?>
<br>Plays: <?=$row['playcount'];?> 

</td></tr></table><? } ?>
Can someone show me how to insert this code as a heading rather than a repeated element?

#2 davinci

davinci
  • Members
  • PipPip
  • Member
  • 29 posts

Posted 07 March 2006 - 05:51 AM

Solved it...!

This seemed to do the trick:

<?php

include 'library/config.php';
include 'library/opendb.php';

$id = $_GET['id'];

if ($id == "") {

$heading = '<div class="title">Video Archive</div><p>';
$rowsPerPage = 6;
$pageNum = 1; 
if(isset($_GET['page']))
{
    $pageNum = $_GET['page'];

}
$offset = ($pageNum - 1) * $rowsPerPage; 
echo $heading;
$query = "SELECT id, name, path, title, thumbnail, playcount, DATE_FORMAT(entry_date, '%M %D %Y') FROM upload2 ORDER BY id DESC LIMIT $offset, $rowsPerPage";
$result = mysql_query($query) or die('Error, query failed');
while($row = mysql_fetch_array($result)) { ?>


#3 PWD

PWD
  • Members
  • PipPip
  • Member
  • 19 posts

Posted 07 March 2006 - 05:53 AM

Just place it before your while() loop:

<?php

include 'library/config.php';
include 'library/opendb.php';

$id = $_GET['id'];

if ($id == "") {

$rowsPerPage = 6;
$pageNum = 1;
if(isset($_GET['page']))
{
    $pageNum = $_GET['page'];
}
$offset = ($pageNum - 1) * $rowsPerPage;

$query = "SELECT id, name, path, title, thumbnail, playcount, DATE_FORMAT(entry_date, '%M %D %Y') FROM upload2 ORDER BY id DESC LIMIT $offset, $rowsPerPage";
$result = mysql_query($query) or die('Error, query failed');

?>
<div class="title">Videos</div>

<?php
while($row = mysql_fetch_array($result)) { 
?>

/*Your Other HTML Markup for your loop*/

/*Then close your loop*/

<?php

}

?>

[!--fonto:Geneva--][span style="font-family:Geneva"][!--/fonto--]My Gratitude---[!--fontc--][/span][!--/fontc--]
(My gratitude in advance for helping me learn; so I may one day give as freely as you have here today)
----------
[!--sizeo:5--][span style="font-size:18pt;line-height:100%"][!--/sizeo--][!--fonto:Optima--][span style="font-family:Optima"][!--/fonto--][!--coloro:red--][span style="color:red"][!--/coloro--]PWD[!--sizec--][/span][!--/sizec--][!--colorc--][/span][!--/colorc--][!--fontc--][/span][!--/fontc--]

#4 davinci

davinci
  • Members
  • PipPip
  • Member
  • 29 posts

Posted 07 March 2006 - 06:02 AM

Your way makes more sense! I've changed it to what you told me and now I have a better understanding of why it works the way it does. Thank you very much.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users