-1
Bitte helfen Sie mir, ich bin das Array (11,7,10) in eine Tabelle einfügen.Echo-Array von Mysql in <option> Wert
Jetzt möchte ich diese Daten an echo:
like this structure iwant to make it
<select>
<option value="11">11- HbA1C</option>
<option value="7">10- O"Solivan Test</option>
<option value="10">7- Randam Blood Glucose</option>
</select>
/////////////////////////////////////
table==>
id \t name \t date \t re_doctor \t sex \t age \t no_ana \t name_pr
11 \t aaaa \t 17/04/2017 \t \t Female \t \t 11,10,7 \t 11- HbA1C,10- O"Solivan Test,7- Randam Blood Gluco.
////////////////////////////////////////////////
my code :-
<?
$qqq=$_GET['n'];
$sql = "SELECT * FROM `profile` where id ='$qqq'"; // select only the username field from the table "users_table"
$result = mysql_query($sql); // process the query
$username_array = array(); // start an array
while($row = mysql_fetch_array($result)){ // cycle through each record returned
$array1[] = $row[6]; // get the username field and add to the array above with surrounding quotes
// get the username field and add to the array above with surrounding quotes
$array3[] = $row[7]; // get the username field and add to the array above with surrounding quotes
}
?>
<select> <option>
<?
foreach($array1 as $it=>$ss){
foreach($array3 as $rr=>$vv){
if ($it==$rr) {
echo str_replace(',', '<option value="'.$ss.'">', $vv .'</option>');
}
}
}
?>
</select>
allererst die 'mysqli_extension' als' mysql' verwenden ist veraltet ein! Und was ist Ihr Tabellenname, weil Sie ihn als ** Profil ** in der Abfrage und ** Benutzer_Tabelle ** in den Kommentaren erwähnt haben. – Anonymous
Was Sie haben, ist eine Datenbank, die dringend normalisiert werden muss. Erstellen Sie eine zweite Tabelle, in der Sie die ID des Benutzers/Arztes hinzufügen, eine Spalte für "no_ana" und eine für "name_pr" und übertragen Sie dann jede einzelne in eine Zeile. Auf diese Weise haben Sie drei von ihnen mit dem Benutzer verbunden, den Sie hier zeigen - alle mit der gleichen ID, aber unterschiedlichen "no_ana" und "name_pr" Inhalt. – junkfoodjunkie
Tabellenname ==> Profil –