Jump to content

Recommended Posts

in my $dep array..y is this only 1 row retrieving..infact i have more than 8 rows in the deparment dabase..help me..thanx in advane...

--------------------------------------

 

<?php
/* 
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
include("include/sessionStart.php");
include("include/dbConnect.php");
$query = "SELECT * FROM schoolmaster";
$result = mysql_query($query);
$arr = mysql_fetch_assoc($result);
$query1 = "SELECT * FROM department";
$result1 = mysql_query($query1);
$dep = mysql_fetch_assoc($result1);
print_r($dep);






if(!empty($_GET['submit']) and $_GET['submit']=="Add" )
{
    $depName = $_GET['txtDepName'];
   $yes =mysql_query("INSERT INTO department(departmentName) VALUES( '$depName' )");
   
     
   
}

?>\<html>
    <head><style>
#header{
width: inherit;
height:110px;
background-color:#09C;
margin:auto;
border-bottom:2px solid #000;
position:relative;
border-left:2px solid #000;
border-right:2px solid #000;
        float:left;
}
h1{
position:absolute;
left:205px;
top:0px;
margin-top:0px;
}
h2{
position:absolute;
left:205px;
top:38px;
margin-top:0px;
}
h3{
position:absolute;
left:205px;
top:68px;
margin-top:0px;

}
#container1{
width:800px;
margin:auto;
}
label{
width:190px;
font-family:"Palatino Linotype", "Book Antiqua", Palatino, serif;
font-weight:bold;
font-size:19px;
float:left;
margin:4px;
}
table{ position:absolute; border:none;
top:0px;

}
td{
font-family:"Palatino Linotype", "Book Antiqua", Palatino, serif;
font-weight:bold;
width:138px;
}
</style></head>
    <body>

<div id="container1">
<div id="header">
<img src="<?php echo $arr['schoolLogo']; ?>" width="200px" height="110px" />
<h1><?php echo $arr['schoolName']; ?></h1>
<h2><?php echo $arr['schoolAddress']; ?></h2>
<h3><?php echo $arr['schoolContact']; ?></h3>

</div>
<div style="margin-left:20px;">
<?php include("dropDown.php");?>

</div>

<div style="width: 620px; height:400px;  position:relative; float: right; background-color: #FFDFFF;text-align:center;">
<form name="formAddDep" action="#" method="get">
        <fieldset style="width:200px; float:right;  border:2px solid #000; ">
        <legend>Update</legend>
            <label>New Department</label><input style="width:180px;" type="text" name="txtDepName" value="" tabindex="1">
            <label>Status</label><br/>
            E<input type="radio" name="radioStatus" value="e" />
            D<input type="radio" name="radioStatus" value="d" /><br/>
            
           
            <input type="submit" name="submit" value="Add">
            
</fieldset>
        </form>
    <table >
        <tr>
            <td>Department Id</td>
            <td>Department Name</td>
            <td>Status</td>

        </tr>
        <tr>
        <?php foreach($dep as $value)
        {?>
        
            <td><?php echo $value;?></td>
            
        
        <?php }?>
            </tr>

    </table>
    <?php
      //      if(!empty($yes)){echo "<h4>department Added</h4>";
    ///        echo "<a href=\"changeDisplay.php\">BACK</a>";
       //     } ?>
</div>
</div>
    </body>
</html>

might be because you dont have it inside a loop...try

 

while($dep = mysql_fetch_assoc($result1)){
print_r($dep);
}

 

honestly I am not sure about this one...however i think that since you do not have your mysqll_fetch_array inside of a loop, it is only grabbing the first row, therefore your print_r will display one row

is this only 1 row retrieving..infact i have more than 8 rows in the deparment dabase

Because mysql_fetch_assoc only retrieves one row at a time. You need to use a while loop to loop through the results from your query, like how the manual demonstrates for mysql_fetch_assoc

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.