chodzi mi o to zeby podczas ladowania pobral wartosc value dla (radio, pozniej select i checkbox i tak dalej) i "kliknal" tam gdzie trzeba checked
$(document).ready(function() { document.getElementsByName('type').value('<?php echo $u['type']; ?>').checked = true; });
<?php if ($u['type'] === "active") { echo ' <label class="radio-inline"><input type="radio" name="type" value="active" onclick="showActive()" checked><b>Uczestnik Aktywny</b> (czynny)</label> <label class="radio-inline"><input type="radio" name="type" value="passive" onclick="hideActive()"><b>Uczestnik Bierny</b> (słuchacz)</label> <label class="radio-inline"><input type="radio" name="type" value="admin" onclick="hideActive()">Administrator</label> '; } if ($u['type'] === "passive") { echo ' <label class="radio-inline"><input type="radio" name="type" value="active" onclick="showActive()"><b>Uczestnik Aktywny</b> (czynny)</label> <label class="radio-inline"><input type="radio" name="type" value="passive" onclick="hideActive()" checked><b>Uczestnik Bierny</b> (słuchacz)</label> <label class="radio-inline"><input type="radio" name="type" value="admin" onclick="hideActive()">Administrator</label> '; } if ($u['type'] === "admin") { echo ' <label class="radio-inline"><input type="radio" name="type" value="active" onclick="showActive()"><b>Uczestnik Aktywny</b> (czynny)</label> <label class="radio-inline"><input type="radio" name="type" value="passive" onclick="hideActive()"><b>Uczestnik Bierny</b> (słuchacz)</label> <label class="radio-inline"><input type="radio" name="type" value="admin" onclick="hideActive()" checked>Administrator</label> '; } ?>
function showActive() { $('#row-active').fadeIn(400); $('#session, #sposob').prop('required', true); } function hideActive() { $('#row-active').fadeOut(400); $('#session, #sposob').prop('required', false); }
<select class="form-control text-center" type="text" id="session" name="session"> <option selected disabled value="">wybierz sesję</option> <option value="s1">Sesja I: Pre i postnatalne procesy rozwojowe i adaptacyjne w ustroju</option> <option value="s2">Sesja II: Komórkowe i sygnalizacyjne transformacje w fizjopatologii nowotworów</option> <option value="s3">Sesja III: Diagnostyka i terapia w gastroenterologii</option> <option value="s4">Sesja IV: Genetyczne i epigenetyczne czynniki kształtujące układowe funkcjonowanie ustroju</option> <option value="s5">Sesja V: Stan odżywienia jako wykładnik zdrowia i podatności na choroby</option> <option value="s6">Sesja VI: Fizjologia i patofizjologia centralnego układu nerwowego</option> <option value="s7">Sesja VII: Substancje pochodzenia naturalnego jako czynniki prawidłowego funkcjonowania organizmu</option> <option value="s8">Sesja VIII: Badania funkcjonalne komórek – metody i techniki</option> <option value="s9">Sesja IX: Fizjologia zwierząt bezkręgowych lub Fizjologia bezkręgowców</option> <option value="s10">Sesja X: Fizjologia bakterii</option> </select>
$usertoupdate = $_POST['email']; $columns = ['type', 'title', 'name', 'surname', 'sex', 'status', 'email', 'password', 'phone', 'college', 'organ', 'city', 'section', 'sectiontype', 'invoice', 'company', 'address', 'code', 'ccity', 'nip', 'cphone', 'payd']; function ($record) use ($columns){ return array_combine($columns, str_getcsv($record, '|')); }, ); $us = array_filter($users, function ($user) use ($usertoedit) {return $user['email'] === $usertoupdate;});
$emailOfUserToUpdate = $_POST['email']; // zobacz jaka czytelna nazwa zmiennej // ... $userToUpdate = array_filter($users, function ($user) use ($emailOfUserToUpdate) {return $user['email'] === $emailOfUserToUpdate;})[0]; // i z dwóch zmiennych robi się jedna
<?php $successPage = './admin/admin.php'; if ($_SERVER['REQUEST_METHOD'] == 'POST') { $action = $_POST['action']; if ($action === 'update') { $newtype = $_POST['type']; $newtitle = $_POST['title']; $newname = $_POST['name']; $newsurname = $_POST['surname']; if ($_POST['sex'] === 'kobieta') { $newsex = 'k'; } else if ($_POST['sex'] === 'mężczyzna') { $newsex = 'm'; } $newstatus = $_POST['status']; $newemail = $_POST['email']; $newpassword = $_POST['password']; $newphone = $_POST['phone']; $newcollege = $_POST['school']; $neworgan = $_POST['organ']; $newcity = $_POST['city']; if ($newtype === 'admin') { $newsection = ''; $newsectiontype = ''; $newinvoice = 'nie'; $newcompany = ''; $newaddress = ''; $newcode = ''; $newccity = ''; $newnip = ''; $newcphone = ''; $newpayd = ''; } else { if ($newtype === 'active') { $newsection = $_POST['session']; $newsectiontype = $_POST['sposob']; } else if ($newtype === 'passive') { $newsection = ''; $newsectiontype = ''; } { $newinvoice = 'tak'; $newcompany = $_POST['company']; $newaddress = $_POST['company-address']; $newcode = $_POST['company-postcode']; $newccity = $_POST['company-city']; $newnip = $_POST['company-nip']; { $newcphone = $_POST['company-phone']; } else { $newcphone = ''; } } else { $newinvoice = 'nie'; $newcompany = ''; $newaddress = ''; $newcode = ''; $newccity = ''; $newnip = ''; $newcphone = ''; } { $newpayd = $_POST['payd']; } else { $newpayd = ''; } } $columns = ['type', 'title', 'name', 'surname', 'sex', 'status', 'email', 'password', 'phone', 'college', 'organ', 'city', 'section', 'sectiontype', 'invoice', 'company', 'address', 'code', 'ccity', 'nip', 'cphone', 'payd']; function ($record) use ($columns){ return array_combine($columns, str_getcsv($record, '|')); }, ); $emailOfUserToUpdate = $newemail; $userToUpdate = array_filter($users, function ($user) use ($emailOfUserToUpdate) {return $user['email'] === $emailOfUserToUpdate;})[0]; } } //header('Location: '.$successPage); //exit; ?>
Notice: Undefined offset: 0 in /home/smusic/ftp/_x-kaf/php/update.php on line 107
$columns = ['type', 'title', 'name', 'surname', 'sex', 'status', 'email', 'password', 'phone', 'college', 'organ', 'city', 'section', 'sectiontype', 'invoice', 'company', 'address', 'code', 'ccity', 'nip', 'cphone', 'payd']; function ($record) use ($columns){ return array_combine($columns, str_getcsv($record, '|')); }, ); $emailOfUserToUpdate = $newemail; $userToUpdate = array_filter($users, function ($user) use ($emailOfUserToUpdate) {return $user['email'] === $emailOfUserToUpdate;})[1]; $userUpdate = array('type' => $newtype, 'title' => $newtitle, 'name' => $newname, 'surname' => $newsurname, 'sex' => $newsex, 'status' => $newstatus, 'email' => $newemail, 'password' => $newpassword, 'phone' => $newphone, 'college' => $newcollege, 'organ' => $neworgan, 'city' => $newcity, 'section' => $newsection, 'sectiontype' => $newsectiontype, 'invoice' => $newinvoice, 'company' => $newcompany, 'address' => $newaddress, 'code' => $newcode, 'ccity' => $newccity, 'nip' => $newnip, 'cphone' => $newcphone, 'payd' => $newpayd); $newUsers = array_filter($users, function ($user) use ($emailOfUserToUpdate) {return $user['email'] !== $emailOfUserToUpdate;}); $done = array_replace($users, $updatedUsers); // to rowniez i tu standardowo fwrite i tak dalej czy jest taki sposob jak pobranie z pliku?
$userToUpdate = array_filter($users, function ($user) use ($emailOfUserToUpdate) {return $user['email'] === $emailOfUserToUpdate;})[0];
$userToUpdate = array_values(array_filter($users, function ($user) use ($emailOfUserToUpdate) {return $user['email'] === $emailOfUserToUpdate;}))[0]null;
$columns = ['type', 'title', 'name', 'surname', 'sex', 'status', 'email', 'password', 'phone', 'college', 'organ', 'city', 'section', 'sectiontype', 'invoice', 'company', 'address', 'code', 'ccity', 'nip', 'cphone', 'payd']; $emailOfUserToUpdate = $newemail; $userToUpdate = array_values(array_filter($users, function ($user) use ($emailOfUserToUpdate) {return $user['email'] === $emailOfUserToUpdate;}))[0]null;
$userUpdate = array('type' => $newtype, 'title' => $newtitle, 'name' => $newname, 'surname' => $newsurname, 'sex' => $newsex, 'status' => $newstatus, 'email' => $newemail, 'password' => $newpassword, 'phone' => $newphone, 'college' => $newcollege, 'organ' => $neworgan, 'city' => $newcity, 'section' => $newsection, 'sectiontype' => $newsectiontype, 'invoice' => $newinvoice, 'company' => $newcompany, 'address' => $newaddress, 'code' => $newcode, 'ccity' => $newccity, 'nip' => $newnip, 'cphone' => $newcphone, 'payd' => $newpayd); $newUsers = array_filter($users, function ($user) use ($emailOfUserToUpdate) {return $user['email'] !== $emailOfUserToUpdate;}); $updatedUsers = array_filter($newUsers, function ($userUpdate) use ($newUsers) {return array_merge($newUsers, $userUpdate);});
$database = './../db/users.csv'; $columns = ['type', 'title', 'name', 'surname', 'sex', 'status', 'email', 'password', 'phone', 'college', 'organ', 'city', 'section', 'sectiontype', 'invoice', 'company', 'address', 'code', 'ccity', 'nip', 'cphone', 'payd']; $emailOfUserToUpdate = $newemail; $userToUpdate = array('type' => $newtype, 'title' => $newtitle, 'name' => $newname, 'surname' => $newsurname, 'sex' => $newsex, 'status' => $newstatus, 'email' => $newemail, 'password' => $newpassword, 'phone' => $newphone, 'college' => $newcollege, 'organ' => $neworgan, 'city' => $newcity, 'section' => $newsection, 'sectiontype' => $newsectiontype, 'invoice' => $newinvoice, 'company' => $newcompany, 'address' => $newaddress, 'code' => $newcode, 'ccity' => $newccity, 'nip' => $newnip, 'cphone' => $newcphone, 'payd' => $newpayd); $newUsers = array_filter($users, function ($user) use ($emailOfUserToUpdate) {return $user['email'] !== $emailOfUserToUpdate;}); foreach ($updatedUsers as &$value) { }
Warning: array_combine(): Both parameters should have an equal number of elements in /home/smusic/ftp/_x-kaf/php/update.php on line 102 Warning: array_combine(): Both parameters should have an equal number of elements in /home/smusic/ftp/_x-kaf/php/update.php on line 102 Warning: array_combine(): Both parameters should have an equal number of elements in /home/smusic/ftp/_x-kaf/php/update.php on line 102 Warning: array_combine(): Both parameters should have an equal number of elements in /home/smusic/ftp/_x-kaf/php/update.php on line 102 Warning: implode(): Invalid arguments passed in /home/smusic/ftp/_x-kaf/php/update.php on line 115 Warning: implode(): Invalid arguments passed in /home/smusic/ftp/_x-kaf/php/update.php on line 115 Warning: implode(): Invalid arguments passed in /home/smusic/ftp/_x-kaf/php/update.php on line 115 Warning: implode(): Invalid arguments passed in /home/smusic/ftp/_x-kaf/php/update.php on line 115
admin||Kacper|...||||||| active|dr n med.|Rad...| admin|dr|Syl...||||||| admin||Boh...|||||||