Jump to content

[SOLVED] Shed some light on this Please


phatgreenbuds

Recommended Posts

First I apologize if this has been asked a thousand times before.  If it has please feel free to point me to the link...I searched but could not find anything most likely because I do not know what to search for.

I have a simple database that lists names within it.  I am trying to get a page with a drop down that will query that table and display the names for selection.  Below is what I thought to be right but turns out I am wrong AGAIN.  Any ideas?

[code]<html>
<head>
<title>test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head>

<div align="center"><table width="50%" border="0" align="center">
<tr> 
  <td><SELECT id="id1" name="Name" style="width:150px">
<?PHP
$con = mysql_connect ("localhost", "root", "me");
if (!$con)
{
die('Could Not Connect: ' . mysql_error());
}
mysql_select_db ("test", $con);

$query="SELECT name
FROM users";

$results=mysql_query($query)
or die(mysql_error());

while ( $rows = mysql_fetch_array($result) ){
foreach ($rows as $value) {
echo '<OPTION value= "'. $row['name'] .'"> '. $row['name'] .' </OPTION>'."\r\n";
}
}
?>
</SELECT></div></p>&nbsp;</td>


    <td><form method="post" action="http://localhost/testsite/srepadd.php">
<div align="center"><p>Blah Blah: <br>
<input type="text" name="srid"></div></p>&nbsp;</td>

</tr></table>


</form>
<br>
</div></html>[/code]
Link to comment
https://forums.phpfreaks.com/topic/33014-solved-shed-some-light-on-this-please/
Share on other sites

so now it looks like this:

[quote]  <td><SELECT id="id1" name="Name" style="width:150px">
<?PHP
$con = mysql_connect ("localhost", "root", "blaine");
if (!$con)
{
die('Could Not Connect: ' . mysql_error());
}

mysql_select_db ("test", $con);
$query="SELECT name FROM users";

$results=mysql_query($query)
or die(mysql_error());

while ( $row = mysql_fetch_array($result) ){

echo '<OPTION value= "'. $row['name'] .'"> '. $row['name'] .' </OPTION>'."\r\n";
}

?>
</SELECT></div></p>&nbsp;</td>[/quote]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.