Jump to content

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]
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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