Forum Moderators: coopster
while (odbc_fetch_row($rs))
$teamsize[]=odbc_result($rs,'teamsize');
{
$tsdropdown .=<<<HTML
<select name="teamsize">
<option value="All">All</option>
$options="<option value="$teamsize">$teamsize v $teamsize</option>";
echo "$options";
</select>
HTML;
}
This works great BUT it only displays the number 3. I want it to highlight the number 3 but also contain the other options also (1-20). p.s. im using odbc
please help!
$options = '';
while (odbc_fetch_row($rs))
$teamsize[]=odbc_result($rs,'teamsize');
{
$options .= "<option value="$teamsize">$teamsize v $teamsize</option>";
}
$tsdropdown =<<<HTML
<select name="teamsize">
<option value="All">All</option>
echo "$options";
</select>
HTML;
$tsdropdown =<<<HTML
<select name="teamsize">
<option value="All">All</option>
echo "$options";
</select>
HTML;
Ugh. Sorry. Try that. Didn't read the code I posted very well.
$dvd_case_color_selector.= "<select name=\"case_color\" size=\"1\" class=\"menu\">\n";
$dvd_case_color_selector.= "<option value=\"\">select</option>";
{
//query database to see what CASE COLOR the dvd has so it can be pre-selected in html select object
mysql_select_db('db');
$query = 'SELECT case_color FROM dvds'." WHERE id LIKE '$id'";
$result = mysql_query($query) or die ("Error in query: $query " . mysql_error());
$myresult = mysql_fetch_array($result);
if (empty($_POST['case_color'])){
$dvd_case_color_selected= $myresult['case_color'];
}
if (isset($_POST['case_color'])){
$dvd_case_color_selected= $_POST['case_color'];
}
//another query to see what color the user is allowed to select as case color for dvd's
$query2 = 'SELECT DISTINCT dvd_case_color FROM selectors WHERE dvd_case_color IS NOT NULL ORDER BY dvd_case_color ASC';
$result2 = mysql_query($query2) or die ("Error in query: $query2 " . mysql_error());
while ($myresult2 = mysql_fetch_array($result2)) // loop through and add each color to dvd_cases array
{
$dvd_cases[]= $myresult2;
}
foreach ($dvd_cases as $dvd_case)
{
// build the options...
$dvd_case_color_selector.= "<option value=\"$dvd_case[0]\"";
// highlight the currently associated case color
if ($dvd_case[0] == $dvd_case_color_selected)
{$dvd_case_color_selector.= " selected ";}
$dvd_case_color_selector.= ">$dvd_case[0]</option>\n";
}
// close the select tags
$dvd_case_color_selector.= "</select>"; }
next just use a echo $dvd_case_color_selector; where u need it :)
edit: sorry, missed the part where u arent using mysql...but the basics remain the same, just modify the queries etc
$data_cells="";
$data_cells .=<<<HTML
<option value="$teamsize">$teamsize v $teamsize</option>
<option>------</option>
HTML;
I then used
<select name=\"teamsize\" >
$data_cells
<option value=\"1\">1v1</option>
<option value=\"2\">2v2</option>
<option value=\"3\">3v3</option>
<option value=\"4\">4v4</option>
<option value=\"5\">5v5</option>
<option value=\"6\">6v6</option>
<option value=\"7\">7v7</option>
<option value=\"8\">8v8</option>
<option value=\"9\">9v9</option>
<option value=\"10\">10v10</option></select>
Not sure if this still is actual, if it is, do write to me...
I have just made a selection for my self, the code is like this':
$query = mysql_query("SELECT id,navn FROM stambog WHERE sex='M' ORDER BY navn");
echo "<tr><td>Father: </td><td><SELECT NAME=\"father_id\">\n";
echo "<OPTION SELECTED VALUE=\"$father_id\">Choose Father</OPTION>\n";
while ($row = mysql_fetch_array($query)) {
$fid = $row['id'];
$fnavn = $row['navn'];
echo " <option value=\"$fid\">$fnavn</option>\n";
}
echo "</SELECT></td></tr><br>\n";
As you can see, I show the name of the cat, but update the database with the ID.
The Option selected value is here "Choose father", but could be any variable, in your case a variable containing #3..
I hope, this could be used..
Regards from Denmark
i have a country table that holds 5 different countries. a dropdown list in my form is populated based on this table. the problem is i want the country stored in the member table to be the default selected in the list . this is the code i tried:
<select name=CountryFrm>
<?php
$qry = "SELECT CountryName FROM Country ORDER BY CountryName";
$result = mysql_query($qry);
while($row = mysql_fetch_assoc($result))
{
$CountryNameFrm = $row['CountryName'];
echo '<option value="'.$row[CountryName].'" CountryFrm selected>'.$row[CountryName].'</option>';
}
?>
</select>
Can anybody help
Thanks in Advanced
Scoobie
<option value="'.$row[CountryName].'" CountryFrm selected>'.$row[CountryName].'</option>';
if your $row[CountryName] was Canada it would look like this
<option value="Canada" CountryFrm selected>Canada</option>
that syntax is a bit messed, your list would all be selected and I am not sure what CountryFrm is doing there.
you need something to compare the country to so you can echo selected for the appropriate option
Have you tried posting your question in the WYSIWYG and Text Code Editors [webmasterworld.com] Forum?