How to solve the undefined index error? i have tried to make hidden field but not working also..

 <?php 

          if($nume==0)
          {  echo "You currently have no item to show"; }
          else if(isset($_GET['msg']))
          {
            $msg = $_GET['msg'];
            if($msg!='')
            { 
            echo '<table border="1">
                <tr>
                <td><font color="red">'.$msg.'</font></td>
                </tr>
                </table>';
            }
        } 
            ?></font></strong></p>

            <table width="680px" cellspacing="0" cellpadding="5">
                        <tr bgcolor="#ddd">
                            <th width="220" align="left">Date </th> 
                            <th width="200" align="left">Outlet </th> 
                            <th width="130" align="left">Status</th> 
                            <th width="70"> </th>
                        </tr>
        <?php

        $start=(isset($_GET['start'])) ? (int)$_GET['start']:0;

            if(strlen($start) > 0 and !is_numeric($start))
            {
                echo "Data Error";
                exit;
            }

            $eu = ($start - 0); 
            $limit = 5;                           
            $this1 = $eu + $limit; 
            $back = $eu - $limit; 
            $next = $eu + $limit; 

            $result = mysql_query("SELECT DISTINCT orderdb.view,orderdb.odate,pstaff.outlet FROM orderdb,pstaff WHERE pstaff.outlet='SAP' AND orderdb.odate='2013-03-26' ORDER BY orderdb.odate  limit $eu, $limit");



            while($row = mysql_fetch_array($result))
            {
                echo"<input type='hidden' name='odate' value='". $row['odate'] ."' />";
                echo"<input type='hidden' name='outlet' value='". $row['outlet'] ."' />";
                echo "<td>" .$row['odate']. "</td>";
                echo "<td>" .$row['outlet']. "</td>";

                if($row['view']=='no'){
                    echo "<td>Not View Yet</td>";
                    echo "<td align='center'> <a href='astockoutlet.php?outlet=".$row['odate']."'>View</a> </td>";

                    }

                echo "</tr>";
            }



        mysql_close($con);
                        ?>
             </table>

*Notice: Undefined index: odate in /home/lh026/public_html/pro1/astockoutlet.php on line 5

Notice: Undefined index: outlet in /home/lh026/public_html/pro1/astockoutlet.php on line 6*

Recommended Answers

All 19 Replies

Member Avatar for LastMitch

How to solve the undefined index error?

Is this the correct file? You post the error for line 5 and line 6 and I don't see those words?

You didn't define these 2 variables in your code:

$row['odate'] 
$row['outlet']

So that's why it's undefined.

Add this before the query:

$odate=isset($row['odate']); 
$outlet=isset($row['outlet']);

For your query it should look like this:

while($row = mysql_fetch_array($result))
{
echo"<input type='hidden' name='odate' value='". $odate ."' />";
echo"<input type='hidden' name='outlet' value='". $outlet ."' />";
echo "<td>". $odate ."</td>";
echo "<td>". $outlet ."</td>";

if($row['view']=='no'){
echo "<td>Not View Yet</td>";
echo "<td align='center'> <a href='astockoutlet.php?outlet=". $odate ."'>View</a> </td>";
}
echo "</tr>";
}

They should exist in the array as the way you are calling them, but I am wondering if it just that your query is failing for some reason which would mean the variables wouldn't exist and then you would get that error you are seeing.

I would put this on the end of your query, so the code would not continue to execute if the query failed, and then you would see an error message. It is a good practice to have it on there anyways.

$result = mysql_query("SELECT DISTINCT orderdb.view,orderdb.odate,pstaff.outlet FROM orderdb,pstaff WHERE pstaff.outlet='SAP' AND orderdb.odate='2013-03-26' ORDER BY orderdb.odate  limit $eu, $limit")or die(mysql_error());

If that doesn't show a possible problem, then I would put this in my while loop to see what the arrays look like.

echo "<pre>";
echo print_r($row);
echo "</pre>";

this is the full code for atockview.php where the unseen data is shown.

<?php
include_once 'admin-class.php';
$admin = new itg_admin();
$admin->_authenticate();
$orderdate=isset($row['odate']); 
$outlet=isset($row['outlet']);
$con=mysql_connect("#","#","#");
mysql_select_db("#", $con);

$id=$_SESSION['admin_login'];
$result2 = mysql_query("SELECT odate,itemcode, quantity, saiz, remark FROM orderdb WHERE staff_id='$id' ORDER BY odate DESC");
$nume=mysql_num_rows($result2);

?>
<!DOCTYPE html>
<html lang="en">
<head>
    <title></title>
    <meta charset="utf-8">
    <link rel="stylesheet" href="css/reset.css" type="text/css" media="all">
    <link rel="stylesheet" href="css/grid.css" type="text/css" media="all">
    <link rel="stylesheet" href="css/style.css" type="text/css" media="all">
    <!--[if lt IE 9]>
        <script type="text/javascript" src="js/html5.js"></script>
    <![endif]-->
</head>

<body>
    <header>
        <nav>
            <div class="container">
                <div class="wrapper">
                    <h1><a href="index.html"><strong>Industrial</strong>Services</a></h1>
                    <ul>
                        <li><a href="astock.php">View Order</a></li>
                        <li><a href="astockview.php">View Pending</a></li>
                        <li><a href="index-2.html" class="current">industries</a></li>
                        <li><a href="index-3.html">contacts</a></li>
                    </ul>
                </div>
            </div> 
            <li style="color:#CCC" style="font-size:medium"><?php
if(isset($_SESSION['admin_login'])){
    echo( 'Welcome    '.$admin->get_name().' >>>'.'<a href="logout.php">Logout</a>');}
?> </li>
        </nav>
        <section class="adv-content">
            <div class="container">
                <ul class="breadcrumbs">
                    <li>Industries</li>
                </ul>
                <form action="" id="search-form">
                    <fieldset>
                        <input type="text" value=""><input type="submit" value="">
                    </fieldset>
                </form>
            </div>
        </section><div class="ic">More Website Templates at TemplateMonster.com!</div>
    </header>
    <section id="content">
        <div class="top">
            <div class="container">
                <div class="clearfix">
                  <div class="grid9 first">
                        <h2>Stock Order</h2>
                        <h3><div id="content2" class="float_r">
                          <h1>&nbsp;</h1>
                          <div id="content" class="float_r">


          <p><strong><font color="red">
          <?php 

          if($nume==0)
          {  echo "You currently have no item to show"; }
          else if(isset($_GET['msg']))
          {
            $msg = $_GET['msg'];
            if($msg!='')
            { 
            echo '<table border="1">
                <tr>
                <td><font color="red">'.$msg.'</font></td>
                </tr>
                </table>';
            }
        } 
            ?></font></strong></p>

            <table width="680px" cellspacing="0" cellpadding="5">
                        <tr bgcolor="#ddd">
                            <th width="220" align="left">Date </th> 
                            <th width="200" align="left">Outlet </th> 
                            <th width="130" align="left">Status</th> 
                            <th width="70"> </th>
                        </tr>
        <?php

        $start=(isset($_GET['start'])) ? (int)$_GET['start']:0;

            if(strlen($start) > 0 and !is_numeric($start))
            {
                echo "Data Error";
                exit;
            }

            $eu = ($start - 0); 
            $limit = 5;                           
            $this1 = $eu + $limit; 
            $back = $eu - $limit; 
            $next = $eu + $limit; 

            $result = mysql_query("SELECT DISTINCT orderdb.view,orderdb.odate,pstaff.outlet FROM orderdb,pstaff WHERE pstaff.outlet='SAP' AND orderdb.odate='2013-03-26' ORDER BY orderdb.odate  limit $eu, $limit") or die(mysql_error());


            $odate=isset($row['odate']); 
$outlet=isset($row['outlet']);


            while($row = mysql_fetch_array($result))
            {

                echo "<td>" .$odate. "</td>";
                echo "<td>" .$outlet. "</td>";
                echo "<pre>";
echo print_r($row);
echo "</pre>";
                if($row['view']=='no'){
                    echo "<td>Not View Yet</td>";
                    echo "<td align='center'> <a href='astockview2.php?outlet=".$row['odate'].$row['outlet']."'>View</a> </td>";

                    }

                echo "</tr>";
            }



        mysql_close($con);
                        ?>
             </table>

        </div>

                    </div></h3>
                        <p>&nbsp;</p>
                        <p>&nbsp;</p>
                        <p>&nbsp;</p>
                  </div>
                    <div class="block-news">
                      <h3 class="color-4 p2">Products List</h3>
                      <ul class="list-2">
                        <li><a href="#">Suspendisse urna</a></li>
                        <li><a href="#">Vehicula fermentum</a></li>
                        <li><a href="#">Etiam turpis arcu</a></li>
                        <li><a href="#">Consectetur vel</a></li>
                        <li><a href="#">Duis id turpis turpis</a></li>
                        <li><a href="#">Nulla a magna</a></li>
                        <li><a href="#">Tempor molestie</a></li>
                        <li><a href="#">Suspendisse urna</a></li>
                        <li><a href="#">Vehicula fermentum</a></li>
                        <li><a href="#">Etiam turpis arcu</a></li>
                        <li><a href="#">Consectetur vel</a></li>
                        <li><a href="#">Duis id turpis turpis</a></li>
                        <li><a href="#">Nulla a magna</a></li>
                        <li><a href="#">Tempor molestie</a></li>
                        <li><a href="#">Suspendisse urna</a></li>
                      </ul>
                  </div>
                </div>
            </div>
        </div>

        <div class="bottom">
            <div class="container">
                <div class="clearfix">
                    <div class="grid3 first">
                        <h3>Special Offers</h3>
                        <ul class="list1">
                            <li><a href="#">Lorem ipsum dolor sitemet amet</a></li>
                            <li><a href="#">Consectetuer adipiscing elitum</a></li>
                            <li><a href="#">Praesent vestibulum molestie sed</a></li>
                            <li><a href="#">Perspiciatis unde omnis iste natus</a></li>
                            <li><a href="#">Error sit voluptatem accusantium</a></li>
                            <li><a href="#">Doloremque laudantium totam rem</a></li>
                            <li><a href="#">Aperiam eaque ipsa quae ab illo</a></li>
                        </ul>
                    </div>
                    <div class="grid6">
                        <h3>Special Proposition</h3>
                        <p>Praesent vestibulum mol lacus aenean nonummy hendrerit maurisen phasellus porta fusce suscipit varius micum sociis <a href="#" class="alt">natoque penatibus et magnis</a> diparturient nascetur ridiculus musnulla dui fusce feugiat malesuada odio morbi.</p>
                        Nunc odio gravida lorem ipsum dolor sit amet, consectetuer adipiscing elitu. Praesent vestibulum molestie lacus. Aenean nonummy hendrerit mauris phasellus porta. Fusce suscipit varius mium <a href="#" class="alt">sociis natoque penatibus</a> magnis dis parturient montes nascetur ridiculus mus. Nulla dui. Fusce feugiat malesuada odio. 
                    </div>
                    <div class="grid3">
                        <h3>Online Support</h3>
                        <ul class="list2">
                            <li><a href="#">Lorem ipsum dolor consectetuer</a></li>
                            <li><a href="#">Adipiscing elit praesent vestibulum</a></li>
                            <li><a href="#">Molestie laenonummy hendrerit</a></li> 
                            <li><a href="#">Mauris phasellus pfusce suscipit</a></li>
                            <li><a href="#">Varius mium natoque penatibus</a></li> 
                            <li><a href="#">Magnis diparturient monacetur</a></li> 
                            <li><a href="#">Ridiculus mus nulla dui fuscem</a></li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </section>
    <footer>
        <div class="container">
            <div class="wrapper">
                <div class="copy">Industrial Services (c) 2010   |   <a href="index-4.html">Privacy policy</a></div>
                <address class="phone">
                    We're glad to help you. Please email or call us. <strong>1-123-456-7890</strong>
                </address>
            </div>
        </div>
    </footer>
</body>
</html>

Here is the code astockview2.php. when user click 'View' ,more data will be dsiplay here

<?php
include_once 'admin-class.php';
$admin = new itg_admin();
$admin->_authenticate();
$orderdate=isset($row['odate']); 
$outlet=isset($row['outlet']);

$con=mysql_connect("#","#","#");
mysql_select_db("#", $con);
$id=$_SESSION['admin_login'];
$result2 = mysql_query("SELECT orderdb.odate,orderdb.itemcode,orderdb.quantity,orderdb.saiz,orderdb.remark,  
 pstaff.outlet  
FROM orderdb ,pstaff  
WHERE  orderdb.staff_id =pstaff.staff_id
AND pstaff.outlet='$outlet'
AND orderdb.odate='$orderdate' ORDER BY odate DESC");
$nume=mysql_num_rows($result2);

?>
<!DOCTYPE html>
<html lang="en">
<head>
    <title></title>
    <meta charset="utf-8">
    <link rel="stylesheet" href="css/reset.css" type="text/css" media="all">
    <link rel="stylesheet" href="css/grid.css" type="text/css" media="all">
    <link rel="stylesheet" href="css/style.css" type="text/css" media="all">
    <!--[if lt IE 9]>
        <script type="text/javascript" src="js/html5.js"></script>
    <![endif]-->
</head>

<body>
    <header>
        <nav>
            <div class="container">
                <div class="wrapper">
                    <h1><a href="index.html"><strong>Industrial</strong>Services</a></h1>
                    <ul>
                        <li><a href="astock.php">View Order</a></li>
                        <li><a href="astockview.php">View Pending</a></li>
                        <li><a href="index-2.html" class="current">industries</a></li>
                        <li><a href="index-3.html">contacts</a></li>
                    </ul>
                </div>
            </div> 
            <li style="color:#CCC" style="font-size:medium"><?php
if(isset($_SESSION['admin_login'])){
    echo( 'Welcome    '.$admin->get_name().' >>>'.'<a href="logout.php">Logout</a>');}
?> </li>
        </nav>
        <section class="adv-content">
            <div class="container">
                <ul class="breadcrumbs">
                    <li>Industries</li>
                </ul>
                <form action="" id="search-form">
                    <fieldset>
                        <input type="text" value=""><input type="submit" value="">
                    </fieldset>
                </form>
            </div>
        </section><div class="ic">###</div>
    </header>
    <section id="content">
        <div class="top">
            <div class="container">
                <div class="clearfix">
                  <div class="grid9 first">
                        <h2>Stock Order</h2>
                        <h3><div id="content2" class="float_r">
                          <h1>&nbsp;</h1>

                          <p><strong><font color="red">
                            <?php 

          if($nume==0)
          {  echo "You currently have no item to show"; }
          else if(isset($_GET['msg']))
          {
            $msg = $_GET['msg'];
            if($msg!='')
            { 

             '<table border="1">
                <tr>
                <td><font color="red">'.$msg.'</font></td>
                </tr>
                </table>';
            }
        } 
            ?>
                            </font></strong></p>
                          <table width="713" cellspacing="0" cellpadding="5">
                            <tr bgcolor="#ddd">
                              <th width="107" align="left">Date </th>
                              <th width="98" align="left">Item Code </th>
                              <th width="89" align="left">Quantity</th>
                              <th width="59" align="left">Size </th>
                              <th width="263" align="left">Remark</th>
                              <th width="18" align="left">Outlet</th>
                              <th width="7"> </th>
                            </tr>

                            <?php

        $start=(isset($_GET['start'])) ? (int)$_GET['start']:0;

            if(strlen($start) > 0 and !is_numeric($start))
            {
                echo "Data Error";
                exit;
            }

            $eu = ($start - 0); 
            $limit = 5;                           
            $this1 = $eu + $limit; 
            $back = $eu - $limit; 
            $next = $eu + $limit; 
            $date =  date("Y-m-d",time() + (8 * 3600)); 

            $result = mysql_query("SELECT orderdb.odate,orderdb.itemcode,orderdb.quantity,orderdb.saiz,orderdb.remark,  
 pstaff.outlet  
FROM orderdb ,pstaff  
WHERE  
pstaff.outlet='$outlet'
AND orderdb.odate='$orderdate' 
ORDER BY odate DESC
") or die(mysql_error());

            while($row = mysql_fetch_array($result))
            {
                echo "<tr>";

                echo "<td>".$row['odate']."</td>";

                echo "<td>".$row['itemcode']."</td>";

                echo "<td>".($row['quantity'])."</td>";

                echo "<td>".($row['saiz'])."</td>";

                echo "<td>".($row['remark'])."</td>"; 

                echo "<td>".($row['outlet'])."</td>";

                echo "</tr>";
            }


        mysql_close($con);
                        ?>
                          </table>
                    </div></h3>

                    <input type="submit" name="submit" value="Generate Delivery Order" />
                        <p>&nbsp;</p>
                        <p>&nbsp;</p>
                        <p>&nbsp;</p>
                        <p>&nbsp;</p>

                  </div>
                    <div class="block-news">


                      <h3 class="color-4 p2">Products List</h3>
                      <ul class="list-2">
                        <li><a href="#">Suspendisse urna</a></li>
                        <li><a href="#">Vehicula fermentum</a></li>
                        <li><a href="#">Etiam turpis arcu</a></li>
                        <li><a href="#">Consectetur vel</a></li>
                        <li><a href="#">Duis id turpis turpis</a></li>
                        <li><a href="#">Nulla a magna</a></li>
                        <li><a href="#">Tempor molestie</a></li>
                        <li><a href="#">Suspendisse urna</a></li>
                        <li><a href="#">Vehicula fermentum</a></li>
                        <li><a href="#">Etiam turpis arcu</a></li>
                        <li><a href="#">Consectetur vel</a></li>
                        <li><a href="#">Duis id turpis turpis</a></li>
                        <li><a href="#">Nulla a magna</a></li>
                        <li><a href="#">Tempor molestie</a></li>
                        <li><a href="#">Suspendisse urna</a></li>
                      </ul>
                  </div>
                </div>
            </div>
        </div>

        <div class="bottom">
            <div class="container">
                <div class="clearfix">
                    <div class="grid3 first">
                        <h3>Special Offers</h3>
                        <ul class="list1">
                            <li><a href="#">Lorem ipsum dolor sitemet amet</a></li>
                            <li><a href="#">Consectetuer adipiscing elitum</a></li>
                            <li><a href="#">Praesent vestibulum molestie sed</a></li>
                            <li><a href="#">Perspiciatis unde omnis iste natus</a></li>
                            <li><a href="#">Error sit voluptatem accusantium</a></li>
                            <li><a href="#">Doloremque laudantium totam rem</a></li>
                            <li><a href="#">Aperiam eaque ipsa quae ab illo</a></li>
                        </ul>
                    </div>
                    <div class="grid6">
                        <h3>Special Proposition</h3>
                        <p>Praesent vestibulum mol lacus aenean nonummy hendrerit maurisen phasellus porta fusce suscipit varius micum sociis <a href="#" class="alt">natoque penatibus et magnis</a> diparturient nascetur ridiculus musnulla dui fusce feugiat malesuada odio morbi.</p>
                        Nunc odio gravida lorem ipsum dolor sit amet, consectetuer adipiscing elitu. Praesent vestibulum molestie lacus. Aenean nonummy hendrerit mauris phasellus porta. Fusce suscipit varius mium <a href="#" class="alt">sociis natoque penatibus</a> magnis dis parturient montes nascetur ridiculus mus. Nulla dui. Fusce feugiat malesuada odio. 
                    </div>
                    <div class="grid3">
                        <h3>Online Support</h3>
                        <ul class="list2">
                            <li><a href="#">Lorem ipsum dolor consectetuer</a></li>
                            <li><a href="#">Adipiscing elit praesent vestibulum</a></li>
                            <li><a href="#">Molestie laenonummy hendrerit</a></li> 
                            <li><a href="#">Mauris phasellus pfusce suscipit</a></li>
                            <li><a href="#">Varius mium natoque penatibus</a></li> 
                            <li><a href="#">Magnis diparturient monacetur</a></li> 
                            <li><a href="#">Ridiculus mus nulla dui fuscem</a></li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </section>
    <footer>
        <div class="container">
            <div class="wrapper">
                <div class="copy">Industrial Services (c) 2010   |   <a href="index-4.html">Privacy policy</a></div>
                <address class="phone">
                    We're glad to help you. Please email or call us. 
                    <strong>1-123-456-7890</strong>
                </address>
            </div>
        </div>
    </footer>
</body> 

Here is the screenshot of current updated code
8d1660e2032f52f3bdc128c4db82e57f8f4ade57de0a854c9901651a92a79f26

No more error but when i click the 'View' no data is display

Member Avatar for LastMitch

WOW, that's alot of reading.

The reason why no data appear because of this:

$orderdate=isset($row['odate']);
$outlet=isset($row['outlet']);

I establish this (because I didn't see the whole code so I didn't see line 5 and line 6):

$odate=isset($row['odate']);
$outlet=isset($row['outlet']);

You need adjust the changes in your query.

No more error but when i click the 'View' no data is display

echo "<td align='center'> <a href='astockview2.php?outlet=".$odate.$outlet."'>View</a> </td>";

You really need to clean up the code. It is very unorganized.

still not working..data not shown..

$result = mysql_query("SELECT DISTINCT orderdb.view,orderdb.odate,pstaff.outlet FROM orderdb,pstaff WHERE pstaff.outlet='SAP' AND orderdb.odate='2013-03-26' ORDER BY orderdb.odate  limit $eu, $limit") or die(mysql_error());


            $odate=isset($row['odate']); 
$outlet=isset($row['outlet']);


            while($row = mysql_fetch_array($result))
            {

                echo "<td>" .$row['odate']. "</td>";
                echo "<td>" .$row['outlet']. "</td>";

                if($row['view']=='no'){
                    echo "<pre>";
echo print_r($row);
echo "</pre>";
                    echo "<td>Not View Yet</td>";
                    echo "<td align='center'> <a href='astockview2.php?outlet=".$row['odate'].$row['outlet']."'>View</a> </td>";
echo"<input type='hidden' name='odate' value='". $row['odate'] ."' />";
echo"<input type='hidden' name='outlet' value='". $row['outlet'] ."' />";
                    }

                echo "</tr>";
            }

i have tried your method to replace with

echo "<td align='center'> <a href='astockview2.php?outlet=".$odate.$outlet."'>View</a> </td>";
Member Avatar for LastMitch

still not working..data not shown..

I mention your query you need to adjusted your query.

I don't understand your query:

$result = mysql_query("SELECT DISTINCT orderdb.view,orderdb.odate,pstaff.outlet FROM orderdb,pstaff WHERE pstaff.outlet='SAP' AND orderdb.odate='2013-03-26' ORDER BY orderdb.odate limit $eu, $limit") or die(mysql_error());

$odate=isset($row['odate']);
$outlet=isset($row['outlet']);

while($row = mysql_fetch_array($result))
{
echo "<td>" .$odate. "</td>";
echo "<td>" .$outlet. "</td>";

if(isset($row['view'])=='no'){
echo "<pre>";
echo print_r($row);
echo "</pre>";
echo "<td>Not View Yet</td>";
echo "<td align='center'> <a href='astockview2.php?outlet=".$odate.$outlet."'>View</a> </td>";
echo"<input type='hidden' name='odate' value='". $odate."' />";
echo"<input type='hidden' name='outlet' value='". $outlet ."' />";

}
echo "</tr>";
}

Run the code with the changes above.

If there's still no data then the issue is with your query or you misspell a word either the word has a uppercase or lowercase in your table in your database.

i have run my code in the database itself..the data is display..but not in the web.

9c6af6dedbfd14fc6e49a8f64eb1c8907feadfaf665b893a3da62b19840c5039

Member Avatar for LastMitch

i have run my code in the database itself..the data is display..but not in the web.

The way you mention it, is it on the host server or on your local host (computer)?

Post your update code.

There's nothing wrong with the code so far. The issue is whether your query works or not?

You post 2 files.

Both files has similiar querys so I don't know what else to tell you.

There's no error so it's bit hard to really pin point the issue now.

Usually it has something do with your query not selecting the data.

Host server.. first file is to display date and outlet so that second file can display details data from the date and outlet.

d4fdb0f87deb2c55ab0e36aec5d009c91ec896d0372ea11835c0055762a6b05c

Member Avatar for LastMitch

Host server.. first file is to display date and outlet so that second file can display details data from the date and outlet.

You didn't understand my question run the code not from your database but from your website.

Please post your update code.

Try breaking this down a bit and simplifying it. Put this code into a file and run it and see if any results are returned.

<?php
    include_once 'admin-class.php';
    $admin = new itg_admin();
    $admin->_authenticate();
    $orderdate=isset($row['odate']); 
    $outlet=isset($row['outlet']);
    $con=mysql_connect("#","#","#");

    mysql_select_db("#", $con);
    $id=$_SESSION['admin_login'];
    $result2 = mysql_query("SELECT odate,itemcode, quantity, saiz, remark FROM orderdb WHERE staff_id='$id' ORDER BY odate DESC");
    $nume=mysql_num_rows($result2);



    $result = mysql_query("SELECT DISTINCT orderdb.view,orderdb.odate,pstaff.outlet FROM orderdb,pstaff WHERE pstaff.outlet='SAP' AND orderdb.odate='2013-03-26' ORDER BY orderdb.odate  limit 0, 30") or die(mysql_error());

    $num_rows = mysql_num_rows($result);
    echo "Rows Returned: ".$num_rows;

    while($row = mysql_fetch_array($result))
    {
        echo "<td>" . $row['odate'] . "</td>";
        echo "<td>" . $row['outlet'] . "</td>";

        echo "<pre>";
        echo print_r($row);
        echo "</pre>";

        if($row['view']=='no'){
            echo "<td>Not View Yet</td>";
            echo "<td align='center'> <a href='astockview2.php?outlet=".$row['odate'].$row['outlet']."'>View</a> </td>";
        }
    }
    mysql_close($con);
?>

@pixelsoul..done as you said but same result

f448651097286c0cd67cc9ee8ba7c7b6

after click no data..

First file

<?php
include_once 'admin-class.php';
$admin = new itg_admin();
$admin->_authenticate();
$odate=isset($row['odate']); 
$outlet=isset($row['outlet']);
$con=mysql_connect("#","#","#");
mysql_select_db("mdb_lh026", $con);

$id=$_SESSION['admin_login'];
$result2 = mysql_query("SELECT odate,itemcode, quantity, saiz, remark FROM orderdb ORDER BY odate DESC");
$nume=mysql_num_rows($result2);

?>
 <?php 

          if($nume==0)
          {  echo "You currently have no item to show"; }
          else if(isset($_GET['msg']))
          {
            $msg = $_GET['msg'];
            if($msg!='')
            { 
            echo '<table border="1">
                <tr>
                <td><font color="red">'.$msg.'</font></td>
                </tr>
                </table>';
            }
        } 
            ?></font></strong></p>

            <table width="680px" cellspacing="0" cellpadding="5">
                        <tr bgcolor="#ddd">
                            <th width="220" align="left">Date </th> 
                            <th width="200" align="left">Outlet </th> 
                            <th width="130" align="left">Status</th> 
                            <th width="70"> </th>
                        </tr>
        <?php

        $start=(isset($_GET['start'])) ? (int)$_GET['start']:0;

            if(strlen($start) > 0 and !is_numeric($start))
            {
                echo "Data Error";
                exit;
            }

            $eu = ($start - 0); 
            $limit = 5;                           
            $this1 = $eu + $limit; 
            $back = $eu - $limit; 
            $next = $eu + $limit; 

            $result = mysql_query("SELECT DISTINCT orderdb.view,orderdb.odate,pstaff.outlet FROM orderdb,pstaff WHERE pstaff.outlet='SAP' AND orderdb.odate='2013-03-26' ORDER BY orderdb.odate ") or die(mysql_error());

            while($row = mysql_fetch_array($result))
            {

                echo "<td>" .$row['odate']. "</td>";
                echo "<td>" .$row['outlet']. "</td>";

                if($row['view']=='no'){
                    echo "<pre>";
echo print_r($row);
echo "</pre>";
                    echo "<td>Not View Yet</td>";
                    echo "<td align='center'> <a href='astockview2.php?outlet=".$row['odate'].$row['outlet']."'>View</a> </td>";
echo"<input type='hidden' name='odate' value='". $row['odate'] ."' />";
echo"<input type='hidden' name='outlet' value='". $row['outlet'] ."' />";
                    }

                echo "</tr>";
            }



        mysql_close($con);
                        ?>
                        </table>

Second file

<?php
include_once 'admin-class.php';
$admin = new itg_admin();
$admin->_authenticate();
$odate=isset($row['odate']); 
$outlet=isset($row['outlet']);
$con=mysql_connect("#","#","#");
mysql_select_db("mdb_lh026", $con);
$id=$_SESSION['admin_login'];
$result2 = mysql_query("SELECT orderdb.odate,orderdb.itemcode,orderdb.quantity,orderdb.saiz,orderdb.remark,  
 pstaff.outlet  
FROM orderdb ,pstaff  
WHERE  orderdb.staff_id =pstaff.staff_id
AND pstaff.outlet='$outlet'
AND orderdb.odate='$odate' ORDER BY odate DESC");
$nume=mysql_num_rows($result2);

?>
<?php 

          if($nume==0)
          {  echo "You currently have no item to show"; }
          else if(isset($_GET['msg']))
          {
            $msg = $_GET['msg'];
            if($msg!='')
            { 

             '<table border="1">
                <tr>
                <td><font color="red">'.$msg.'</font></td>
                </tr>
                </table>';
            }
        } 
            ?>
                            </font></strong></p>
                          <table width="713" cellspacing="0" cellpadding="5">
                            <tr bgcolor="#ddd">
                              <th width="107" align="left">Date </th>
                              <th width="98" align="left">Item Code </th>
                              <th width="89" align="left">Quantity</th>
                              <th width="59" align="left">Size </th>
                              <th width="263" align="left">Remark</th>
                              <th width="18" align="left">Outlet</th>
                              <th width="7"> </th>
                            </tr>

                            <?php

        $start=(isset($_GET['start'])) ? (int)$_GET['start']:0;

            if(strlen($start) > 0 and !is_numeric($start))
            {
                echo "Data Error";
                exit;
            }

            $eu = ($start - 0); 
            $limit = 5;                           
            $this1 = $eu + $limit; 
            $back = $eu - $limit; 
            $next = $eu + $limit; 
            $date =  date("Y-m-d",time() + (8 * 3600)); 

            $result = mysql_query("SELECT orderdb.odate,orderdb.itemcode,orderdb.quantity,orderdb.saiz,orderdb.remark,  
 pstaff.outlet  
FROM orderdb ,pstaff  
WHERE  
pstaff.outlet='$outlet'
AND orderdb.odate='$odate' 
ORDER BY odate DESC
") or die(mysql_error());

            while($row = mysql_fetch_array($result))
            {
                echo "<tr>";

                echo "<td>".$row['odate']."</td>";

                echo "<td>".$row['itemcode']."</td>";

                echo "<td>".($row['quantity'])."</td>";

                echo "<td>".($row['saiz'])."</td>";

                echo "<td>".($row['remark'])."</td>"; 

                echo "<td>".($row['outlet'])."</td>";

                echo "</tr>";
            }


        mysql_close($con);
                        ?>
                          </table>

Well, it is getting something back according to the print out of the array there. And that is really strange what it gave you back for the mysql_num_rows.

Try this one, made a change to the while loop and got rid of some unneeded stuff.

<?php    
    $con = mysql_connect("#","#","#");
    mysql_select_db("#", $con);

    $result = mysql_query("SELECT DISTINCT orderdb.view,orderdb.odate,pstaff.outlet FROM orderdb,pstaff WHERE pstaff.outlet='SAP' AND orderdb.odate='2013-03-26' ORDER BY orderdb.odate  limit 0, 30") or die(mysql_error());

    $num_rows = mysql_num_rows($result);
    echo "Rows Returned: ".$num_rows;

    while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
    {
        echo "<td>" . $row['odate'] . "</td>";
        echo "<td>" . $row['outlet'] . "</td>";

        echo "<pre>";
        echo print_r($row);
        echo "</pre>";

        if($row['view']=='no'){
            echo "<td>Not View Yet</td>";
            echo "<td align='center'> <a href='astockview2.php?outlet=".$row['odate'].$row['outlet']."'>View</a> </td>";
        }
    }
    mysql_close($con);
?>

i hate to say this but same result.no data

Rows Returned: 12013-03-26SAP
Array
(
    [view] => no
    [odate] => 2013-03-26
    [outlet] => SAP
)
1
Not View Yet View
Member Avatar for LastMitch

i hate to say this but same result.no data

Add or die(mysql_error()); to those 2 files:

For your first file:

mysql_select_db("mdb_lh026", $con) or die('Could not connect: ' . mysql_error());

and your second file:

mysql_select_db("mdb_lh026", $con) or die('Could not connect: ' . mysql_error());

What was the results?

For these query in your first file:

$result2 = mysql_query("SELECT odate,itemcode, quantity, saiz, remark FROM orderdb ORDER BY odate DESC");

and this

 $result = mysql_query("SELECT DISTINCT orderdb.view,orderdb.odate,pstaff.outlet FROM orderdb,pstaff WHERE pstaff.outlet='SAP' AND orderdb.odate='2013-03-26' ORDER BY orderdb.odate ") or die(mysql_error());

add this: or die('Could not connect: ' . mysql_error()); to the end:

$result2 = mysql_query("SELECT odate,itemcode, quantity, saiz, remark FROM orderdb ORDER BY odate DESC") or die('Could not connect: ' . mysql_error());

and this:

 $result = mysql_query("SELECT DISTINCT orderdb.view,orderdb.odate,pstaff.outlet FROM orderdb,pstaff WHERE pstaff.outlet='SAP' AND orderdb.odate='2013-03-26' ORDER BY orderdb.odate ") or die('Could not connect: ' . mysql_error());

For these query in your second file:

$result2 = mysql_query("SELECT orderdb.odate,orderdb.itemcode,orderdb.quantity,orderdb.saiz,orderdb.remark,pstaff.outlet
FROM orderdb ,pstaff WHERE orderdb.staff_id =pstaff.staff_id AND pstaff.outlet='$outlet' AND orderdb.odate='$odate' ORDER BY odate DESC")

and this:

$result = mysql_query("SELECT orderdb.odate,orderdb.itemcode,orderdb.quantity,orderdb.saiz,orderdb.remark,pstaff.outlet
FROM orderdb ,pstaff WHERE pstaff.outlet='$outlet' AND orderdb.odate='$odate' ORDER BY odate DESC")

add this: or die('Could not connect: ' . mysql_error()); to the end:

$result2 = mysql_query("SELECT orderdb.odate,orderdb.itemcode,orderdb.quantity,orderdb.saiz,orderdb.remark,pstaff.outlet
FROM orderdb ,pstaff WHERE orderdb.staff_id =pstaff.staff_id AND pstaff.outlet='$outlet' AND orderdb.odate='$odate' ORDER BY odate DESC") or die('Could not connect: ' . mysql_error());

and this:

$result = mysql_query("SELECT orderdb.odate,orderdb.itemcode,orderdb.quantity,orderdb.saiz,orderdb.remark,pstaff.outlet
FROM orderdb ,pstaff WHERE pstaff.outlet='$outlet' AND orderdb.odate='$odate' ORDER BY odate DESC") or die('Could not connect: ' . mysql_error());

So all of the query should have this or die('Could not connect: ' . mysql_error());

Then run the code.

If there's an error then you know it's the query.

If there's no error then somewhere in your code there much be a white space or you miss an period or comma or misspelled a word.

ok..added or die('Could not connect: ' . mysql_error());
nothing wrong with the query..
i guess the problem is the white space or other things..

Member Avatar for LastMitch

i guess the problem is the white space or other things..

Try this ( I tweak it a little):

First file:

<?php
include_once 'admin-class.php';
$admin = new itg_admin();
$admin->_authenticate();
$odate=isset($row['odate']);
$outlet=isset($row['outlet']);
$con=mysql_connect("#","#","#");
mysql_select_db("mdb_lh026", $con);
$id=$_SESSION['admin_login'];
$result2 = mysql_query("SELECT odate,itemcode, quantity, saiz, remark FROM orderdb ORDER BY odate DESC");
$nume=mysql_num_rows($result2);
?>
<?php
if($nume==0){ 
echo "You currently have no item to show"; 
}else if(isset($_GET['msg'])){
$msg = $_GET['msg'];
if($msg!=''){
echo '<table border="1">
<tr>
<td><font color="red">'.$msg.'</font></td>
</tr>
</table>';
}
}
?>
</font></strong></p>
<table width="680px" cellspacing="0" cellpadding="5">
<tr bgcolor="#ddd">
<th width="220" align="left">Date </th>
<th width="200" align="left">Outlet </th>
<th width="130" align="left">Status</th>
<th width="70"> </th>
</tr>
<?php
$start=(isset($_GET['start'])) ? (int)$_GET['start']:0;
if(strlen($start) > 0 and !is_numeric($start)){
echo "Data Error";
exit;
}
$eu = ($start - 0);
$limit = 5;
$this1 = $eu + $limit;
$back = $eu - $limit;
$next = $eu + $limit;
$result = mysql_query("SELECT DISTINCT orderdb.view,orderdb.odate,pstaff.outlet FROM orderdb,pstaff WHERE pstaff.outlet='SAP' AND orderdb.odate='2013-03-26' ORDER BY orderdb.odate ") or die(mysql_error());
while($row = mysql_fetch_array($result)){
echo "<td>" .$odate. "</td>";
echo "<td>" .$outlet. "</td>";
if($row['view']=='no'){
echo "<pre>";
echo print_r($row);
echo "</pre>";
echo "<td>Not View Yet</td>";
echo "<td align='center'> <a href='astockview2.php?outlet=".$odate.$outlet."'>View</a> </td>";
echo"<input type='hidden' name='odate' value='". $odate ."' />";
echo"<input type='hidden' name='outlet' value='". $outlet ."' />";
}
echo "</tr>";
}
mysql_close($con);
?>
</table>

Second file:

<?php
include_once 'admin-class.php';
$admin = new itg_admin();
$admin->_authenticate();
$odate=isset($row['odate']);
$outlet=isset($row['outlet']);
$itemcode=isset($row['itemcode']);
$quantity=isset($row['quantity']);
$saiz=isset($row['saiz']);
$remark=isset($row['remark']);
$con=mysql_connect("#","#","#");
mysql_select_db("mdb_lh026", $con);
$id=$_SESSION['admin_login'];
$result2 = mysql_query("SELECT orderdb.odate,orderdb.itemcode,orderdb.quantity,orderdb.saiz,orderdb.remark,pstaff.outlet FROM orderdb ,pstaff WHERE orderdb.staff_id =pstaff.staff_id AND pstaff.outlet='$outlet' AND orderdb.odate='$odate' ORDER BY odate DESC");
$nume=mysql_num_rows($result2);
?>
<?php
if($nume==0){ 
echo "You currently have no item to show"; 
}else if(isset($_GET['msg'])){
$msg = $_GET['msg'];
if($msg!=''){
'<table border="1">
<tr>
<td><font color="red">'.$msg.'</font></td>
</tr>
</table>';
}}
?>
</font></strong></p>
<table width="713" cellspacing="0" cellpadding="5">
<tr bgcolor="#ddd">
<th width="107" align="left">Date </th>
<th width="98" align="left">Item Code </th>
<th width="89" align="left">Quantity</th>
<th width="59" align="left">Size </th>
<th width="263" align="left">Remark</th>
<th width="18" align="left">Outlet</th>
<th width="7"> </th>
</tr>
<?php
$start=(isset($_GET['start'])) ? (int)$_GET['start']:0;
if(strlen($start) > 0 and !is_numeric($start)){
echo "Data Error";
exit;
}
$eu = ($start - 0);
$limit = 5;
$this1 = $eu + $limit;
$back = $eu - $limit;
$next = $eu + $limit;
$date = date("Y-m-d",time() + (8 * 3600));
$result = mysql_query("SELECT orderdb.odate,orderdb.itemcode,orderdb.quantity,orderdb.saiz,orderdb.remark,pstaff.outlet FROM orderdb ,pstaff WHERE pstaff.outlet='$outlet' AND orderdb.odate='$odate' ORDER BY odate DESC") or die(mysql_error());

while($row = mysql_fetch_array($result)){
echo "<tr>";
echo "<td>".$odate."</td>";
echo "<td>".$itemcode."</td>";
echo "<td>".$quantity."</td>";
echo "<td>".$saiz."</td>";
echo "<td>".$remark."</td>";
echo "<td>".$outlet."</td>";
echo "</tr>";
}
mysql_close($con);
?>
</table>

If there's still no data echoing out then it's has be either a white space or other things now.

Sorry but no data too..by the way thanks alot to LastMitch and pixelsoul..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.