I got everything going regarding PHP widgets and successfully fetched my DB.

<?php
$con = mysql_connect("mywebsite.com","DB","password");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("pages", $con);

$result = mysql_query("SELECT ebayid, reason, DATE_FORMAT(date, '%M %d, %Y')
	FROM `blacklist` ORDER BY `ebayid` ASC");

echo "<table border='0'>
<tr>
<th>EBay ID</th>
<th>Reason</th>
</tr>";

while($row = mysql_fetch_array($result))
  {
  echo "<tr>";
  echo "<td>" . $row['ebayid'] . "</td>";
  echo "<td>" . $row['reason'] . "</td>";
  echo "</tr>";
  }
echo "</table>";

mysql_close($con);
?>

so it fetches great but its one big page as seen here http://testsub.thenorthfaceguru.com/blacklist/

how can I break it into smaller bits or is it even possible to do that in Wordpress?

Thanks

Recommended Answers

All 3 Replies

Well, here's a little something to try. Please note that it has NOT been tested, as I do not have your database. :)

<?php
$con = mysql_connect("mywebsite.com","DB","password");

$lines = 5;		// The number of entries you wish to display at once.

if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("pages", $con);

$start = 1;		// Set a starting number

if($_GET['start']) {	// if this isn't page 1...
	$start += $_GET['start'];	// start where we left off
}
$end = $start+$lines;		// The end number for record calling.
$newstart = $end+1;			// if we have another page, then we use this as start
$counter = $start;			// set a counter for the loop

// Print the table headers

echo "<table border='0'>
<tr>
<th>EBay ID</th>
<th>Reason</th>
</tr>";


// Query for the records
$result = mysql_query("SELECT ebayid, reason, DATE_FORMAT(date, '%M %d, %Y')
	FROM `blacklist` ORDER BY `ebayid` ASC LIMIT $start,$end");
while($row = mysql_fetch_array($result, MYSQL_BOTH)) { // Print the lines
	echo "<tr><td>", $row['ebayid'], "</td><td>", $row['reason'], "</td></tr>\n";
	$counter++;		// Add 1 to the counter
}

// Now, let's see how many records we are dealing with
$result = mysql_query("SELECT COUNT(*) AS total FROM `blacklist`");
$row = mysql_fetch_array($result, MYSQL_BOTH);
if($counter>=$row['total']) { $continue = "Y"; } else { $continue = "N"; } // are there more pages?
echo "<tr><td colspan=2 align=center>";		// Prep an area for previous / Next links
if($start==1) {		// if this is out first page...
	echo "Previous - ";	// do not link the word
} else {
	echo "<a href='?start=", ($start-10), "'>Previous</a> - "; // link to the previous listings
}

if($continue=="N") {
	echo "Next";	// Do not link the word
} else {
	echo "<a href='?start=", $newstart, "'>Next</a>";	// Link to next results
}

echo "</td></tr></table>";	// Just to make things tidy

?>

My 2¢. Hope this helps.

commented: thanks +1

Well, here's a little something to try. Please note that it has NOT been tested, as I do not have your database. :)

<?php
$con = mysql_connect("mywebsite.com","DB","password");

$lines = 5;		// The number of entries you wish to display at once.

if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("pages", $con);

$start = 1;		// Set a starting number

if($_GET['start']) {	// if this isn't page 1...
	$start += $_GET['start'];	// start where we left off
}
$end = $start+$lines;		// The end number for record calling.
$newstart = $end+1;			// if we have another page, then we use this as start
$counter = $start;			// set a counter for the loop

// Print the table headers

echo "<table border='0'>
<tr>
<th>EBay ID</th>
<th>Reason</th>
</tr>";


// Query for the records
$result = mysql_query("SELECT ebayid, reason, DATE_FORMAT(date, '%M %d, %Y')
	FROM `blacklist` ORDER BY `ebayid` ASC LIMIT $start,$end");
while($row = mysql_fetch_array($result, MYSQL_BOTH)) { // Print the lines
	echo "<tr><td>", $row['ebayid'], "</td><td>", $row['reason'], "</td></tr>\n";
	$counter++;		// Add 1 to the counter
}

// Now, let's see how many records we are dealing with
$result = mysql_query("SELECT COUNT(*) AS total FROM `blacklist`");
$row = mysql_fetch_array($result, MYSQL_BOTH);
if($counter>=$row['total']) { $continue = "Y"; } else { $continue = "N"; } // are there more pages?
echo "<tr><td colspan=2 align=center>";		// Prep an area for previous / Next links
if($start==1) {		// if this is out first page...
	echo "Previous - ";	// do not link the word
} else {
	echo "<a href='?start=", ($start-10), "'>Previous</a> - "; // link to the previous listings
}

if($continue=="N") {
	echo "Next";	// Do not link the word
} else {
	echo "<a href='?start=", $newstart, "'>Next</a>";	// Link to next results
}

echo "</td></tr></table>";	// Just to make things tidy

?>

My 2¢. Hope this helps.

Thanks it works but the second page link would not work. This is probably a constraint of WordPress http://testsub.thenorthfaceguru.com/blacklist-test-2/

I was thinking maybe just one large page, but have a better 'chart' so lines are more visible? Do I do that in PHP or is it strictly HTML?

Thanks it works but the second page link would not work. This is probably a constraint of WordPress http://testsub.thenorthfaceguru.com/blacklist-test-2/

I was thinking maybe just one large page, but have a better 'chart' so lines are more visible? Do I do that in PHP or is it strictly HTML?

There may be php functions that will do it for you but ultimately it will be made with html, so the answer is, strictly html.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.