Jump to content

jxfish2

Members
  • Posts

    34
  • Joined

  • Last visited

Everything posted by jxfish2

  1. Thanks to everyone who tried to help. I really appreciate both your time, and your input. The output that I was trying to get was similar to the following, in that there were a number of database records being returned, each record had it's own select dropdown box, and when selected for "Update", that record, and only that record was supposed to be updated. ABC123 Little_Boy_Blue My Record 20130521 No Update Available Abandon SS_SD-Y HLS_SD-N iPhone_SD-N SS_HD-N HLS_HD-N BDF812 Man_In_The_Moon Your Record 20130715 No Update Available On Hold SS_SD-N HLS_SD-N iPhone_SD-N SS_HD-N HLS_HD-Y XYZ246 Blue_Boy_n_Pinky Our Record 20130627 No Update Available Provider Input Requested SS_SD-Y HLS_SD-Y iPhone_SD-N SS_HD-Y HLS_HD-Y But, no matter how much help you guys provided, I could not get it to work! I was pulling the data straight from the database, and building the above array live, as the data was retrieved. In order to update the database, I needed to take the environment variable from the 1st column, and include it with the dropdown selection variable from the 6th column, passing both variables to the JS function, when the "Update" button was selected. But, I don't know if I was pulling the first column value correctly from the array, as the page was displayed in it's entirety, before the dropdown box and Update button (Submit) were being selected. And, no matter how much I tried, I could not get the JS function to return the alert messages. Historically, over the past few weeks, I've created numerous other scripts that passed a single variable to the JS function file, and successfully received the alert messages. However, this was the first time I tried to mix PHP and HTML data together in one script. I'm really sorry that my efforts weren't successful, but after wasting several days, I've decided to abandon the "Update" piece of this effort. Note that the same output above, minus the status box, dropdown box and Update button, also serves a purpose, so the entire effort wasn't wasted. Again, thanks for your assistance, and have a great week. JCF
  2. Hi Guys, I really appreciate the help you've given so far, but I still can't seem to make it work. Here's my code snippets: Inside of the PHP script: <HTML> <HEAD><script type="text/javascript" src="functions.js"></script> <META HTTP-EQUIV="Cache-Control" CONTENT="no-store" /> <META HTTP-EQUIV="Pragma" CONTENT="no-cache"> <META HTTP-EQUIV="Expires" CONTENT="-1"> </HEAD> <!--<BODY onload="PageLoadFunctions(); document.getElementById('inputbox').focus();">--> <BODY document.getElementById('this.value').focus();"> <?php ......... Some code that doesn't pertain to this issue......... $result = mysqli_query($con, "select * from tbl_vms order by alt_code"); while($row = mysqli_fetch_array($result)){echo "<tr>"; $alt = $row['alt_code'];echo "<td>" . " " . $alt . " " . "</td>"; //echo "<td>" . " " . $row['alt_code'] . " " . "</td>"; ?> <form method="post"> <select name="stat"> <option value="2"> Abandon </option> <option value="3"> On Hold </option> <option value="4"> Provider Input Requested </option> <option value="5"> Working </option> <option value="6"> Complete - Not Yet Delivered </option> <option value="7"> Complete - Delivered </option> </select> <input type="button" value="Update" onclick="func_UpdateOldAssets(' . $alt . ',' . $stat . '); return false;"></input> </form> <?php Inside of the functions.js script: function func_UpdateOldAssets(){ alert("Update equals " + 'this.value'); var alt_stat = [' $alt ' . ',' . ' $stat ']; document.getElementById(this.value).value; var formdata=document.getElementById(this.value).value; alert(formdata); ......... I know that the variable "$alt" is initialized inside the PHP code. I have to assume that the variable "$stat" is being initialized via the "SELECT" code, when I step out of PHP and into HTML. I still don't understand, and still can't seem to pass both of these variables to the functions.js script. None of the "alert" commands inside of the functions.js script are returning any values. Note that I'm also using the "F12 Developer Tools" dropdown. I am getting an error that says "SCRIPT5009: 'func_UpdateOldAssets' is undefined".Remember that I have only been playing with PHP for about 1 week now. In this time, with my extensive shell scripting background, I have managed to successfully create a number of PHP scripts already. But, this particular one, with the select statement, and need to pass multiple variables to the JavaScript function, seems to be giving me a world of trouble. If you could help me to get this one running correctly, I would be very grateful, as this same "format" / "functionality" will be used for a number of additional, similar pages in the near future... Thanks in advance, and have a great day. JCF.
  3. Sorry, but I'm back again. I'm still having one big issue. I've been trying all day to figure it out on my own, but have had no luck. Here are some of my code snippets: while($row = mysqli_fetch_array($result)) { echo "<tr>"; $alt=$row['alt_code']; echo "<td>" . " " . $alt . " " . "</td>"; The above array initialization is working just fine, as intended. I substituted the actual variable "$alt" in the echo command, just to make sure a valid value was being declared. Here's the current <SELECT> statement, which on the surface, also looks like it's working as intended. At least it's displaying correctly on the webpage: echo "<td>"; echo '<form method="post"> <select name="update"> <option value="2"> Abandon </option> <option value="3"> On Hold </option> <option value="4"> Provider Input Requested </option> <option value="5"> Working </option> <option value="6"> Complete - Not Yet Delivered </option> <option value="7"> Complete - Delivered </option> </select> <INPUT type="button" value="Update" onclick="func_UpdateOldAssets($alt,$value); return false;"></INPUT> </form>'; echo "</td>";The issue I'm having, is that the variable "$alt", and the variable initialized by the select drop down box, both need to be passed to the JS Function. Neither of these two variables is being passed to the JS Function! Here's the first few lines from my JS Function: function func_UpdateOldAssets() { alert("Update equals " + 'this.value'); var formdata=document.getElementById(this.value).value; When I run the script, and select the drop down value that I want, here's what I get as output: Error: '$alt' is undefined If I change the variables in the INPUT line as follows: <INPUT type="button" value="Update" onclick="func_UpdateOldAssets(this.value); return false;"></INPUT> A successful call to the JS Function returns the following values: Update equals this.value In short, I can't get the 2 variables that I need to pass to the JS Function to work. I believe once I get the variables to the JS Function, I can finish the rest on my own. But, I've been "playing" / "experimenting" all day today, and still haven't hit on the magic button... If you could help with this one last piece, I believe I can finish the rest on my own. Thanks in advance, and have a great day. JCF
  4. I really appreciate your help... I created some java script code, and I'm attempting to feed values to the java script file, from my php / html document. I'm getting an error, and as this is very very new to me, I'm not sure of what to do. I've been searching w3Schools, stack overflow and google, but have not come across the answers that I need yet. So, I'm coming back to ask for your assistance one more time. Here's my current select statement: echo "<td>"; echo '<form method="post"> <select name="update_status"> <option value="2"> Abandon </option> <option value="3"> On Hold </option> <option value="4"> Provider Input Requested </option> <option value="5"> Working </option> <option value="6"> Complete - Not Yet Delivered </option> <option value="7"> Complete - Delivered </option> </select> <INPUT type="button" value="Update" onclick="func_UpdateOldAssets(update_status)"></INPUT> </form>'; echo "</td>"; I have no real idea of how to reference the java script from within the html body, but here's what I've tried so far: <HEAD><TITLE>Old Asset Tracking</TITLE> <script type="text/javascript" src="functions.js"></script></HEAD> <BODY onload="PageLoadFunctions(); document.getElementById('alt').focus(); document.getElementById('update_status').focus();"> NOTE: I only tried the above, as I need to pass two distinctly different variables to the functions.js parser. And finally, here's the first few lines of code from the functions.js parser: function func_UpdateOldAssets(update_status){ var formdata=document.getElementById(update_status).value; alert(formdata); I'm getting the following error message: var formdata=document.getElementById(update_status).value; SCRIPT5007: Unable to get property 'value' of undefined or null reference I've never tried to pass data to the java script parser from a drop-down box before, and don't know why I'm getting the undefined value error. It appears as if the "update_status" variable isn't being initialized, or not being sent to the java script parser. Another issue is that I also need to send 2 variables to the java script parser, but I don't know how to do that, and none of the references that I've checked so far, give any examples of how to do this. Your help is greatly appreciated. Thanks in advance, and have a great day. JCF
  5. Thank you very very much... The primary webpage is EXACTLY what I was looking for... Now, having said that, when I click on the "Update" button, my page goes blank... Here's the code that I just inserted in the basic webpage: echo "<td>"; echo '<form method="post" action="/update_status.php"> <select name="update_status"> <option value="2"> Abandon </option> <option value="3"> On Hold </option> <option value="4"> Provider Input Requested </option> <option value="5"> Working </option> <option value="6"> Complete - Not Yet Delivered </option> <option value="7"> Complete - Delivered </option> </select> <INPUT type="submit" value="Update" /> </form>'; echo "</td>"; Here's the code I put inside of the "update_status.php" script: <?php $con=mysqli_connect("x.x.x.x","user","passwd","DB_Instance"); // Check connection if (mysqli_connect_error()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $date = date("Ymd"); $status = $_POST["update_status"]; $alt = $_POST["alt"]; mysqli_query($con, "UPDATE ...tablename... SET status_id='$status', mod-date='$date' WHERE alt_code='$alt'"); mysqli_close($con); ?> Again, when I click on the "Update" button, the screen goes blank, as if it's redirecting me to a new page. How can I execute the above UPDATE command, without leaving the current webpage? Is this possible? JCF
  6. I would assume that I can not break out of the PHP code, without losing both the initialized variables, and without exiting from the loop. Instead of displaying the data direct to the monitor, I could build an external flat file, with HTML markup in it, then display the HTML page in the DIV. Unless you have some additional suggestions, I'll try that next... Build a flat file with the HTML markup in it, then call PHP to submit the database updates for those rows where the select box was called and changed.
  7. Thanks JustSomeGuy. I'm going to try inserting the echo statements first, as that's how I'm currently inserting my "other" html formatted output. Here's what I tried to insert: while($row = mysqli_fetch_array($result)) { echo "<tr>"; echo "<td>"; echo "<select name="update_status">"; echo "<option value="2">" . "Abandoned" . "</option>"; echo "<option value="3">" . "On Hold" . "</option>"; echo "<option value="4">" . "Provider Input Requested" . "</option>"; echo "<option value="5">" . "Working" . "</option>"; echo "<option value="6">" . "Complete - Not Yet Delivered" . "</option>"; echo "<option value="7">" . "Complete - Delivered" . "</option>"; echo "</select>"; echo "</td>"; echo "<td>" . " " . $row['alt_code'] . " " . "</td>"; ### Next output field, which is working correctly.When I insert the above code, nothing is displayed on the screen. It's just blank. If I take it out, the page is generated as intended, formatted beautifully, to fit the screen. I also tried inserting the same code as follows, with the same results: echo "<td>" . "<select name="update_status">" . "<option value="2">" . "Abandoned" . "</option>" . "<option value="3">" . "On Hold" . "</option>" . "<option value="4">" . "Provider Input Requested" . "</option>" . "<option value="5">" . "Working" . "</option>" . "<option value="6">" . "Complete - Not Yet Delivered" . "</option>" . "<option value="7">" . "Complete - Delivered" . "</option>" . "</select>" . "</td>"; echo "<td><select name="update_status"><option value="2">Abandoned</option><option value="3">On Hold</option><option value="4">Provider Input Requested</option><option value="5">Working</option><option value="6">Complete - Not Yet Delivered</option><option value="7">Complete - Delivered</option></select></td>"; ------------------- You noted above that I could break out of the php code, long enough to insert the html select code. I'm in the middle of a PHP loop, where all environment variables have been initialized for this particular record. If I exit from the PHP code at this point, won't I lose the variables that were initialized inside of the loop?
  8. I am calling hundreds of records from a MySQL database. Each record has been formatted to fit on a single line, formatted using HTML, so that the output appears neat and clean. For each record that is displayed, I want to include a drop-down box, at the beginning of the line, that will allow a user to update the current status for that particular record. Essentially, there will be a drop-down box for each and every row. The data is retrieved from the database, and stored in an array. For each line or record read in, the HTML select statement needs to be called, and the resulting values need to be displayed in the drop-down box, in column 1 of the output. (I may need a submit button to be included for each line, but I'm not sure at this point.) To be honest, I'm new to PHP and HTML, but I've been shell scripting for years. Once the values in the Select box have been changed, a SQL UPDATE command needs to be run against the MySQL database, for each record that's been changed. All of the code, to include SQL queries, loops, arrays, and HTML page formatting, are already in place, and working as intended. The only piece remaining, is the dropdown box, for each record, and the SQL UPDATE calls. (I know how to write the SQL UPDATE commands, I just don't know how to call them from this dropdown box.) I found numerous examples of how to call PHP from within HTML, but have not found any examples of how to call a from within my PHP code. I'm not very good with java script, but I do know how to call an external java script. The issue is that I need the dropdown box to appear in the array, as if it were just another data field in my output display. I've searched numerous boards, but nobody has posted anything close to what I need at this point. Note, that of the hundreds of records that are displayed, the user / viewer may only update 2 or 3 rows on the entire display. The purpose of this webpage, is to give our 3rd party vendor a place where they can provide a very very simple way to update the status of assets that we're tracking! It's either this, or we sit for hours on phone calls, manually transcribing the status changes on hundreds of assets. I tried using 2 different PHP function calls, but I really don't know if my syntax is correct: //function dropdown() //{ //<html> //<body> //echo "<td>" . <select> //<option value='2'>Abandoned</option> //<option value='3'>On Hold</option> //<option value='4'>Provider Input Requested</option> //<option value='5'>Working</option> //<option value='6'>Complete - Not Yet Delivered</option> //<option value='7'>Complete - Delivered</option> //</select> . "</td>"; //</body> //</html> //} And, a second function call: //function dropdown() //{ //<form method="post" action"update_status.php"> //<select name="update_status"> //<option value="2"> Abandoned </option> //<option value="3"> On Hold </option> //<option value="4"> Provider Input Requested </option> //<option value="5"> Working </option> //<option value="6"> Complete - Not Yet Delivered </option> //<option value="7"> Complete - Delivered </option> //</select> //<INPUT type="submit" name="submit" /> //</form> //} Note: Neither of the above function calls produced any output. The page would not display in either case. Here's the array initialization, and where I build my HTML input. I'm reading in the data, one line at a time: while($row = mysqli_fetch_array($result)){ echo "<tr>"; //dropdown //NOTE: This is the point in the HTML row, where I want to insert the drop-down box. echo "<td>" . " " . $row['field_1'] . " " . "</td>"; echo "<td>" . " " . $row['field_2'] . " " . "</td>"; //NOTE: The current status is displayed in the 3rd column, and will need to change, if a new selection is made, within the drop-down box. if ($row['status_id'] == "1") { echo "<td>" . " " . "No Update Available" . " " . "</td>"; } elseif ($row['status_id'] == 2) { echo "<td>" . " " . "Abandoned" . " " . "</td>"; } elseif ($row['status_id'] == 3) { echo "<td>" . " " . "On Hold" . " " . "</td>"; } ... Continued IS IT EVEN POSSIBLE TO CALL AN HTML SELECT OPTION FROM WITHIN PHP? Any help, suggestions, examples, would be greatly appreciated. Thanks in advance, and have a great week. jxfish2
  9. I'm a senior HP Unix Systems Engineer, but I've never developed an actual web-based application.<b> I run Windows and Linux at home.<b> I have my own home-built SAN.<b> I did some basic MySQL installation and setup at work.<b> I have fairly decent SQL skills.<b> I want to create my own online application, but that application will need a very fast, back-end processing engine.<b> I am heavy into shell scripting, but that's not going to be fast enough to process the amount of data that I envision for this app.<b> I need to learn some kind of simple, yet powerful compiled language.<b> I started studying C++ 2 days ago, and so far, it looks fairly straight-forward and not too difficult.<b> What other "tools" do I need, in order to allow the new C++ programs to query and manipulate the actual MySQL database?<b> SQL by itself won't do it, PHP won't do it, as it's not compiled, and won't be fast enough to process the data in a timely manner.<b> At this time, I'm planning to build the web-based front-end using HTML and PHP.<b> I'm planning to use MySQL as the database itself.<b> Linux will of course be the O/S of choice.<b> I want to get this project off the ground as quickly as possible, so any advice or suggestions would be greatly appreciated.<b> Thanks in advance, and have a very happy holiday season.
×
×
  • Create New...