Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jun 2012
    Posts
    12
    Thanks
    2
    Thanked 0 Times in 0 Posts

    retrieve information into table.

    I want to list out everything from database to a proper table. However , there are only header but no details/information come out. Could anyone please help me
    Code:
    <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=$cat_id\">$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>

  • #2
    Senior Coder
    Join Date
    Jun 2008
    Location
    New Jersey
    Posts
    2,535
    Thanks
    45
    Thanked 259 Times in 256 Posts
    You need to show the relevant portions of your code, like the query itself, and tell us what framework/system you're using, as the database functions there are non-standard. We cant debug your code if we don't know what its doing.

    Have you tried feeding your query through a command line like phpMyAdmin?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •