Re: Re: can a session be used in a query?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jan 7, 2009 at 8:28 PM, Paul M Foster <paulf@xxxxxxxxxxxxxxxxx>wrote:

> On Wed, Jan 07, 2009 at 08:29:42PM -0500, Frank Stanovcak wrote:
>
> > because you so nicely didn't make fun of me...that much  :)
> > I keep it in it's own file and just use it as in include to probe where I
> need to.
> >
> > ------code follows------
> >
> > <?php
> > function breakarray($passed){
> >  echo '<table border="1"><tr><th>key</th><th>value</th></tr>';
> >  foreach($passed as $tkey=>$tvalue){
> >   echo '<tr><td>[' , $tkey , ']</td><td>';
> >   if(is_array($tvalue)){
> >    breakarray($tvalue);
> >   }else{
> >    echo '"' , $tvalue , '"</td></tr>';
> >   };
> >  };
> >  echo '</table>';
> > };
> >
> > echo '<table border=1><tr> <th>variable</th> <th>value</th> </tr>';
> > foreach(get_defined_vars() as $key => $value){
> >  echo '<tr><td>$',$key ,'</td><td>';
> >     if(is_array($value) and $key != 'GLOBALS'){
> >   if(sizeof($value) > 0){
> >    breakarray($value);
> >    echo '</td></tr>';
> >   }else{
> >    echo 'EMPTY </td></tr>';
> >   };
> >  }else{
> >   echo '"' , $value , '"</td></tr>';
> >  };
> > };
> > echo '</table>';
> > ?>
>
> Nicely done.
>
> Paul
>
> --
> Paul M. Foster
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

Good Morning Everyone
Thanks for the snippet going to try that now, is it not okay to reuse the
$row thru the code block, I do try and use it over and over to check for
different fields data.  I am going to go ahead and post the full block of
code:
----------------------code--------------------------------------------------------------------------------
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
session_start();
include("inc/dbconn_open.php");

if (empty($_SESSION['AdminLogin']) || $_SESSION['AdminLogin'] !=  true){
    header ("Location: LogOut.php");
    $_SESSION['user']=$UserName;
}



   $query = "SELECT * FROM admin WHERE  UserName =   '".$_SESSION['user']."'
";
    $result=mysql_query($query) or die('Queryproblem: ' . mysql_error() .
'<br />Executed            query: ' . $query);
             if (mysql_num_rows($result) >= '1'){
            while ($row = mysql_fetch_array($result)){
            echo $row['AddEditAdmin']; //to print out the value of column
'var1' for each record

      }
  }else{
                 echo 'No records found.';
   }
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>The NEW Work Order System </title>
<LINK REL="STYLESHEET" HREF="inc/style.css">
</head>

<body bgcolor="#006699">
<table width="180" border="0" cellpadding="0" cellspacing="0">
    <tr>
        <td align="center"><BR>
        <? echo $row['AddEditAdmin'];?>
        <div class="admin_Title" align="center">Work Order System<br> </div>


        </td>
    </tr>
    <tr>
        <td><HR>You are logged on as <?php echo $_SESSION['user'];?><HR>
        <?php echo $result;?><br>
        <?php echo $row;?>
        <HR></td>
    </tr>
    <tr>
        <td><div class="admin_link"><a href="Welcome.php?AdminID=<?php echo
$_SESSION['user']; ?>" target="mainFrame">Home</a>
        </tr>
        <tr>
        <td><div class="admin_link"><a href="LogOut.php"
target="_parent">LogOut</a></div></td>
    </tr>
        <tr>
        <td align="center"><BR><?php echo $row['AddEditAdmin'];?>
        <div class="admin_Title" align="center">Your Admin Tools</div></td>
    </tr>
        <?php
    if($row['AddEditAdmin'] === 'YES'){    <----this is the only one I have
been playing with..
    ?>
    <tr>
        <td><div class="admin_link"><a href="AddAdmin.php?AdminID=<?php echo
$_SESSION['user']; ?>" target="mainFrame">Add Admin</a></div></td>
    </tr>
    <tr>
        <td><div class="admin_link"><a href="ViewAdmin.php?AdminID=<?php
echo $_SESSION['user']; ?>" target="mainFrame">View Admin</a></div></td>
    </tr>
    <tr>
        <td><div class="admin_link"><a
href="ChangePassword.php?AdminID=<?php echo $_SESSION['user']; ?>"
target="mainFrame">Change My Password</a></div></td>
    </tr>
        <?php
    }
?>

        </div></td>
    </tr>
    <tr>
        <td class="admin_Title"><HR><strong>BANNER & ART
REQUESTS</strong><HR></td>
    </tr>

<?php
    if ($row["AddWorkOrder"] == "YES") {
?>
    <tr>
        <td><div class="admin_link"><a href="WorkOrder.php?AdminID=<?php
echo $_SESSION['AdminLogin']; ?>" target="mainFrame">Work Order
Form</a></div><br></td>
    </tr>

</table>
</body>
</html>
--------------------------------------------------------end
code-------------------------
it's larger than this but you get the picture, I just need to get the $row
to actually work, I don't understand why I can echo it at the top of the
page and then not further down.

Thanks for looking
terion

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux