I have built a drop down menu that is populated from an sql database. Each <option> includes 2 variables. I need to align each variable.
This example won't work, but illustrates what I am trying to do:
I built a php script that counts the first variable name and adds until it reaches 30 characters in length and then echos the second variable. My problem is that not all characters in the font are the same width so the results end up misaligned, but closer. Any ideas?
current function:
Thanks in advance!
This example won't work, but illustrates what I am trying to do:
Code:
<option value="value"><table><tr><td align="left">value1</td><td align="left">value2</td></tr></table></option>
I built a php script that counts the first variable name and adds until it reaches 30 characters in length and then echos the second variable. My problem is that not all characters in the font are the same width so the results end up misaligned, but closer. Any ideas?
current function:
Code:
function theaccts() {
$table = "accounts";
$conn = mysql_connect("$host", "$user", "$passwd");
mysql_select_db("$thedb", $conn);
$sql = "SELECT * FROM $table ORDER BY 'name'";
$result = mysql_query($sql, $conn);
$fields = mysql_num_fields ($result);
$rows = mysql_num_rows ($result);
$g='0';
while ($row = mysql_fetch_object ($result)) {
for ($i = 0; $i < $fields; $i++) {
$fname = mysql_field_name($result, $i);
if ($fname == 'ID') {
$id[$g] = $row->$fname;
} else if ($fname == 'type') {
$type[$g] = $row->$fname;
} else if ($fname == 'name'){
$name[$g] = $row->$fname;
}
} // end for
############## add spaces to the name ##########
for ($i='0'; $i<'30'; $i++) {
$a[$i] = substr($name[$g], $i, 1);
if ($a[$i] == NULL) {
$a[$i] = " ";
}
$name1[$g] .= $a[$i];
}
##################################################
$g++;
} // end while
$typesort = array("red", "black", "yellow", "orange", "peuce", "brown", "purple", "pink", "green", "magenta", "tan");
$p='0';
while ($p<'11'){
for ($z='0'; $z<count($id); $z++) {
if ($type[$z] == $typesort[$p]) {
echo "<option value=\"".$name[$z]."\">".$name1[$z]." $type[$z] </option>";
}
} // end for
$p++;
} // end while
} // end function
Thanks in advance!