HI everyone
I tried in_array to build the table and it works, but it doesn't work properly (again is because i mainly use deramweaver), I have to have all the records in one page!! If anyone know how can i make it to show in different pages please let me know (because I don't have a developers logic 😕 )
<?php
$dir = "./Images/";
$filesDir = scandir($dir,1);
do { ?>
<?php
$FileName = $row_ProductPicDB['SKU'].".jpg";
if (in_array($FileName, $filesDir, true)) {} else {
?>
<tr bordercolor="#006699" bgcolor="#D5F0FC">
<td align="center"><img src="/untitled/Images/<?php echo $FileName; ?>" width="45" height="45" /></td>
<td><?php echo $row_ProductPicDB['SKU']; ?></td>
<td><?php echo $row_ProductPicDB['pretty_name']; ?></td>
<td><?php echo $row_ProductPicDB['manufacturer']; ?></td>
</tr>
<?php }} while ($row_ProductPicDB = mysql_fetch_assoc($ProductPicDB)); ?>
</table>
Here is the full Dreamweaver Code:
<?php virtual('/Connections/ProducDB.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$currentPage = $_SERVER["PHP_SELF"];
$maxRows_ProductPicDB = 1000000;
$pageNum_ProductPicDB = 0;
if (isset($_GET['pageNum_ProductPicDB'])) {
$pageNum_ProductPicDB = $_GET['pageNum_ProductPicDB'];
}
$startRow_ProductPicDB = $pageNum_ProductPicDB * $maxRows_ProductPicDB;
mysql_select_db($database_ProducDB, $ProducDB);
$query_ProductPicDB = "SELECT * FROM ProductDB ORDER BY ProductDB.SKU";
$query_limit_ProductPicDB = sprintf("%s LIMIT %d, %d", $query_ProductPicDB, $startRow_ProductPicDB, $maxRows_ProductPicDB);
$ProductPicDB = mysql_query($query_limit_ProductPicDB, $ProducDB) or die(mysql_error());
$row_ProductPicDB = mysql_fetch_assoc($ProductPicDB);
if (isset($_GET['totalRows_ProductPicDB'])) {
$totalRows_ProductPicDB = $_GET['totalRows_ProductPicDB'];
} else {
$all_ProductPicDB = mysql_query($query_ProductPicDB);
$totalRows_ProductPicDB = mysql_num_rows($all_ProductPicDB);
}
$totalPages_ProductPicDB = ceil($totalRows_ProductPicDB/$maxRows_ProductPicDB)-1;
$queryString_ProductPicDB = "";
if (!empty($_SERVER['QUERY_STRING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_ProductPicDB") == false &&
stristr($param, "totalRows_ProductPicDB") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_ProductPicDB = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_ProductPicDB = sprintf("&totalRows_ProductPicDB=%d%s", $totalRows_ProductPicDB, $queryString_ProductPicDB);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
.style11 {color: #FFFFFF; font-weight: bold; font-family: Arial, Helvetica, sans-serif; font-size: 14px; }
-->
</style>
</head>
<body>
<table width="800" border="1" align="center" cellpadding="3" cellspacing="3">
<tr>
<td width="50" align="center" bgcolor="#006699"><span class="style11">Pic</span></td>
<td width="70" bgcolor="#006699"><span class="style11">SKU</span></td>
<td bgcolor="#006699"><span class="style11">pretty_name</span></td>
<td width="195" bgcolor="#006699"><span class="style11">manufacturer</span></td>
</tr>
<?php
$dir = "./Images/";
$filesDir = scandir($dir,1);
do { ?>
<?php
$FileName = $row_ProductPicDB['SKU'].".jpg";
if (in_array($FileName, $filesDir, true)) {} else {
?>
<tr bordercolor="#006699" bgcolor="#D5F0FC">
<td align="center"><img src="/untitled/Images/<?php echo $FileName; ?>" width="45" height="45" /></td>
<td><?php echo $row_ProductPicDB['SKU']; ?></td>
<td><?php echo $row_ProductPicDB['pretty_name']; ?></td>
<td><?php echo $row_ProductPicDB['manufacturer']; ?></td>
</tr>
<?php }} while ($row_ProductPicDB = mysql_fetch_assoc($ProductPicDB)); ?>
</table>
<br />
<br />
<table border="0" align="center">
<tr>
<td><?php if ($pageNum_ProductPicDB > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_ProductPicDB=%d%s", $currentPage, 0, $queryString_ProductPicDB); ?>"><img src="/images/First.gif" border="0" /></a>
<?php } // Show if not first page ?>
</td>
<td><?php if ($pageNum_ProductPicDB > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_ProductPicDB=%d%s", $currentPage, max(0, $pageNum_ProductPicDB - 1), $queryString_ProductPicDB); ?>"><img src="/images/Previous.gif" border="0" /></a>
<?php } // Show if not first page ?>
</td>
<td><?php if ($pageNum_ProductPicDB < $totalPages_ProductPicDB) { // Show if not last page ?>
<a href="<?php printf("%s?pageNum_ProductPicDB=%d%s", $currentPage, min($totalPages_ProductPicDB, $pageNum_ProductPicDB + 1), $queryString_ProductPicDB); ?>"><img src="/images/Next.gif" border="0" /></a>
<?php } // Show if not last page ?>
</td>
<td><?php if ($pageNum_ProductPicDB < $totalPages_ProductPicDB) { // Show if not last page ?>
<a href="<?php printf("%s?pageNum_ProductPicDB=%d%s", $currentPage, $totalPages_ProductPicDB, $queryString_ProductPicDB); ?>"><img src="/images/Last.gif" border="0" /></a>
<?php } // Show if not last page ?>
</td>
</tr>
</table>
</body>
</html>
<?php
mysql_free_result($ProductPicDB);
?>