Page 1 of 1

adding a category

Posted: Sat Jul 21, 2007 11:58 am
by carsky
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


hi guys..need some help from you all..im creating an add category feature of our system..i have a problem because the i am encountering this error

Fatal error: Call to undefined function: getpagingquery() in D:\Server\xampp\htdocs\ieccTESTproj\admin\category\list.php on line 22

here's the list.php this displays all the category if there is, if not a prompt will show on the page that there is no category available.

Code: Select all

<?php
if (!defined('WEB_ROOT')) {
	exit;
}

if (isset($_GET['Categoryno']) && (int)$_GET['catId'] >= 0) {
	$catId = (int)$_GET['catId'];
	$queryString = "&catId=$catId";
} else {
	$catId = 0;
	$queryString = '';
}
	
// for paging
// how many rows to show per page
$rowsPerPage = 5;

$sql = "SELECT Categoryno, Cat_Parent_ID, Cat_Name, Cat_Description, Cat_Image
        FROM tblcategory
		WHERE Cat_Parent_ID = $catId
		ORDER BY Cat_Name";

//THIS WHERE THE ERROR IS..
$result     = dbQuery(getPagingQuery($sql, $rowsPerPage));
$pagingLink = getPagingLink($sql, $rowsPerPage);
?>
<p>&nbsp;</p>
<form action="processCategory.php?action=addCategory" method="post"  name="frmListCategory" id="frmListCategory">
 <table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" class="text">
  <tr align="center" id="listTableHeader"> 
   <td>Category Name</td>
   <td>Description</td>
   <td width="75">Image</td>
   <td width="75">Modify</td>
   <td width="75">Delete</td>
  </tr>
  <?php
$Cat_Parent_ID = 0;
if (dbNumRows($result) > 0) {
	$i = 0;
	
	while($row = dbFetchAssoc($result)) {
		extract($row);
		
		if ($i%2) {
			$class = 'row1';
		} else {
			$class = 'row2';
		}
		
		$i += 1;
		
		if ($Cat_Parent_ID == 0) {
			$Cat_Name = "<a href=\"index.php?catId=$Categoryno\">$Cat_Name</a>";
		}
		
		if ($Cat_Image) {
			$Cat_Image = WEB_ROOT . 'images/category/' . $Cat_Image;
		} else {
			$Cat_Image = WEB_ROOT . 'images/no-image-small.png';
		}		
?>
  <tr class="<?php echo $class; ?>"> 
   <td><?php echo $Cat_Name; ?></td>
   <td><?php echo nl2br($Cat_Description); ?></td>
   <td width="75" align="center"><img src="<?php echo $Cat_Image; ?>"></td>
   <td width="75" align="center"><a href="javascript:modifyCategory(<?php echo $Cat_ID; ?>);">Modify</a></td>
   <td width="75" align="center"><a href="javascript:deleteCategory(<?php echo $Cat_ID; ?>);">Delete</a></td>
  </tr>
  <?php
	} // end while


?>
  <tr> 
   <td colspan="5" align="center">
   <?php 
   echo $pagingLink;
   ?></td>
  </tr>
<?php	
} else {
?>
  <tr> 
   <td colspan="5" align="center">No Categories Yet</td>
  </tr>
  <?php
}
?>
  <tr> 
   <td colspan="5">&nbsp;</td>
  </tr>
  <tr> 
   <td colspan="5" align="right"> <input name="btnAddCategory" type="button" id="btnAddCategory" value="Add Category" class="box" onClick="addCategory(<?php echo $catId; ?>)"> 
   </td>
  </tr>
 </table>
 <p>&nbsp;</p>
</form>
guys maybe you could help me out..thanks a lot in advance


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Sat Jul 21, 2007 12:06 pm
by superdezign
Firstly, your error says getpagingquery() and your code says getPagingQuery(). Which is it?

Secondly, where is this function defined? I don't see any files being included.

Posted: Sat Jul 21, 2007 12:29 pm
by carsky
well i tried changing it already but still i get the same error..then there's no more function that needs to be called because as you can see on the code.

Code: Select all

$rowsPerPage = 5;

$sql = "SELECT Categoryno, Cat_Parent_ID, Cat_Name, Cat_Description, Cat_Image
        FROM tblcategory
		WHERE Cat_Parent_ID = $catId
		ORDER BY Cat_Name";
$result     = dbQuery(getpagingquery([u]$sql, $rowsPerPage[/u]));
$sql and $rowsPerPage are already defined. do you think i missed out something?

Posted: Sat Jul 21, 2007 12:57 pm
by superdezign
carsky wrote:$sql and $rowsPerPage are already defined. do you think i missed out something?
Yes. Again, where do you define the getpagingquery() function?

Posted: Sat Jul 21, 2007 8:11 pm
by carsky
i called the $sql and $rowsPerPage..evertime you view the category list this getpagingquery() executes both..the $sql which check if there is a category available on the database..and the $rowsPerPage sees to it that if the there is more than 5 rows of category it would create another pagingLink..i guess there is no need to further define getPagingQuery() because if have set it with the value of $result.

Code: Select all

<?php
$Cat_Parent_ID = 0;
if (dbNumRows($result) > 0) {
        $i = 0;
       
        while($row = dbFetchAssoc($result)) {
                extract($row);
               
                if ($i%2) {
                        $class = 'row1';
                } else {
                        $class = 'row2';
                }
               
                $i += 1;
               
                if ($Cat_Parent_ID == 0) {
                        $Cat_Name = "<a href=\"index.php?catId=$Categoryno\">$Cat_Name</a>";
                }
               
                if ($Cat_Image) {
                        $Cat_Image = WEB_ROOT . 'images/category/' . $Cat_Image;
                } else {
                        $Cat_Image = WEB_ROOT . 'images/no-image-small.png';
                }              
?>
  <tr class="<?php echo $class; ?>">
   <td><?php echo $Cat_Name; ?></td>
   <td><?php echo nl2br($Cat_Description); ?></td>
   <td width="75" align="center"><img src="<?php echo $Cat_Image; ?>"></td>
   <td width="75" align="center"><a href="javascript:modifyCategory(<?php echo $Cat_ID; ?>);">Modify</a></td>
   <td width="75" align="center"><a href="javascript:deleteCategory(<?php echo $Cat_ID; ?>);">Delete</a></td>
  </tr>
  <?php
        } // end while


?>
  <tr>
   <td colspan="5" align="center">
   <?php
   echo $pagingLink;
   ?></td>
  </tr>
<?php   
} else {
?>
  <tr>
   <td colspan="5" align="center">No Categories Yet</td>
  </tr>
  <?php
}
?>