Help my php says this | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
+ 1

Help my php says this

<?php $conn = mysqli_connect('localhost','root','','bursary'); $table_content = ' <table class="table-responsive col-md-12 table-users"> <thead> <tr> <th class="col-md-1">Name</th> <th class="col-md-2">ID Number</th> <th class="col-md-3">Registration Number</th> <th class="col-md-4">Institution Name</th> <th class="col-md-5">Bank Name</th> <th class="col-md-6">Account Name</th> <th class="col-md-7">Account Number</th> </tr> </thead> '; $sql = $conn->query ("SELECT firstName, sirName, user_id, Regno, institutionName, bankName, accountName, accountNo FROM profile"); while ($user = mysqli_fetch_array($sql)) { $name = strtoupper($user['firstName']." ".$user['sirName']); $userID = $user['user_id']; $btn_AD_id = "AD".$userID; $btn_DEL_id = "DEL".$userID; $table_content .= ' <tr> <td class="col-md-1">'.$user['$name'].'</td> <td class="col-md-2">'.$user['user_id'].'</td> <td class="col-md-3">'.$user['Regno'].'</td> <td class="col-md-4">'.$user['institutionName'].'</td> <td class="col-md-5">'.$user['bankName'].'</td> <td class="col-md-6">'.$user['accountName'].'</td> <td class="col-md-7">'.$user['accountNo'].'</td> </tr> '; } $table_content .='</table>'; ?>

11th Apr 2018, 4:26 PM
Maamun Maamun
Maamun Maamun - avatar
5 Respuestas
+ 9
$user['$name'] You have $name variable inside single quotes ``. Change them to double quotes or remove them. $user[$name] You can't use variables inside single quotes. It's displayed as string.
11th Apr 2018, 5:16 PM
Toni Isotalo
Toni Isotalo - avatar
+ 7
Maybe you meant to display the $name variable itself? You are now using it as array index. That doesn’t exist.
12th Apr 2018, 1:30 AM
Toni Isotalo
Toni Isotalo - avatar
+ 6
The column doesn’t exist in your database.
12th Apr 2018, 1:24 AM
Toni Isotalo
Toni Isotalo - avatar
0
It gives this error : Notice: Undefined index: $name in C:\xampp\htdocs\bursery\my_application.php on line 27
11th Apr 2018, 4:29 PM
Maamun Maamun
Maamun Maamun - avatar
0
hy toni thnc it worked...but now it says: undefined index: (displays data from the database) on line 27
12th Apr 2018, 1:12 AM
Maamun Maamun
Maamun Maamun - avatar