What's new

PHP Mga IT Gods Need your help

Status
Not open for further replies.

M H I N Y E

Forum Guru
Elite
Joined
May 11, 2018
Posts
3,625
Solutions
5
Reaction
5,767
Points
1,610
IT Gods Need your help on how to solve this

My problem is that only the Administrator and staff lng ang ma didisplay sa user type. gusto ko lang po sana na kung alin ang senilect kng user type ay yung din sana ma display sa usertype. yun lng po mga mster sana matulungan THANKS IN ADVANCE

PHP:
ito po ung code nya kaya admin and staff lng ang display
feel ko dito lng ata galawin pero kahit anong try ko hindi ko makuha

<td ><p class="m-0"><?php echo ($row['type'] == 1 )? "Adminstrator" : "Staff" ?></p></td>
1656251856229.png


PHP:
Ito naman po ung code for selecting user type

<div class="form-group col-6">
                    <label for="type">User Type</label>
                    <select name="type" id="type" class="custom-select"  required>
                        <option value="1" <?php echo isset($meta['type']) && $meta['type'] == 1 ? 'selected': '' ?>>Administrator</option>
                        <option value="2" <?php echo isset($meta['type']) && $meta['type'] == 2 ? 'selected': '' ?>>Staff</option>
                        <option value="3" <?php echo isset($meta['type']) && $meta['type'] == 3 ? 'selected': '' ?>>Process Owner</option>
                        <option value="4" <?php echo isset($meta['type']) && $meta['type'] == 4 ? 'selected': '' ?>>Auditor</option>
                        <option value="5" <?php echo isset($meta['type']) && $meta['type'] == 5 ? 'selected': '' ?>>Auditor Lead</option>
                        <option value="6" <?php echo isset($meta['type']) && $meta['type'] == 6 ? 'selected': '' ?>>QAH</option>
                        <option value="7" <?php echo isset($meta['type']) && $meta['type'] == 7 ? 'selected': '' ?>>Team Management</option>
                        <option value="8" <?php echo isset($meta['type']) && $meta['type'] == 8 ? 'selected': '' ?>>Human Resource</option>
                    </select>
                </div>
1656251983298.png


ito pala user type attribute
1656254050212.png
 

Attachments

Last edited:
nag try ako ganto lumabas awit
PHP:
<td >
                                <p class="m-0">
                                    <?php echo ($row['type'] == 1 )? "Adminstrator" : "Staff" ?>
                                    <?php echo ($row['type'] == 2 )? "Adminstrator" : "Staff" ?>
                                    <?php echo ($row['type'] == 3 )? "Adminstrator" : "Staff" ?>
                                    <?php echo ($row['type'] == 4 )? "Adminstrator" : "Staff" ?>
                                    <?php echo ($row['type'] == 5 )? "Adminstrator" : "Staff" ?>
                                    <?php echo ($row['type'] == 6 )? "Adminstrator" : "Staff" ?>
                                    <?php echo ($row['type'] == 7 )? "Adminstrator" : "Staff" ?>
                                    <?php echo ($row['type'] == 8 )? "Adminstrator" : "Staff" ?>
                                </p>
                            </td>
1656254400646.png


yung $meta['type'] po ba yan yung user type attribute po
yan po ung mga mga user type
1656254472772.png
 

Attachments

Ang gusto mo ba is ganito? (meron kang data sa database ng usertype tapos sa combo box kung ano man piliin nya gusto mo yun lang lalabas parang sort ganon ba?)
 
Ang gusto mo ba is ganito? (meron kang data sa database ng usertype tapos sa combo box kung ano man piliin nya gusto mo yun lang lalabas parang sort ganon ba?)
yes po

Ang gusto mo ba is ganito? (meron kang data sa database ng usertype tapos sa combo box kung ano man piliin nya gusto mo yun lang lalabas parang sort ganon ba?)
ganto po ksi itsura nyan
1656254637637.png

for example select ko yung auditor na user type tapos ang makalagay is staff parin
1656254744838.png
 

Attachments

Ganto po sagot dyan, una ilagay mo po sa variable yung value ng selected combo box , tapos po sa table po ng view mo, mag query kalang ng select * where usertype = 'variablengselectedcombobox' tas i view mo na po sya sa table mo po

yes po


ganto po ksi itsura nyan
View attachment 1997602
for example select ko yung auditor na user type tapos ang makalagay is staff parin
View attachment 1997604
ay ok gets gets, ang gusto mo lang pala is ilagay na value kay user type is yung selected sa combo box ganon ba? parang insert palang pala sya?
 
Ganto po sagot dyan, una ilagay mo po sa variable yung value ng selected combo box , tapos po sa table po ng view mo, mag query kalang ng select * where usertype = 'variablengselectedcombobox' tas i view mo na po sya sa table mo po


ay ok gets gets, ang gusto mo lang pala is ilagay na value kay user type is yung selected sa combo box ganon ba?
oo yan paps
 
netong form papuntang database mo
PHP:
<?php
if(isset($_GET['id']) && $_GET['id'] > 0){
    $user = $conn->query("SELECT * FROM users where id ='{$_GET['id']}'");
    foreach($user->fetch_array() as $k =>$v){
        $meta[$k] = $v;
    }
}
?>
<?php if($_settings->chk_flashdata('success')): ?>
<script>
    alert_toast("<?php echo $_settings->flashdata('success') ?>",'success')
</script>
<?php endif;?>
<div class="card card-outline card-primary">
    <div class="card-body">
        <div class="container-fluid">
            <div id="msg"></div>
            <form action="" id="manage-user">   
                <input type="hidden" name="id" value="<?php echo isset($meta['id']) ? $meta['id']: '' ?>">
                <div class="form-group col-6">
                    <label for="name">First Name</label>
                    <input type="text" name="firstname" id="firstname" class="form-control" value="<?php echo isset($meta['firstname']) ? $meta['firstname']: '' ?>" required>
                </div>
                <div class="form-group col-6">
                    <label for="name">Last Name</label>
                    <input type="text" name="lastname" id="lastname" class="form-control" value="<?php echo isset($meta['lastname']) ? $meta['lastname']: '' ?>" required>
                </div>
                <div class="form-group col-6">
                    <label for="username">Username</label>
                    <input type="text" name="username" id="username" class="form-control" value="<?php echo isset($meta['username']) ? $meta['username']: '' ?>" required  autocomplete="off">
                </div>
                <div class="form-group col-6">
                    <label for="password">Password</label>
                    <input type="password" name="password" id="password" class="form-control" value="" autocomplete="off" <?php echo isset($meta['id']) ? "": 'required' ?>>
                    <?php if(isset($_GET['id'])): ?>
                    <small class="text-info"><i>Leave this blank if you dont want to change the password.</i></small>
                    <?php endif; ?>
                </div>
                <div class="form-group col-6">
                    <label for="type">User Type</label>
                    <select name="type" id="type" class="custom-select"  required>
                        <option value="1" <?php echo isset($meta['type']) && $meta['type'] == 1 ? 'selected': '' ?>>Administrator</option>
                        <option value="2" <?php echo isset($meta['type']) && $meta['type'] == 2 ? 'selected': '' ?>>Staff</option>
                        <option value="3" <?php echo isset($meta['type']) && $meta['type'] == 3 ? 'selected': '' ?>>Process Owner</option>
                        <option value="4" <?php echo isset($meta['type']) && $meta['type'] == 4 ? 'selected': '' ?>>Auditor</option>
                        <option value="5" <?php echo isset($meta['type']) && $meta['type'] == 5 ? 'selected': '' ?>>Auditor Lead</option>
                        <option value="6" <?php echo isset($meta['type']) && $meta['type'] == 6 ? 'selected': '' ?>>QAH</option>
                        <option value="7" <?php echo isset($meta['type']) && $meta['type'] == 7 ? 'selected': '' ?>>Team Management</option>
                        <option value="8" <?php echo isset($meta['type']) && $meta['type'] == 8 ? 'selected': '' ?>>Human Resource</option>
                    </select>
                </div>
                <div class="form-group col-6">
                    <label for="" class="control-label">Avatar</label>
                    <div class="custom-file">
                      <input type="file" class="custom-file-input rounded-circle" id="customFile" name="img" onchange="displayImg(this,$(this))">
                      <label class="custom-file-label" for="customFile">Choose file</label>
                    </div>
                </div>
                <div class="form-group col-6 d-flex justify-content-center">
                    <img src="<?php echo validate_image(isset($meta['avatar']) ? $meta['avatar'] :'') ?>" alt="" id="cimg" class="img-fluid img-thumbnail">
                </div>
            </form>
        </div>
    </div>
    <div class="card-footer">
            <div class="col-md-12">
                <div class="row">
                    <button class="btn btn-sm btn-success mr-2" form="manage-user">Save</button>
                    <a class="btn btn-sm btn-secondary" href="./?page=user/list">Cancel</a>
                </div>
            </div>
        </div>
</div>
 
Code:
<form action="" id="manage-user">   
                <input type="hidden" name="id" value="<?php echo isset($meta['id']) ? $meta['id']: '' ?>">
                <div class="form-group col-6">
                    <label for="name">First Name</label>
                    <input type="text" name="firstname" id="firstname" class="form-control" value="<?php echo isset($meta['firstname']) ? $meta['firstname']: '' ?>" required>
                </div>
                <div class="form-group col-6">
                    <label for="name">Last Name</label>
                    <input type="text" name="lastname" id="lastname" class="form-control" value="<?php echo isset($meta['lastname']) ? $meta['lastname']: '' ?>" required>
                </div>
                <div class="form-group col-6">
                    <label for="username">Username</label>
                    <input type="text" name="username" id="username" class="form-control" value="<?php echo isset($meta['username']) ? $meta['username']: '' ?>" required  autocomplete="off">
                </div>
                <div class="form-group col-6">
                    <label for="password">Password</label>
                    <input type="password" name="password" id="password" class="form-control" value="" autocomplete="off" <?php echo isset($meta['id']) ? "": 'required' ?>>
                    <?php if(isset($_GET['id'])): ?>
                    <small class="text-info"><i>Leave this blank if you dont want to change the password.</i></small>
                    <?php endif; ?>
                </div>
                <div class="form-group col-6">
                    <label for="type">User Type</label>
                    <select name="type" id="type" class="custom-select"  required>
                        <option value="1" <?php echo isset($meta['type']) && $meta['type'] == 1 ? 'selected': '' ?>>Administrator</option>
                        <option value="2" <?php echo isset($meta['type']) && $meta['type'] == 2 ? 'selected': '' ?>>Staff</option>
                        <option value="3" <?php echo isset($meta['type']) && $meta['type'] == 3 ? 'selected': '' ?>>Process Owner</option>
                        <option value="4" <?php echo isset($meta['type']) && $meta['type'] == 4 ? 'selected': '' ?>>Auditor</option>
                        <option value="5" <?php echo isset($meta['type']) && $meta['type'] == 5 ? 'selected': '' ?>>Auditor Lead</option>
                        <option value="6" <?php echo isset($meta['type']) && $meta['type'] == 6 ? 'selected': '' ?>>QAH</option>
                        <option value="7" <?php echo isset($meta['type']) && $meta['type'] == 7 ? 'selected': '' ?>>Team Management</option>
                        <option value="8" <?php echo isset($meta['type']) && $meta['type'] == 8 ? 'selected': '' ?>>Human Resource</option>
                    </select>
                </div>
                <div class="form-group col-6">
                    <label for="" class="control-label">Avatar</label>
                    <div class="custom-file">
                      <input type="file" class="custom-file-input rounded-circle" id="customFile" name="img" onchange="displayImg(this,$(this))">
                      <label class="custom-file-label" for="customFile">Choose file</label>
                    </div>
                </div>
                <div class="form-group col-6 d-flex justify-content-center">
                    <img src="<?php echo validate_image(isset($meta['avatar']) ? $meta['avatar'] :'') ?>" alt="" id="cimg" class="img-fluid img-thumbnail">
                </div>
            </form>

