database query advise
am 05.04.2011 21:18:03 von Chris StinemetzHello All,
I am fairly new to the PHP and MySQL world and I was wondering if you
could offer some advise or tutorials that may help me achieve my
objectives.
My code is pasted on the far bottom.
I currently have a form page and results page.
The first thing I would like to do is combine the form page with the
results so that a new page isn't opened when the end user hits the
submit.
The second is how do I change my javascript form script so that the
second and third menu is hidden until the prior menu is selected.
The third is: How can I use PHP ternary instead of my current if else
on the form page?
The fourth is: How can I alter my results page so that the records can
me edited. For example once the query is submitted and the results are
displayed. I would like to edit any field in any record and submit the
changes back to the database. Is this possible??
Thank you in advance!
Chris
form page below:
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
require "../PHP_Scripts/config.php"; // Your Database details
?>
type something
///////// Getting the data from Mysql table for first list box//////////
$market=mysql_query("SELECT DISTINCT market FROM sector_list ORDER BY
market DESC");
/////// for second drop down list we will check if market is selected
else we will display all the cell_sectors/////
$term=$_GET['term']; // This line is added to take care if your global
variable is off
if(isset($term) and strlen($term) > 0)
{
$cellSect=mysql_query("SELECT DISTINCT cell_sect FROM sector_list
where market like '%$term' order by cell_sect");
}
else
{
$cellSect=mysql_query("SELECT DISTINCT cell_sect FROM sector_list
order by cell_sect"); }
////////// end of query for second subcategory drop down list box
///////////////////////////
$term3=$_GET['term']; // This line is added to take care if your
global variable is off
/////// for Third drop down list we will check if cell_sect is
selected else we will display all the dates/////
if(isset($term3) and strlen($term3) > 0)
{
$date=mysql_query("SELECT DISTINCT date FROM evdo WHERE market LIKE
'%$term' ORDER BY date DESC");
}
else
{
$date=mysql_query("SELECT DISTINCT date FROM evdo ORDER BY date");
}
////////// end of query for third subcategory drop down list box
///////////////////////////
echo "";
?>
results page below:
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
require ("config.php"); // Your Database details
?>
$term=$_POST['term'];
$term2=$_POST['term2'];
$term3=$_POST['term3'];
# your orignal that just pulls the market data
#$result = mysql_query("select * FROM evdo WHERE Market like '%$term'
LIMIT 20");
#this pulls the cell_sect assigned to market
$result = mysql_query("select * FROM evdo WHERE Market like '%$term'
and Cell_Sect = '$term2' ORDER BY date desc LIMIT 96");
#This pulls the cell_sect on given date and market
#$result = mysql_query("select * FROM evdo WHERE Market like '%$term'
and Cell_Sect = '$term2' and Date = '$term3'");
# you need to modify the first page to autopopulate the cell_sect and
date option boxes
# so it only list the cells applicable to a market on a given day
$firstRow=1;
$rowNum = 0;
echo "
" . $key . " | ";
---|
" . $value . " | " ;
echo "You Selected the following:
Market = $term
Cell_Secter =
$term2
Timestamp = $term3";
?>
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php