Jump to content

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


davinci

Recommended Posts

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

Into this script without it repeating in the loop:
[code]
<?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><? } ?>
[/code]
Can someone show me how to insert this code as a heading rather than a repeated element?
Link to comment
https://forums.phpfreaks.com/topic/4303-want-to-insert-this-html-into-this-script/
Share on other sites

Solved it...!

This seemed to do the trick:

[code]
<?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)) { ?>
[/code]
Just place it before your while() loop:

[code]<?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

}

?>
[/code]

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.