PHP expert |
|
ten eerste, stop eens met zoveel HTML te printen met de echo functie...
ten tweede, spring beter in, zodat je sneller fouten ziet...
ten derde, gebruik assoc, het is sneller
opmerking: kan er wel value2 bestaan?
nu ga ik ff het script posten met bovenstaande regels en misschien de oplossing:
<?
require("config.php");
$query = mysql_query("SELECT * FROM members");
$result = mysql_num_rows($query);
$tmembers = mysql_num_rows(mysql_query("SELECT memberid FROM members"));
if(!$result){
?>
<div align="left">
<table border="0" width="451" height="350" cellspacing="0" cellpadding="0" style="border: 1px solid #000000">
<tr>
<td width="451" height="45" colspan="2" bgcolor="#575782">
<img border="0" src="imageslogopriveberichten.gif" width="250" height="54">
</td>
</tr>
<tr>
<td width="451" height="10" colspan="2" bgcolor="#C4C4D7">
<b><font face="Verdana" size="1"></font></b>
</td>
</tr>
<tr>
<td width="311" height="260" valign="top" style="background-image: url('images/bgpb.jpg'); background-repeat: no-repeat; background-attachment: fixed; background-position: left top" bgcolor="white">
<font face="Verdana" size="1" color="#000000">
<div align="left">
<table border="0" width="276" height="1" cellspacing="0" cellpadding="0">
<tr>
<td width="276" height="1" colspan="3"></td>
</tr>
<tr>
<td width="28" height="1">
<img border="0" src="images/Index/icoontjes/fout.gif" width="32" height="32">
</td>
<td width="4" height="1" valign="bottom">
</td>
<td width="236" height="1">
<b><font face="Verdana" size="1">We hebben nog geen members...</font></b>
</td>
</tr>
<tr>
<td width="276" height="1" colspan="3"></td>
</tr>
</table>
</div>
</td>
</tr>
<tr>
<td width="435" height="9" colspan="2" bgcolor="#434365">
<p align="center">
<b><font face="Verdana" size="1" color="#FFFFFF"></font></b>
</p>
</td>
</tr>
</table>
</div>
<?
} else {
?>
<font face="Verdana" size="1">Ontvanger:<br>
<select size="1" name="ontvangersselectie"
onMouseover="ddrivetip('Kies uit deze lijst de ontvanger van uw bericht.', 300)"
onMouseout="hideddrivetip()">
<?
while($aFetch = mysql_fetch_assoc($query)){
?>
<option value="<?= $aFetch['memberid']; ?>" value2="<?= $aFtech['username']; ?>"
<?
if($aFtech['webmaster']=="1"){
?>
style="background-color: #0000FF; color: #FFFFFF;">
<?
} else {
?>
style="background-color: #FF9933; color: #FFFFFF;">
<?= $aFtech['username']; ?>
</option>
<?
}
}
?>
</select>
<? require("config.php"); if(!$result){ ?> <div align="left"> <table border="0" width="451" height="350" cellspacing="0" cellpadding="0" style="border: 1px solid #000000"> <tr> <td width="451" height="45" colspan="2" bgcolor="#575782"> <img border="0" src="imageslogopriveberichten.gif" width="250" height="54"> </td> </tr> <tr> <td width="451" height="10" colspan="2" bgcolor="#C4C4D7"> <b><font face="Verdana" size="1"></font></b> </td> </tr> <tr> <td width="311" height="260" valign="top" style="background-image: url('images/bgpb.jpg'); background-repeat: no-repeat; background-attachment: fixed; background-position: left top" bgcolor="white"> <font face="Verdana" size="1" color="#000000"> <div align="left"> <table border="0" width="276" height="1" cellspacing="0" cellpadding="0"> <tr> <td width="276" height="1" colspan="3"></td> </tr> <tr> <td width="28" height="1"> <img border="0" src="images/Index/icoontjes/fout.gif" width="32" height="32"> </td> <td width="4" height="1" valign="bottom"> </td> <td width="236" height="1"> <b><font face="Verdana" size="1">We hebben nog geen members...</font></b> </td> </tr> <tr> <td width="276" height="1" colspan="3"></td> </tr> </table> </div> </td> </tr> <tr> <td width="435" height="9" colspan="2" bgcolor="#434365"> <p align="center"> <b><font face="Verdana" size="1" color="#FFFFFF"></font></b> </p> </td> </tr> </table> </div> <? } else { ?> <font face="Verdana" size="1">Ontvanger:<br> <select size="1" name="ontvangersselectie" onMouseover="ddrivetip('Kies uit deze lijst de ontvanger van uw bericht.', 300)" onMouseout="hideddrivetip()"> <? ?> <option value="<?= $aFetch['memberid']; ?>" value2="<?= $aFtech['username']; ?>" <? if($aFtech['webmaster']=="1"){ ?> style="background-color: #0000FF; color: #FFFFFF;"> <? } else { ?> style="background-color: #FF9933; color: #FFFFFF;"> <?= $aFtech['username']; ?> </option> <? } } ?> </select>
hopelijk werkt deze
bij $aFetch['username'] vul je de naam van de row in die in jouw db staat hé: bijv gebruikersnaam, username, usernaam etc...
een select kan als naam toch geen variabele hebben, hoe kan je hem anders gaan checken?
|