???passing a query from a form???
From: Joe (t3463_at_hotmail.com)
Date: 03/29/04
- Previous message: Riddic: "Re: Why are comments preceeded by // not ignored?"
- Next in thread: Riddic: "Re: ???passing a query from a form???"
- Reply: Riddic: "Re: ???passing a query from a form???"
- Reply: Eric Bohlman: "Re: ???passing a query from a form???"
- Reply: Ruby Tuesdays: "Re: ???passing a query from a form???"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 28 Mar 2004 17:11:54 -0800
I have wrote a script to query my mysql database based up a name that
is selected from an HTML list menu, the form action calls to my php
script from my html doc, I have tested connectivity to the databse and
have added a manual sql query to my php script to be sure it is
functioning properly, the problem is I'm not sure how to get the
script to see what option the html form is sending, I thought I could
use:
$query = "SELECT * FROM table WHERE email =
'{$_GET['selecteduser']}@mydomain.com'";
but that doesn't seem to be working properly. Maybe the HTML document
is sending it correctly? Here is my form:
<form action="report_results.php" method="post">
<select name="selecteduser">
<option value="selecteduser">Select One:</option>
<option value="user1@mydomain.com">user1</option>
<option value="user2@mydomain.com">user2</option>
</select>
<input type="submit" name="submit" value="Go!">
</form>
This form calls to the php script which then takes the input from the
HTML form and processes it into the $_GET query and sends it to the
while loop in the script, I'm not sure why this is not working? Here
is my php code:
PHP:
--------------------------------------------------------------------------------
<?php
$db = mysql_connect("localhost", "sqluser", "sqlpasswd") or
die("Could not connect to Mysql");
if (!$db == False)
{
mysql_select_db("mydb");
$query = "SELECT * FROM table WHERE email =
'{$_GET['selecteduser']}@mydomain.com'";
$result = mysql_query($sql,$db);
while ($row = mysql_fetch_row($result))
{
print "<tr>";
foreach ($row as $field)
{
print "<td>$field</td>";
}
print "</tr>";
}
mysql_close($cn);
}
else
{
print "Problem Connecting to the Database<br>";
}
?>
--------------------------------------------------------------------------------
Does anyone have any suggestions??
Thanks
- Previous message: Riddic: "Re: Why are comments preceeded by // not ignored?"
- Next in thread: Riddic: "Re: ???passing a query from a form???"
- Reply: Riddic: "Re: ???passing a query from a form???"
- Reply: Eric Bohlman: "Re: ???passing a query from a form???"
- Reply: Ruby Tuesdays: "Re: ???passing a query from a form???"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|