Hi there ..... having a bit of a problem, I have a drop down menu,
populated from my database and it works fine , see here below ....
<?php
$username = "username";
$password = "password";
$hostname = "localhost";
$dbh = mysql_connect($hostname, $username, $password)
or die("Unable to connect to MySQL");
$selected = mysql_select_db("database",$dbh)
or die("Could not select my database");
function generate_box() {
$sql = "SELECT ClubNo, ClubName FROM club";
$result = mysql_query($sql) or die(mysql_error());
$entries = mysql_num_rows($result);
$options = '<option value="-1"></option>';
while($row = mysql_fetch_assoc($result)) {
$options .= "<option value=\"{$row['ClubNo']}\">{$row['ClubName']}</option>";
}
return $options;
}
$options = generate_box();
?>
And this is the HTML ..... when i used "Get" instead of "Post" it
passed the selection along with the URL so that works
<table>
<form method="post" name="forum_select" action="result.php"> <table cellspacing="0" cellpadding="0" border="0">
<tr><td border="1"><span>Select a club from the drop down list: <br>
<select name="by">
<? echo "$options"; ?>
<input type="submit" value="Submit"></span>
And heres the problem
i dont know if it is running the SELECT below, .... i dont know if $result gets the data from the query
and i need it to show those results (via the echo in the WHILE part) when displayed on result.php
I dont know how to tell it where on result.php it is meant to go either ??
something like <?php echo $_result; ?> i'd imagine but that is wrong i think ??
<?Php
if ($_REQUEST['submit'] == 'Submit') {
$username = "username";
$password = "password";
$hostname = "localhost";
$dbh = mysql_connect($hostname, $username, $password)
or die("Unable to connect to MySQL");
$selected = mysql_select_db("database",$dbh)
or die("Could not select my database");
$clubID = $_POST['Clubno'];
$result=mysql_query("SELECT ClubName, DomesticLeague, TelePhoneNo, FaxNo, EmailAddress, Website, Groundno, YearEstablished,
Status, ManagerNo, CoachNo FROM club WHERE Clubno=$clubID");
while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) {
echo "Club Name: {$row['ClubName']} <br> League: {$row['DomesticLeague']} <br> Telephone: {$row['TelePhoneNo']} <br> Fax No.:
{$row['FaxNo']} <br> Email: {$row['EmailAddress']} <br> Website: {$row['Website']} <br> GroundNo: {$row['GroundNo']} <br>
Established: {$row['YearEstablished']} <br> Status: {$row['Status']} <br> ManagerNo: {$row['ManagerNo']} <br> CoachNo:
{$row['CoachNo']} <br>";
}
}
?>
Can someone help ..... but bare in mind .... i am new to Php !!