PHP:
<form action="" id="manage-user">   
                <input type="hidden" name="id" value="<?php echo isset($meta['id']) ? $meta['id']: '' ?>">
                <div class="form-group col-6">
                    <label for="name">First Name</label>
                    <input type="text" name="firstname" id="firstname" class="form-control" value="<?php echo isset($meta['firstname']) ? $meta['firstname']: '' ?>" required>
                </div>
                <div class="form-group col-6">
                    <label for="name">Last Name</label>
                    <input type="text" name="lastname" id="lastname" class="form-control" value="<?php echo isset($meta['lastname']) ? $meta['lastname']: '' ?>" required>
                </div>
                <div class="form-group col-6">
                    <label for="username">Username</label>
                    <input type="text" name="username" id="username" class="form-control" value="<?php echo isset($meta['username']) ? $meta['username']: '' ?>" required  autocomplete="off">
                </div>
                <div class="form-group col-6">
                    <label for="password">Password</label>
                    <input type="password" name="password" id="password" class="form-control" value="" autocomplete="off" <?php echo isset($meta['id']) ? "": 'required' ?>>
                    <?php if(isset($_GET['id'])): ?>
                    <small class="text-info"><i>Leave this blank if you dont want to change the password.</i></small>
                    <?php endif; ?>
                </div>
                <div class="form-group col-6">
                    <label for="type">User Type</label>
                    <select name="type" id="type" class="custom-select"  required>
                        <option value="1" <?php echo isset($meta['type']) && $meta['type'] == 1 ? 'selected': '' ?>>Administrator</option>
                        <option value="2" <?php echo isset($meta['type']) && $meta['type'] == 2 ? 'selected': '' ?>>Staff</option>
                        <option value="3" <?php echo isset($meta['type']) && $meta['type'] == 3 ? 'selected': '' ?>>Process Owner</option>
                        <option value="4" <?php echo isset($meta['type']) && $meta['type'] == 4 ? 'selected': '' ?>>Auditor</option>
                        <option value="5" <?php echo isset($meta['type']) && $meta['type'] == 5 ? 'selected': '' ?>>Auditor Lead</option>
                        <option value="6" <?php echo isset($meta['type']) && $meta['type'] == 6 ? 'selected': '' ?>>QAH</option>
                        <option value="7" <?php echo isset($meta['type']) && $meta['type'] == 7 ? 'selected': '' ?>>Team Management</option>
                        <option value="8" <?php echo isset($meta['type']) && $meta['type'] == 8 ? 'selected': '' ?>>Human Resource</option>
                    </select>
                </div>
                <div class="form-group col-6">
                    <label for="" class="control-label">Avatar</label>
                    <div class="custom-file">
                      <input type="file" class="custom-file-input rounded-circle" id="customFile" name="img" onchange="displayImg(this,$(this))">
                      <label class="custom-file-label" for="customFile">Choose file</label>
                    </div>
                </div>
                <div class="form-group col-6 d-flex justify-content-center">
                    <img src="<?php echo validate_image(isset($meta['avatar']) ? $meta['avatar'] :'') ?>" alt="" id="cimg" class="img-fluid img-thumbnail">
                </div>
            </form>

yan na paps
 
Status
Not open for further replies.

Similar threads

Back
Top