Open siddiquedu opened 10 years ago
hmm I don't see anything wrong. Try tossing a mysqli_error()
in there....
<div id="form-group">
<label for="user">User:</label>
<select class="form-control" name="user" id="user">
<option value="0">No User</option>
<?php
$q = "SELECT email FROM users ORDER BY first ASC";
$r = mysqli_query($dbc, $q);
if($r) {
while ($user_list = mysqli_fetch_assoc($r)){
$user_data = data_user($dbc, $user_list['email']);
?>
<option value="0"><?php echo $user_data['fullname'];?></option>
<?php } }else{
echo mysqli_error($dbc); // See if mysql has any error to report.
echo '<br>'.$q; // Output the query just to see if there is an obvious mistake.
?>
</select>
</div>
Brother, I found no error. However, I re-arranged the codding like below: and I found only current user(who is logged in out of all).
here is points.
How can I get all member. How can I fix php block in this case.
seems like a database mistake
<div id="form-group">
<label for="user">User:</label>
<select class="form-control" name="user" id="user">
<option value="0">No User</option>
<?php
$q = "SELECT email FROM [(users)<----check that it's the actual table name] ORDER BY [(first) check that this colum exist in the table]ASC";
$r = mysqli_query($dbc, $q);
while ($user_list = mysqli_fetch_assoc($r)){
$user_data = data_user($dbc, $user_list['email']);<---- check the data_user function and that it's linked properly
?>
<option value="0"><?php echo $user_data['fullname'];?></option>
<?php } ?>
</select>
</div>
this should be your data_user function:
function data_user($dbc, $id) {
if(is_numeric($id)) {
$cond = "WHERE id = '$id'";
} else {
$cond = "WHERE email = '$id'";
}
$q = "SELECT * FROM users $cond";
$r = mysqli_query($dbc, $q);
$data = mysqli_fetch_assoc($r);
$data['fullname'] = $data['first'].' '.$data['last'];
$data['fullname_reverse'] = $data['last'].', '.$data['first'];
return $data;
}
Brother, I check all even your code from GitHub...But i can't see the user list from select option in the index.php(admin). here is my code.please help after a long journey to your series I am stuck now.