sig
05-03-2006, 09:55 PM
Anyone that knows php:
Small (simple) project from a novice:
I want to have a page refresh the data based on a drop down. I know little php, but it's what my sever supports.
I have the mysql table with data already and I have gotten as far as having my dropdown update from the table (cool)
here is my code:
<?
$db_username = "mydbname"; // I chaged the real thing here...
$db_password = "mypw";
$db_hostname = "mysql.mysite.com";
$db_connect = mysql_connect($db_hostname, $db_username, $db_password)or die("Unable to connect to MySQL");
$db_select = mysql_select_db("mydb", $db_connect)or die("Unable to select Database");
// below is where I have the dropdown get options from a field "team1"
$result = mysql_query("SELECT DISTINCT `team1`,'team2' FROM `sg1`WHERE `team1` NOT LIKE '%bye%' ORDER BY `team1` ASC ");
echo "<select name=home1 value=''>Home1</option>";
while($nt=mysql_fetch_array($result)){//Array or records stored in $nt
echo "<option value=$nt[team2]>$nt[team1]</option>";
/* Option values are added by looping through the array */
}
echo "</select><br>";// Closing of list box
// lost from here: how do I have the above dropdown output based on it's value
$result = mysql_query("select * from sg1");
while ($row = mysql_fetch_array($result)) {
echo "Match Start Date: $row[start_date]<br>Playing Dates: $row[match_dates] <br> Zone Details: $row[zone] Group: $row[zone_tittle]<br> Home Team: $row[team1] vs. $row[team2] at Grounds: $row[ground]<br><br><br>";
}
mysql_close($db_connect);
So all I want is to have the user select a couple dropdowns and have the data output based on the selections....
any help is a lot of help... Thanks. :cool:
Small (simple) project from a novice:
I want to have a page refresh the data based on a drop down. I know little php, but it's what my sever supports.
I have the mysql table with data already and I have gotten as far as having my dropdown update from the table (cool)
here is my code:
<?
$db_username = "mydbname"; // I chaged the real thing here...
$db_password = "mypw";
$db_hostname = "mysql.mysite.com";
$db_connect = mysql_connect($db_hostname, $db_username, $db_password)or die("Unable to connect to MySQL");
$db_select = mysql_select_db("mydb", $db_connect)or die("Unable to select Database");
// below is where I have the dropdown get options from a field "team1"
$result = mysql_query("SELECT DISTINCT `team1`,'team2' FROM `sg1`WHERE `team1` NOT LIKE '%bye%' ORDER BY `team1` ASC ");
echo "<select name=home1 value=''>Home1</option>";
while($nt=mysql_fetch_array($result)){//Array or records stored in $nt
echo "<option value=$nt[team2]>$nt[team1]</option>";
/* Option values are added by looping through the array */
}
echo "</select><br>";// Closing of list box
// lost from here: how do I have the above dropdown output based on it's value
$result = mysql_query("select * from sg1");
while ($row = mysql_fetch_array($result)) {
echo "Match Start Date: $row[start_date]<br>Playing Dates: $row[match_dates] <br> Zone Details: $row[zone] Group: $row[zone_tittle]<br> Home Team: $row[team1] vs. $row[team2] at Grounds: $row[ground]<br><br><br>";
}
mysql_close($db_connect);
So all I want is to have the user select a couple dropdowns and have the data output based on the selections....
any help is a lot of help... Thanks. :cool: