PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Mon Nov 24, 2014 4:16 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Help Me
PostPosted: Sat Apr 23, 2011 2:04 pm 
Offline
Forum Newbie

Joined: Sat Apr 23, 2011 1:56 pm
Posts: 2
Hello! I Have Web-Site and the Web-Site has products page. First time This Page working very well I need to change something in this code but when i change this product page does not show anything it show just index.php codes. I can't correct this :banghead: .
Syntax: [ Download ] [ Hide ]
 <?PHP include_once('sitemap.php'); ?>

<DIV class="page_container">

<?PHP include_once('productcategory.php'); ?>

<div style="float:left;">
<table border="0">
<?PHP

$page = $_GET['pagenum'];


if($_GET['category'])
{
$add_Q=" WHERE cat_id="'" . $_GET['category'] . "' ";
}
else
{
$add_Q="
";
}


$records_per_page = 7;
if(!filter_var($page, FILTER_VALIDATE_INT, 1))
$page=1;

$offset = ($page-1) * $records_per_page;

$result = mysql_query("
SELECT * FROM products $add_Q ORDER BY prod_id DESC LIMIT $offset, $records_per_page");

if($row = mysql_fetch_array($result)){
  do{

$id=$row['prod_id'];
$name=$row['prod_name'];
$pn=$row['prod_pn'];
$price=$row['prod_price'];
$description=$row['prod_qdescription'];
$image1="
product_images/" . $id . "/" . $row['image1'];

echo "
<tr>
    <td rowspan='2'><center><a href='index.php?lan=$lan&page=detail&id=$id'><img src='$image1' width='120' height='120'/></a><br><b>$pn</b></center></td>
    <td><a href='index.php?lan=$lan&page=detail&id=$id' class='product_name'>$name</a><br><br><b style='font-size:12px;'>" . $lang['PRODUCT_PRICE'] . ": $price GEL</b></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>";


} while($row = mysql_fetch_array($result));
}


echo "
</table>";


function build_url($filename, $key, $value){
  $values = array();
  $query_str = array();

parse_str($_SERVER['QUERY_STRING'], $values);

foreach($values as $k=>$v){
    if($k!=$key){
      $query_str[] = "
{$k}={$v}";
    }
  }
  $query_str[] = "
{$key}={$value}";

  return "
$filename&".implode("&", $query_str);
}

$count_result = mysql_query("
SELECT COUNT(*) FROM products $add_Q");
$count_row = mysql_fetch_array($count_result);
$count = $count_row["
COUNT(*)"];


echo "
<div style='float:left; width:100%; text-align:center; margin-top:25px; margin-bottom:30px;'>";

echo (($page>1)?"
<a href='".build_url("index.php?lan=$lan&page=products", "pagenum", $page-1)."'>" . $lang['PRODUCT_BACK'] . "</a>":"" . $lang['PRODUCT_BACK'] . "")." | ";

for($i=1; $i<=($count/$records_per_page)+1; $i++){
  if($i!=$page)
    echo "
<a style='text-decoration:underline;' href='".build_url("index.php?lan=$lan&page=products", "pagenum", $i)."'>$i</a> ";
  else
    echo $i;
  if($i<$count/$records_per_page)
    echo "
| ";
}

echo ' | ' . (($page<$count/$records_per_page)?"
<a href='".build_url("index.php?lan=$lan&page=products", "pagenum", $page+1)."'>" . $lang['PRODUCT_NEXT'] . "</a>":"" . $lang['PRODUCT_NEXT'] . "");


echo "
</div></div>";
?>



</DIV>

<?PHP //include_once('leftbanners.php'); ?>

<?PHP include_once('sitemap.php'); ?>

<DIV class="page_container">

<?PHP include_once('productcategory.php'); ?>

<div style="float:left;">
<table border="0">
<?PHP

$page = $_GET['pagenum'];


if($_GET['category'])
{
$add_Q=" WHERE cat_id='" . $_GET['category'] . "' ";
}
else
{
$add_Q=" ";
}


$records_per_page = 7;
if(!filter_var($page, FILTER_VALIDATE_INT, 1))
$page=1;

$offset = ($page-1) * $records_per_page;

$result = mysql_query("SELECT * FROM products $add_Q ORDER BY prod_id DESC LIMIT $offset, $records_per_page");

if($row = mysql_fetch_array($result)){
  do{

$id=$row['prod_id'];
$name=$row['prod_name'];
$pn=$row['prod_pn'];
$price=$row['prod_price'];
$description=$row['prod_qdescription'];
$image1="product_images/" . $id . "/" . $row['image1'];

echo "<tr>
    <td rowspan='2'><center><a href='index.php?lan=$lan&page=detail&id=$id'><img src='$image1' width='120' height='120'/></a><br><b>$pn</b></center></td>
    <td><a href='index.php?lan=$lan&page=detail&id=$id' class='product_name'>$name</a><br><br><b style='font-size:12px;'>"
. $lang['PRODUCT_PRICE'] . ": $price GEL</b></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>"
;


} while($row = mysql_fetch_array($result));
}


echo "</table>";


function build_url($filename, $key, $value){
  $values = array();
  $query_str = array();

parse_str($_SERVER['QUERY_STRING'], $values);

foreach($values as $k=>$v){
    if($k!=$key){
      $query_str[] = "{$k}={$v}";
    }
  }
  $query_str[] = "{$key}={$value}";

  return "$filename&".implode("&", $query_str);
}

$count_result = mysql_query("SELECT COUNT(*) FROM products $add_Q");
$count_row = mysql_fetch_array($count_result);
$count = $count_row["COUNT(*)"];


echo "<div style='float:left; width:100%; text-align:center; margin-top:25px; margin-bottom:30px;'>";

echo (($page>1)?"<a href='".build_url("index.php?lan=$lan&page=products", "pagenum", $page-1)."'>A« " . $lang['PRODUCT_BACK'] . "</a>":"A« " . $lang['PRODUCT_BACK'] . "")." | ";

for($i=1; $i<=($count/$records_per_page)+1; $i++){
  if($i!=$page)
    echo "<a style='text-decoration:underline;' href='".build_url("index.php?lan=$lan&page=products", "pagenum", $i)."'>$i</a> ";
  else
    echo $i;
  if($i<$count/$records_per_page)
    echo " | ";
}

echo ' | ' . (($page<$count/$records_per_page)?"<a href='".build_url("index.php?lan=$lan&page=products", "pagenum", $page+1)."'>" . $lang['PRODUCT_NEXT'] . " A»</a>":"" . $lang['PRODUCT_NEXT'] . " A»");


echo "</div></div>";
?>


</DIV>

<?PHP //include_once('leftbanners.php'); ?>


Top
 Profile  
 
 Post subject: Re: Help Me
PostPosted: Sat Apr 23, 2011 4:47 pm 
Offline
Forum Commoner
User avatar

Joined: Sun Sep 06, 2009 12:28 pm
Posts: 71
does your code enter if() statement?


Top
 Profile  
 
 Post subject: Re: Help Me
PostPosted: Sun Apr 24, 2011 3:03 am 
Offline
Forum Newbie

Joined: Sat Apr 23, 2011 1:56 pm
Posts: 2
Yes there is many if() you can see in code. :roll:


Top
 Profile  
 
 Post subject: Re: Help Me
PostPosted: Sun Apr 24, 2011 5:14 pm 
Offline
Forum Commoner
User avatar

Joined: Sun Sep 06, 2009 12:28 pm
Posts: 71
Megobrebi wrote:
Yes there is many if() you can see in code. :roll:


mmm...

what i mean is, does your code meet this condition
Syntax: [ Download ] [ Hide ]
if($row = mysql_fetch_array($result)){


is there any data in $result variable?


Top
 Profile  
 
 Post subject: Re: Help Me
PostPosted: Sun Apr 24, 2011 6:53 pm 
Offline
DevNet Master
User avatar

Joined: Sun Jan 21, 2007 12:06 am
Posts: 4135
Just a tip:

If you want more responses, you need to pinpoint where your error resides instead of stating that a script doesn't work and giving us the entire thing. Tell us what it should be doing versus what it is doing. "Not showing anything" is far too vague. The only advice I can give you is to enable display_errors and set error_reporting to E_ALL.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group