Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2010

    Unanswered: 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...


    $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>";

    <form action="manageuser.php" method="post">
    <table border="0">
    	<td rowspan="6">
    		<select size=10 name=userList mutiple>
    		<option value="fname">fname</option>
    		<option value="fname">fname</option>
    		<option value="fname">fname</option>
    		User ID: 
    note: the host dbname password etc are all changed, it not being 'localhost' is definately not my issue =P

    thanks in advance

  2. #2
    Join Date
    Sep 2009
    Provided Answers: 1
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts