If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > PHP > populaing a listbox

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-10-10, 16:07
mattman098 mattman098 is offline
Registered User
 
Join Date: Feb 2010
Posts: 1
populaing a listbox

Hi all, I've just started learning PHP so apologies if what I'm about to post is full on ridiculous but I'm definately stuck...

basically I'm trying to populate a listbox from a database in php myadmin, and I can do it fine jus using PHP but I'm wanting to run it through HTML as well, i dont know if i need to use _POST or _GET to make this work, or if there's some other method but any help will be appreciated, here's my code...

PHP

Code:
<?php
$con = mysql_connect("host", "database", "password"); 
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("dbname", $con);

$result = mysql_query("SELECT * FROM students");


echo "<table border='0'>";


echo "<tr>";
echo "<td rowspan=\"6\">";
echo "<select size=10 name=userList mutiple>";
while($row = mysql_fetch_array($result))
{
	echo "<option>$row[sname], $row[fname]</option>";
}
echo "</select>";
echo "</td>";
echo "</tr>";
echo "</table>";

mysql_close($con);
?>
HTML

Code:
<html>
<body>

<form action="manageuser.php" method="post">

<table border="0">

<tr>
	<td rowspan="6">
		<select size=10 name=userList mutiple>
		<option value="fname">fname</option>
		<option value="fname">fname</option>
		<option value="fname">fname</option>
		</select>	
	</td>
	<td>
		User ID: 
	</td>
</tr>
</form>
</body>
</html>
note: the host dbname password etc are all changed, it not being 'localhost' is definately not my issue =P

thanks in advance
Reply With Quote
  #2 (permalink)  
Old 02-10-10, 17:48
kitaman kitaman is offline
Registered User
 
Join Date: Sep 2009
Location: Ontario
Posts: 526
Either POST or GET will work, the difference is in how you handle the data when you receive it at server (the action process).

POST is more secure.
POST is the equivalent of standard input
GET is the equivalent of a command line variable.

If you run this through a web server you should also look at the session_id() function.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On