<select>
<option<?php if($option = "volvo" ){ echo "selected=\"selected\" " } ?> value ="volvo">Volvo</option>
<option <?php if($option = "saab"){ echo "selected=\"selected\" "} ?>value ="saab">Saab</option>
<option <?php if($option = "opel" ){ echo "selected=\"selected\" " } ?>value ="opel">Opel</option>
<option <?php if($option = "audi" ){ echo "selected=\"selected\" " } ?> value ="audi">Audi</option>
</select>
Reference
<?php
$dbHost = "localhost";$dbUser = "USERNAME";$dbPass = "PASSWORD";$dbname = "dbcarselect";$db = mysql_connect($dbHost,$dbUser,$dbPass);mysql_select_db($dbname,$db);
$sql1 = mysql_query("SELECT * FROM tbluser ORDER BY uname ASC");
echo '<html>
<head>
<title>Car DB</title>
</head>
<body>';
while($row1 = mysql_fetch_array($sql1)) { $uID = $row1['uID']; $cID = $row1['cID']; $uname = $row1['uname'];
$sql2 = mysql_query("SELECT * FROM tblcars ORDER BY cmake ASC"); echo 'Name: '.$uname.' - Car: <select name="cmake">'; while($row2 = mysql_fetch_array($sql2)) { echo '<option ' . ($cID==$row2['cID'] ? 'selected' : '') . ' value="'.$row2['cID'].'">'.$row2['cmake'].'</option>'; } echo '</select><p />';
}
echo '</body>
</html>';?>
<option<?php if($option = "volvo" ){ echo "selected=\"selected\" " } ?> value ="volvo">Volvo</option>
<option <?php if($option = "saab"){ echo "selected=\"selected\" "} ?>value ="saab">Saab</option>
<option <?php if($option = "opel" ){ echo "selected=\"selected\" " } ?>value ="opel">Opel</option>
<option <?php if($option = "audi" ){ echo "selected=\"selected\" " } ?> value ="audi">Audi</option>
</select>
Reference
<?php
$dbHost = "localhost";$dbUser = "USERNAME";$dbPass = "PASSWORD";$dbname = "dbcarselect";$db = mysql_connect($dbHost,$dbUser,$dbPass);mysql_select_db($dbname,$db);
$sql1 = mysql_query("SELECT * FROM tbluser ORDER BY uname ASC");
echo '<html>
<head>
<title>Car DB</title>
</head>
<body>';
while($row1 = mysql_fetch_array($sql1)) { $uID = $row1['uID']; $cID = $row1['cID']; $uname = $row1['uname'];
$sql2 = mysql_query("SELECT * FROM tblcars ORDER BY cmake ASC"); echo 'Name: '.$uname.' - Car: <select name="cmake">'; while($row2 = mysql_fetch_array($sql2)) { echo '<option ' . ($cID==$row2['cID'] ? 'selected' : '') . ' value="'.$row2['cID'].'">'.$row2['cmake'].'</option>'; } echo '</select><p />';
}
echo '</body>
</html>';?>
Great post.
ReplyDeletehttps://forums.vwvortex.com/member.php?3718309-KareefAbdul
Great post.
ReplyDeletehttps://www.walleyecentral.com/forums/member.php?u=301526
Great post.
ReplyDeletehttps://speakerdeck.com/albertmccarthy