Jump to content

Help on error-undefined index


gnawz

Recommended Posts

I have two files;

 

brandview.php  AND brandshow.php

 

brandview.php has a dynamic drop down form which a user selects to view results as per the selection in brandshow.php

 

 

The display should come with its editing properties....eg modify and delete

 

I however get the undefined index error and nothing is displayed.  Please help me.

 

My two files

 

brandview.php

<?php
require_once '../../functions.php';

$_SESSION['login_return_url'] = $_SERVER['REQUEST_URI'];
checkUser();

?> 

<body>
<form action="index.php?view=brandshow" method="post" name="frmShowBrand">
<table width="100%" border="0">
    <tr>
      <td width="100">View By brand:</td>
      <td width="200"><select name = "sltBrand" onChange="ShowBrand();">
            <option value="0">Select Brand</option>
            <?
		$sql = "SELECT DISTINCT Brand FROM cstockitems ORDER BY Brand ASC";
		$result = dbQuery($sql);		

		if(dbNumRows($result))
		{
			while($row1 = dbFetchAssoc($result))
			{
			echo "<option>$row1[brand]</option>";
			}
		}
		 		else 
				{
			echo "<option>No Brands Present</option>"; 
				}
  ?>
          </select></td>
    </tr>
  </table>
</form>
</body>
<script>
function ShowBrand()
{
window.location.href = 'index.php?view=brandshow';
}

</script>
?>

 

 

 

 

 

 

 

brandshow.php

 

<?
require_once '../../functions.php';

//error_reporting(0);
/*if (!defined('WEB_ROOT')) {
exit;
}*/

$ShowBrand = $_POST["sltBrand"];

$sql = "SELECT * FROM cstockitems WHERE Brand = '$ShowBrand'";
//$sql = "SELECT * FROM cstockitems GROUP BY Brand";
$rowsPerPage = 10;

$result     = dbQuery(getPagingQuery($sql, $rowsPerPage));
$pagingLink = getPagingLink($sql, $rowsPerPage);

?>
<form action="index.php?view=choice" method="post"  name="frmList" id="frmList">
  <table width="100%" border="0" align="center" cellpadding="2" cellspacing="1">
    <tr align="center" class="title_text"> 
      <td width="400" class="">Brand</td>
<td width="400" class="">Category</td>
      <td width="400">Date Created </td>
      <td width="200">View</td>
      <td width="200">Modify</td>
    </tr>
    <?php
if (dbNumRows($result) > 0) {
	$i = 0;

	while($row = dbFetchAssoc($result)) {
	extract($row);

	if ($i%2) {
		$class = 'row1';
	} else {
		$class = 'row2';
	}
	$i += 1;
?>
    <tr class="<?php echo $class; ?>"> 
      <td width="400"><?php echo $Brand; ?></td>
<td width="400"><?php echo $Category; ?></td>
      <td width="400"><?php echo $DateAddedBrand; ?></td>
      <td width="200" align="center"><a href="<?php echo $_SERVER['PHP_SELF']; ?>?view=detail&ProductID=<?php echo $ProductID; ?>">Details</a></td>
      <td width="200" align="center"><a href="javascript:modifyBrand(<?php echo $ProductID; ?>);">Modify</a></td>
    </tr>
    <?php
} // end while


?>
    <tr> 
      <td colspan="4" align="center"> 
        <?php 
   echo $pagingLink;
   ?>
      </td>
    </tr>
    <?php	
} else {
?>
    <tr> 
      <td colspan="4" align="center">No brands yet</td>
    </tr>
    <tr> 
      <td colspan="4" align="center"> </td>
    </tr>
    <?php
}
?>
    <tr> 
      <td colspan="4" align="right"> 
        <input name="AddBrand" type="submit" value="Add" class="button_image"> 
	<input type="submit" name="DeleteBrand" value="Delete" class="button_image">
    </tr>
  </table>
</form>

 

Link to comment
Share on other sites

$_POST will show nothing because you are not actually "posting" the data.

 

Change your javascript from this:

window.location.href = 'index.php?view=brandshow';

 

To this:

document.getElementById('frmShowBrand').submit();

 

Then give your form tag an id attribute and set it to frmShowBrand.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.