PHP - Want 2 Values From Db In Drop Down.
I've got two tables (classOfferings, instructors). The fields I'm dealing with are 'co.instructorId', 'i.instructorId', 'i.fName', 'i.lName'.
I have a form with dynamically generated drop downs. What I would like to do is check classOfferings table to see which instructors are teaching classes then display them in drop down with the 'instructorId' as the value and 'fName' and 'lName' as the user selectable part. So I have found the distinct 'instructorId', but I can't make 'fName' and 'lName' appear as the user selectable part. The code below produces a drop down which has invisible values, but still posts a value. <select size="1" name="instructor"> <option value="" selected>Search By Teacher...</option> <? $instrList=mysql_query("select distinct instructorId from classOfferings order by instructorId asc"); $instrNameList=mysql_query("select fName, lName from instructors where classOfferings.instructorId = instructors.instructorId order by lName asc"); // Show records by while loop. while($instructor_list=mysql_fetch_assoc($instrList)){ $instrNames = ($instr_Name['fName']) . ($instr_Name['lName']); ?> <option value="<? echo $instructor_list['instructorId']; ?>" <? if($instructor_list['instructorId']==$select){ echo "selected"; } ?>> <? echo $instrNames; ?></option> <? // End while loop. } ?> </select> Similar Tutorials
Table Issue - Multiple Location Values For User Pushes Values Out Of Row Instead Of Wrapping In Cell
i'm trying to print out values from a table into a drop down box, but my code doesnt seem to work. when i test it, there are no values in the drop down box. if someone could find the problem, that would be great. <form name="add_sub_section" method="post" action="<?php echo $_SERVER['../PHP_SELF']; ?>"> Sub Section Name <input type="text" name="sub_section_title" maxlength="200" /><br/><br/> Sub Section desc <textarea name="sub_section_desc" rows="4" columns="30" /></textarea><br/><br/> SECTION <?php $list = "SELECT section_title FROM section_main"; echo "<select name='section_title'>"; while ($a = mysql_fetch_row($list)) { for ($j = 0; $j < mysql_num_fields($list); $j++) { echo "<option value=". $a[$j] . ">". $a[$j] . "</option>"; } } echo "</select>"; ?> <br/><br/> <input type="submit" name="submit" value="Add Section"/> </form> the connection to the table works, so i havnt put that code in. there's no formatting for the html yet, i just want to get the php working first Thanks Hi all, I'm just wondering if there's an easier way of doing what accomplishing the following: I have a value in my database which represents a selection in a drop down menu, i want to read it from the database and have it automatically selected depending on the stored data. I have the following working but just wondered if there was an easier way to get the same result: Code: [Select] <?php //database connection $query = "SELECT id FROM `tablename` WHERE username='$username'"; $result = mysql_query($query); $row = mysql_fetch_object($result); $id = $row->id; $id = (int)$id; ?> <select name="id"> <option value="">Select your option...</option> <option value="1" <?php if (($id - 1) === 0) { echo 'selected="selected"'; }?>>Selection 1</option> <option value="2"<?php if (($id - 2) === 0) { echo 'selected="selected"'; }?>>Selection 2</option> </select> Sorry if it's not very clear, i'll explain best i can if anyone can help. Thanks I am trying to make a Web Form for people to fill out that has two drop down menus where i want the first drop down menu's selection changes the values of the selections in the second drop down. ((IE. If the first drop down value is "product 01" then the second drop down shows values "Red, Green, Blue" while if the first drop down value is "product 02" then the second drop down shows values "Yellow, Green")) Anyone have any ideas? Thanks in Advance. I have several drop down boxes. When submit is clicked it execute query on another page. Problem is when submit is clicked selected values are return to defaults. Is it possible for the values to be remembered after submitting them? Part of the drop down code: Code: [Select] <?php $result = mysql_query("SELECT * FROM product GROUP BY Rim"); ?> <select id="Rim" name="Rim" selected="selected" style="width:158px;position:static;z-index:-1;"> <option value="rim" selected="selected"><?php echo "Rim"; ?></option> <?php while ($row = mysql_fetch_array($result)) { echo "<option>" . $row['Rim'] . "</option>"; echo "<br />"; } ?> </select> Hi guys, I had a problem before which is similar to the problem im about to describe, however Pikachu helped me solve the last problem so a big thanks to him! However this problem is slightly different and im struggling to find a solution. I will first describe the problem I had which pikachu helped me solve as it would be easier for me to describe this past problem. I have an update form, so a user can edit existing records which are pulled from a database. When the user changes the values in a text field then submits the form, the values in the text fields updates fine. However if they change the values in the text box and then tries to submit the form but there was an error, the values in the text fields go back to the values from the database and the user has to change the text fields again. Well this problem was solved with the help of pikachu and the this is what I did... <?php if(isset($_POST['title'])){echo htmlspecialchars($_POST['title']);} else if (isset($title)) {echo htmlspecialchars($title);}?> Again, the above works fine however the problem I have now is the same problem as described above however it relates to drop down menus and not text fields. I can't seem to figure out how to retain the values in a drop down menu the same way I have for text fields. Below is the code that im using that I thought would work however it isnt working, the values of the drop down menu (if there was an error) are going back to the values from the database. Heres the code... <option value="Psychopathic" <?php if ((isset($_POST['category']))&&($_POST['category'] == 'Psychopathic')) { echo ' selected=selected'; } else if ((isset($category))&&($category == 'Psychopathic')) { echo ' selected=selected'; } ?>>Psychopathic</option> Does anybody know what i am doing wrong and how i can fix this problem? I understand what i need to do but i cant seem to get the code to do what i want to do and thats to retain values of a drop down menu when the page is returned with an error. Any help would be much appreciated. AJay Basically, I have a database table called 'users' and I would like to populate a drop down box with these values of 'users'. How?? - to call upon the values is this: 'upduser2' Right now, all I am using is a text box, in where you have to type in the users name manually (this is so an admin can change variables and settings according to that current user). This is what I am using so far: <h3>Update User Level</h3> <? echo $form->error("upduser"); ?> <table> <form action="adminprocess.php" method="post"> <tr> <td> Username:<br /> <input type="text" name="upduser" maxlength="30" value="<? echo $form->value("upduser"); ?>" /></td> <td> Level:<br /> <select name="updlevel"> <option value="1">1 </option> //example settings <option value="9">9 </option> </select></td> <td><br /> <input type="hidden" name="subupdlevel" value="1" /> <input type="submit" value="Update Level" /></td> </tr> </form> </table></td> </tr> Much help would be appreciated. Hi guys, Im currently doing a project for college and i have experienced some problems with saving my php drop down values to my database. im am getting no error but my values are not being stored to my db.If anyone could help me or point me in the correct direction then id be grateful. Ive attached my code. Ive been scanning over and over this code and I cant work out why my 2nd drop down menu doesnt have unique values. Please if anyone can give me guidance, you never know I may be able to get rid of my headache! Code: [Select] <body> <p> <form action="" method="post"> <select name="drop_1" id="drop_1"> <option value="" selected="selected" disabled="disabled">Select a Category</option> <?php getTierOne(); ?> </select> <span id="wait_1" style="display: none;"> <img alt="Please Wait" src="ajax-loader.gif"/> </span> <span id="result_1" style="display: none;"></span> </form> </p> <p> <?php if(isset($_POST['submit'])){ $drop = $_POST['drop_1']; $tier_two = $_POST['Subtype']; echo "You selected "; echo $drop." & ".$tier_two; } ?> </body> Code: [Select] <?php function getTierOne() { $result = mysql_query("SELECT DISTINCT Type FROM business") or die(mysql_error()); while($tier = mysql_fetch_array( $result )) { echo '<option value="'.$tier['Type'].'">'.$tier['Type'].'</option>'; } } if($_GET['func'] == "drop_1" && isset($_GET['func'])) { drop_1($_GET['drop_var']); } function drop_1($drop_var) { include_once('db.php'); $result = mysql_query("SELECT DISTINCT Subtype FROM business WHERE Type='$drop_var'") or die(mysql_error()); echo '<select name="Subtype" id="Subtype"> <option value=" " disabled="disabled" selected="selected">Choose one</option>'; while($drop_2 = mysql_fetch_array( $result )) { echo '<option value="'.$drop_2['Subtype'].'">'.$drop_2['Subtype'].'</option>'; } echo '</select> '; echo '<input type="submit" name="submit" value="Submit" />'; } ?> I'm simply trying to set up a form where, if when a user clicks 'Submit', and then 'Back', the values from the form are preserved. My question is, how do I preserve the values of drop down menus. The following is a snippet of my code: Code: [Select] <select name="dropdown_dept" id="dept_list"> <option value=0><?php echo "Please select one..."?></option> <?php $dropdown_dept = "select dept_name from departments"; $result_dept = $db_conn->query($dropdown_dept); if (!$result_dept) { echo '<p>Unable to get department data.</p>'; return false; } for($i=0; $i<$result_dept->num_rows; $i++) { $app_name_row = $result_dept -> fetch_array(); ?> <option><?php echo($app_name_row[0]); ?></option> <? } ?> </select> Above is where I have set up a drop down menu of departments. Given that code, how can I preserve the department name after a user clicks 'Submit'? GREAT this forum - JUST GREAT !... Issue: All data entered into my online form was lost (blanked out) and the form returned correctly with message "wrong verification code", when submitted with the wrong verification code. However, going through this great forum I managed to get all - manually entered - data back ! I placed value="<?php echo $_GET['the_field_name'];?>"/ after each input field. BUT... not so with input fields entered from drop-down menu ! How do I put a similar string for the field "Payment by" in this sample: <tr> <td class="table-inquire" width="47%"> <font face="Verdana" size="1" color="#000042"> Payment by:</font></td> <td class="table-inquire" width="51%" colspan="2"> <font color="#400000" face="Verdana"> <select name="payment" size="1"> <option value="VISA">VISA</option> <option value="MASTER">MASTER</option> <option value="CASH">CASH</option> <option value="T/T Banktransfer">T/T Banktransfer</option> <option selected>Please select</option> </select></font><font size="2" color="#400000" face="Verdana"></font></td> </tr> Any advise greatly appreciated. Thanks. Hi i have this drop down list for date which contain 3 selects DAY MONTH YEAR hwo can i make so that when update form select keeps the same value has before help please <?php $months = array('','January','February','March','April','May','June','July','August','September','October','November','December'); echo '<select name="month_of_birth">'; for ($i=1;$i<13;++$i) { echo '<option value="' . sprintf("%02d",$i) . '">' . $months[$i] . '</option>'; } echo '</select>'; echo '<select name="day_of_birth">'; for ($i=1;$i<32;++$i) { echo '<option value="' . sprintf("%02d",$i) . '">' . $i . '</option>'; } echo '</select>'; echo '<select name="year_of_birth">'; $year = date("Y"); for ($i = $year;$i > $year-50;$i--) { $s = ($i == $year)?' selected':''; echo '<option value="' . $i . '" ' . $s . '>' . $i . '</option>'; } echo '</select>'; ?> Hello all Ok here is the problem... I want when a user inputs the requested data to the text fields , the script to insert those data in the prope table depending on the choise the user does by choosing one option from the drop down menu. Below is the php code (apparently not working) $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } $site_type = $_REQUEST['category_selection']; if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "link_submission") && ($site_type = "Web_Sites")) { $insertSQL = sprintf("INSERT INTO partner_sites (url, url_title, anchor_text, `description`, webmaster_name, webmaster_email, category) VALUES (%s, %s, %s, %s, %s, %s, %s)", GetSQLValueString($_POST['url_field'], "text"), GetSQLValueString($_POST['title_field'], "text"), GetSQLValueString($_POST['anchor_field'], "text"), GetSQLValueString($_POST['description_field'], "text"), GetSQLValueString($_POST['webmaster_nane_field'], "text"), GetSQLValueString($_POST['webmaster_email_field'], "text"), GetSQLValueString($_POST['category_selection'], "text")); mysql_select_db($database_content_conn, $content_conn); $Result1 = mysql_query($insertSQL, $content_conn) or die(mysql_error()); } if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "link_submission") && ($site_type = "Blogs")) { $insertSQL = sprintf("INSERT INTO partner_blogs (url, url_title, anchor_text, `description`, webmaster_name, webmaster_email, category) VALUES (%s, %s, %s, %s, %s, %s, %s)", GetSQLValueString($_POST['url_field'], "text"), GetSQLValueString($_POST['title_field'], "text"), GetSQLValueString($_POST['anchor_field'], "text"), GetSQLValueString($_POST['description_field'], "text"), GetSQLValueString($_POST['webmaster_nane_field'], "text"), GetSQLValueString($_POST['webmaster_email_field'], "text"), GetSQLValueString($_POST['category_selection'], "text")); mysql_select_db($database_content_conn, $content_conn); $Result1 = mysql_query($insertSQL, $content_conn) or die(mysql_error()); } if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "link_submission") && ($site_type = "Directories")) { $insertSQL = sprintf("INSERT INTO partner_directories (url, url_title, anchor_text, `description`, webmaster_name, webmaster_email, category) VALUES (%s, %s, %s, %s, %s, %s, %s)", GetSQLValueString($_POST['url_field'], "text"), GetSQLValueString($_POST['title_field'], "text"), GetSQLValueString($_POST['anchor_field'], "text"), GetSQLValueString($_POST['description_field'], "text"), GetSQLValueString($_POST['webmaster_nane_field'], "text"), GetSQLValueString($_POST['webmaster_email_field'], "text"), GetSQLValueString($_POST['category_selection'], "text")); mysql_select_db($database_content_conn, $content_conn); $Result1 = mysql_query($insertSQL, $content_conn) or die(mysql_error()); } And the html form <form action="<?php echo $editFormAction; ?>" method="POST" enctype="multipart/form-data" name="link_submission" id="link_submission"> <table width="630" border="0" align="center" cellpadding="5" cellspacing="5"> <tr> <td width="76">URL:*</td> <td width="519"><label for="url_field"></label> <span id="sprytextfield1"> <label for="url_field"></label> <input name="url_field" type="text" id="url_field" size="50" /> <span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span></td> </tr> <tr> <td>Anchor Text:*</td> <td><label for="anchor_field"><span id="sprytextfield2"> <input type="text" name="anchor_field" id="anchor_field" /> <span class="textfieldRequiredMsg">A value is required.</span></span></label></td> </tr> <tr> <td>URL Title:*</td> <td><label for="title_field"><span id="sprytextfield3"> <input type="text" name="title_field" id="title_field" /> <span class="textfieldRequiredMsg">A value is required.</span></span></label></td> </tr> <tr> <td>Description:*</td> <td><span id="sprytextarea1"> <label for="description_field"></label> <textarea name="description_field" id="description_field" cols="45" rows="3"></textarea> <span id="countsprytextarea1"> </span><span class="textareaRequiredMsg">A value is required.</span><span class="textareaMaxCharsMsg">Exceeded maximum number of characters.</span></span></td> </tr> <tr> <td>Webmaster Name:*</td> <td><label for="textfield2"><span id="sprytextfield4"> <input type="text" name="webmaster_nane_field" id="webmaster_nane_field" /> <span class="textfieldRequiredMsg">A value is required.</span></span></label></td> </tr> <tr> <td>Webmaster E-mail:*</td> <td><label for="textfield3"><span id="sprytextfield5"> <input name="webmaster_email_field" type="text" id="webmaster_email_field" size="40" /> <span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span></label></td> </tr> <tr> <td>Category:*</td> <td><span id="spryselect1"> <label for="category_selection"></label> <select name="category_selection" id="category_selection"> <option>Select An Option</option> <option value="Web_Sites">Web Sites</option> <option value="Blogs">Blogs</option> <option value="Directories">Directories</option> </select> <span class="selectRequiredMsg">Please select an item.</span></span></td> </tr> <tr> <td> </td> <td><label for="select"></label> <input type="submit" name="button" id="button" value="Url Submission" /></td> </tr> </table> <input type="hidden" name="MM_insert" value="link_submission" /> </form> Im begging for your help..... Dear All Members here is my table data.. (4 Columns/1row in mysql table)
id order_no order_date miles How to split(miles) single column into (state, miles) two columns and output like following 5 columns /4rows in mysql using php code.
(5 Columns in mysql table) id order_no order_date state miles 310 001 02-15-2020 MI 108.53 310 001 02-15-2020 Oh 194.57 310 001 02-15-2020 PA 182.22
310 001 02-15-2020 WA 238.57 ------------------my php code -----------
<?php
if(isset($_POST["add"]))
$miles = explode("\r\n", $_POST["miles"]);
$query = $dbh->prepare($sql);
$lastInsertId = $dbh->lastInsertId(); if($query->execute()) {
$sql = "update tis_invoice set flag='1' where order_no=:order_no"; $query->execute();
} ----------------- my form code ------------------
<?php -- Can any one help how to correct my code..present nothing inserted on table
Thank You Edited February 8, 2020 by karthicbabuHi, My company has 240+ locations and as such some users (general managers) cover multiple sites. When I run a query to pull user information, when the user has multiple sites to his or her name, its adds the second / third sites to the next columns, rather than wrapping it inside the same table cell. It also works the opposite way, if a piece of data is missing in the database and is blank, its pull the following columns in. Both cases mess up the table and formatting. I'm extremely new to any kind of programming and maybe this isn't the forum for this question but figured I'd give it a chance since I'm stuck. The HTML/PHP code is below: <table id="datatables-column-search-select-inputs" class="table table-striped" style="width:100%"> <thead> <tr> <th>ID</th> <th>FirstName</th> <th>LastName</th> <th>Username</th> <th>Phone #</th> <th>Location</th> <th>Title</th> <th>Role</th> <th>Actions</th> </tr> </thead> <tbody> <?php //QUERY TO SELECT ALL USERS FROM DATABASE $query = "SELECT * FROM users"; $select_users = mysqli_query($connection,$query);
// SET VARIABLE TO ARRAY FROM QUERY while($row = mysqli_fetch_assoc($select_users)) { $user_id = $row['user_id']; $user_firstname = $row['user_firstname']; $user_lastname = $row['user_lastname']; $username = $row['username']; $user_phone = $row['user_phone']; $user_image = $row['user_image']; $user_title_id = $row['user_title_id']; $user_role_id = $row['user_role_id'];
// POPULATES DATA INTO THE TABLE echo "<tr>"; echo "<td>{$user_id}</td>"; echo "<td>{$user_firstname}</td>"; echo "<td>{$user_lastname}</td>"; echo "<td>{$username}</td>"; echo "<td>{$user_phone}</td>";
//PULL SITE STATUS BASED ON SITE STATUS ID $query = "SELECT * FROM sites WHERE site_manager_id = {$user_id} "; $select_site = mysqli_query($connection, $query); while($row = mysqli_fetch_assoc($select_site)) { $site_name = $row['site_name']; echo "<td>{$site_name}</td>"; } echo "<td>{$user_title_id}</td>"; echo "<td>{$user_role_id}</td>"; echo "<td class='table-action'> <a href='#'><i class='align-middle' data-feather='edit-2'></i></a> <a href='#'><i class='align-middle' data-feather='trash'></i></a> </td>"; //echo "<td><a href='users.php?source=edit_user&p_id={$user_id}'>Edit</a></td>"; echo "</tr>"; } ?>
<tr> <td>ID</td> <td>FirstName</td> <td>LastName</td> <td>Username</td> <td>Phone #</td> <td>Location</td> <td>Title</td> <td>Role</td> <td class="table-action"> <a href="#"><i class="align-middle" data-feather="edit-2"></i></a> <a href="#"><i class="align-middle" data-feather="trash"></i></a> </td> </tr> </tbody> <tfoot> <tr> <th>ID</th> <th>FirstName</th> <th>LastName</th> <th>Username</th> <th>Phone #</th> <th>Location</th> <th>Title</th> <th>Role</th> </tr> </tfoot> </table>
Hi all, Just curious why this works: Code: [Select] while (($data = fgetcsv($handle, 1000, ",")) !== FALSE){ $import="INSERT into $prodtblname ($csvheaders1) values('$data[0]','$data[1]','$data[2]','$data[3]','$data[4]','$data[5]','$data[6]')"; } And this does not: $headdata_1 = "'$data[0]','$data[1]','$data[2]','$data[3]','$data[4]','$data[5]','$data[6]'"; while (($data = fgetcsv($handle, 1000, ",")) !== FALSE){ $import="INSERT into $prodtblname ($csvheaders1) values($headdata_1)"; }it puts $data[#'s] in the database fields instead of the actual data that '$data[0]','$data[1]'... relates to. I wrote a script to create the values in $headdata_1 based on the number of headers in $csvheaders1 but can't seem to get it working in the sql statement. Thanks Hi all, I'm a first time poster here and I would really appreciate some guidance with my latest php challenge! I've spent the entire day googling and reading and to be honest I think I'm really over my head and need the assistance of someone experienced to advise the best way to go! I have a multi dimensional array that looks like (see below); the array is created by CodeIgniter's database library (the rows returned from a select query) but I think this is a generic PHP question as opposed to having anything to do with CI because it related to working with arrays. I'm wondering how I might go about searching the array below for the key problem_id and a value equal to a variable which I would provide. Then, when it finds an array with a the matching key and variable, it outputs the other values in that part of the array too. For example, using the sample data below. How would you recommend that I search the array for all the arrays that have the key problem_id and the value 3 and then have it output the value of the key problem_update_date and the value of the key problem_update_text. Then keep searching to find the next occurrence? Thanks in advance, as above, I've been searching really hard for the answer and believe i'm over my head! Output of print_r($updates); CI_DB_mysql_result Object ( [conn_id] => Resource id #30 [result_id] => Resource id #35 [result_array] => Array ( ) [result_object] => Array ( ) [current_row] => 0 [num_rows] => 5 [row_data] => ) Output of print_r($updates->result_array()); Array ( [0] => Array ( [problem_update_id] => 1 [problem_id] => 3 [problem_update_date] => 2010-10-01 [problem_update_text] => Some details about a paricular issue [problem_update_active] => 1 ) [1] => Array ( [problem_update_id] => 4 [problem_id] => 3 [problem_update_date] => 2010-10-01 [problem_update_text] => Another update about the problem with an ID of 3 [problem_update_active] => 1 ) [2] => Array ( [problem_update_id] => 5 [problem_id] => 4 [problem_update_date] => 2010-10-12 [problem_update_text] => An update about the problem with an ID of four [problem_update_active] => 1 ) [3] => Array ( [problem_update_id] => 6 [problem_id] => 4 [problem_update_date] => 2010-10-12 [problem_update_text] => An update about the problem with an ID of 6 [problem_update_active] => 1 ) [4] => Array ( [problem_update_id] => 7 [problem_id] => 3 [problem_update_date] => 2010-10-12 [problem_update_text] => Some new update about the problem with the ID of 3 [problem_update_active] => 1 ) ) I am creating a form that will allow the user to select the make of vehicle "FORD" for example. If that make of vehicle is selected among different makes of vehicles, then another box will appear, with all the models for that particular model "Fiesta" for example. What type of code accomplishes this setup in my web page? I do not want to list 500 models in one drop down list, but just those for each make in the first drop down list. Thanks much! Hi All, I have 2 tables: one CarMake - CarMakeID - CarMakeDesc two CarModel - CarModelID - CarModelMake - CarModelDesc Depending on what the user selects in the first dropdown (carmake) the possible selection in the second dropdown (model) needs to be limited to only the models from the selected carmake. in the second table (Carmodel : the 'CarModelMake' = CarMakeID, to identify the make) How do I limit the dropdown 'CarModel' based on the selected CarMake in the first dropdown. link : http://98.131.37.90/postCar.php code : -- -- -- Code: [Select] <label> <select name="carmake" id="CarMake" class="validate[required]" style="width: 200px;"> <option value="">Select CAR MAKE...</option> <?php while($obj_queryCarMake = mysql_fetch_object($result_queryCarMake)) { ?> <option value="<?php echo $obj_queryCarMake->CarMakeID;?>" <?php if($obj_queryCarMake->CarMakeID == $CarAdCarMake) { echo 'selected="selected"'; } ?> > <?php echo $obj_queryCarMake->CarMakeDesc;?></option> <?php } ?> </select> </label> <label> <select name="carmodel" id="CarModel" class="validate[required]" style="width: 200px;"> <option value="">Select MODEL...</option> <?php while($obj_queryCarModel = mysql_fetch_object($result_queryCarModel)) { ?> <option value="<?php echo $obj_queryCarModel->CarModelID;?>" <?php if($obj_queryCarModel->CarmodelID == $CarAdCarModel) { echo 'selected="selected"'; } ?> > <?php echo $obj_queryCarModel->CarModelDesc;?></option> <?php } ?> </select> </label> I'm a novice.. and appreciates all the help ! Hello, I have read tutorials, searched forums for 2 weeks, and not found the assistance I require. I now jump in to ask my questions with the assistance from those much wiser then I... I am new to this arena, so I honor your understanding to my situation. I have 2 Solar Inverters that I have at my home, and I have a RS232 data port on each that is now connected to my home network via an IP converter to upload the data of the power they make each hour to a simple website I made, so I can see what is going on durring the hours I am at work. The information goes to my FTP site and the data falls into the MySQL table perfectly. I am trying to get the PHP and MySQL code to list the data into the forms/tables on the web page. For this project I have set up Dreamweaver CS5 and a test server on my home PC, to get this working. All the data on the web host MySQL table is the same as in the test server (other then the host, name, and password but it works fine). I have a very basic MySQL Named "inverters", and the table below named "feed"... +---------+----------+------------+---------+------------+----------+ | Unit ID | Date | Time | Power | Volts | Current | +---------+----------+------------+---------+------------+----------+ | 1 |YYYY-MM-DD| 12:00:00 | 560 | XXXX | XXXX | +---------+----------+------------+---------+------------+----------+ | 1 |YYYY-MM-DD| 13:00:00 | 565 | XXXX | XXXX | +---------+----------+------------+---------+------------+----------+ | 1 |YYYY-MM-DD| 14:00:00 | 890 | XXXX | XXXX | +~~~~~~+~~~~~~+~~~~~~~~+~~~~~~+~~~~~~~+~~~~~~~+ Etc.... The 'Time' has 24 rows for each day, each 'Date" shows the same date for each of the 24 rows of 'Time". The 'Power', is assigned as double the Volts and Current are "float". I am able to SUM the Total "Power" of all the "Power" Rows with... <? $con = mysql_connect("localhost","NAME","PASWORD"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("inverters", $con); $qry = mysql_query(" SELECT SUM(Power) AS total FROM feed "); $row = mysql_fetch_assoc($qry); echo $row['total']; mysql_close($con); ?> I have been trying for weeks to get "the CURRENT DAY power", Week Power, the month power etc to show the data on the webpage with no luck. A very simple table on the website... As seen on the website. +-----------+----------------+-----------------+-----------------+ | Today | This Month | This Year | Lifetime Power | +-----------+----------------+-----------------+-----------------+ |????????| ??????????|???????????|----working----| +-----------+----------------+-----------------+-----------------+ For the Current Day, I have tried this, but it does not work... $query = mysql_query("SELECT(date), SUM(Power) AS 'day_total' FROM feed WHERE (date) = CURDATE() GROUP BY (date) ORDER BY (date) "); $result = mysql_fetch_array($query); $daytotal = $result["day_total"]; echo $row['day_total']; mysql_close($con); For the Month, I have tried this, but it does not work... $query = mysql_query("SELECT MONTH(date), SUM(Power) AS month_total FROM feed GROUP BY Month(date)"); $result = mysql_fetch_array($query); echo $row['month_total']; mysql_close($con); For the YEAR, I have tried this, but it does not work... $query = mysql_query("SELECT date, SUM(Power) AS total FROM feed GROUP BY date"); $result = mysql_fetch_array($query); echo $row['year_total']; mysql_close($con); I am reading and reading. Online I see how to get user names, and the time they register, and how many 'visitor' hits per year or month etc, but none have been informative to my situation. I think the more I read on the PHP and MySQL website manual, the more stupid I have become... Using Google to seach "how to get the SUM of Current Date" only showes me how to enter the current date on a webpage or in a table row, not how to SUM the values of a table of the current day. I also want to have a PHP graph (I have PHPgraphLIB now) on another page, and control the graph images by using a simple "Date Picker" or calendar, but that ran into the same type of issues as anything I write does not generate or show the results. I spent days using Prototype.js calendars and AJAX to connect the server side to the graphs and calendar etc..., but that is a different issue... hahaha I would greatly honor any assistance to my learning and functioning of this. Thank You, Alan I have a table with a list of towns and cities with their postcode and latitude and longitude. Since a lot of small towns in an area have the same postcode. I have a search which I want to return all towns that have the same postcode. the table is set up as: postcode:::::::town::::::::lat:::::::::long |