Levinax
Members-
Posts
8 -
Joined
-
Last visited
Never
Profile Information
-
Gender
Not Telling
Levinax's Achievements
Newbie (1/5)
0
Reputation
-
[!--quoteo(post=364512:date=Apr 13 2006, 11:26 AM:name=earl_dc10)--][div class=\'quotetop\']QUOTE(earl_dc10 @ Apr 13 2006, 11:26 AM) [snapback]364512[/snapback][/div][div class=\'quotemain\'][!--quotec--] are you echoing the form inside of php? if you are try this : [code] echo ' .... <form action="'.$_SERVER['PHP_SELF'].'" method="POST" name="input"> [/code] hope that helps! [/quote] yes, i am echoing it in PHP, and that gives me the same parse error.
-
[!--quoteo(post=364234:date=Apr 12 2006, 05:12 PM:name=earl_dc10)--][div class=\'quotetop\']QUOTE(earl_dc10 @ Apr 12 2006, 05:12 PM) [snapback]364234[/snapback][/div][div class=\'quotemain\'][!--quotec--] hi, try changing [code] <form method=POST name=input> [/code] to [code] <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="POST" name="input"> [/code] [/quote] nope, that gives me the following error: [code][Thu Apr 13 09:34:16 2006] [error] PHP Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in /home/test/public_html/test/test4.php on line 262 [/code]
-
so i have a script where i can update entries in my database. i have all the SQL worked out to where i know that hitting the submit button successfully updates the information in the database. however, the information on the form on the current page still displays the old information. if i hit F5 and refresh the page, it comes up with the new info, but i was wondering if there was a way to do it so it would automatically refresh after hitting the submit button? here is my function... i know its got to be something with my data flow... but i am not a programmer (my boss seems to think i am though =\ ) [code]function edit_form($db, $hostname) { if (isset($hostname)) { echo "Update Entry Form"; $edittype = "update"; //query db and put results in array to populate form $lkup = "SELECT * FROM info WHERE hostname = '$hostname'"; $editqry = pg_query($db, $lkup); $editres = pg_fetch_array($editqry); } else { echo "Add New Form"; $edittype = "insert"; } echo"<BR>"; echo" <BR> <table> <form method=POST name=input> <tr><td>Hostname:</td><td> <input type=\"text\" name=\"host\" value=\"$hostname\"></td></tr> <tr><td>MAC:</td><td> <input type=\"text\" name=\"mac\" value=\"$editres[mac_address]\"></td></tr> <tr><td>OS:</td><td> <input type=\"text\" name=\"os\" value=\"$editres[os]\"></td></tr> <tr><td>SP:</td><td> <input type=\"text\" name=\"sp\" value=\"$editres[service_pack]\"></td></tr> <tr><td>CPU:</td><td> <input type=\"text\" name=\"cpu\" value=\"$editres[processor]\"></td></tr> <tr><td>RAM:</td><td> <input type=\"text\" name=\"ram\" value=\"$editres[ram]\"></td></tr> <tr><td>HDD:</td><td> <input type=\"text\" name=\"hdd\" value=\"$editres[hard_drive]\"></td></tr> <tr><td>Optical:</td><td> <input type=\"text\" name=\"cdr\" value=\"$editres[optical_type]\"></td></tr> <tr><td>FDD:</td><td> <input type=\"text\" name=\"fdd\" value=\"$editres[floppy]\"></td></tr> <tr><td>Dell Tag:</td><td> <input type=\"text\" name=\"dell\" value=\"$editres[dell_service_tag]\"></td></tr> <tr><td>Location:</td><td> <input type=\"text\" name=\"locat\" value=\"$editres[location]\"></td></tr> <tr><td>Store:</td><td> <input type=\"text\" name=\"store\" value=\"$editres[store]\"></td></tr> <tr><td>Dept:</td><td> <input type=\"text\" name=\"dept\" value=\"$editres[dept]\"></td></tr> <tr><td>Comments:</td><td> <input type=\"text\" name=\"comment\" value=\"$editres[comments]\"></td></tr> <input type=hidden name=edit value=$edittype> <tr><td colspan=\"2\" align=\"center\"><input type=submit value=\"Submit\" action=\"$updqry\" onlcick=\"edit_form($db, $hostname)\"></td></tr\ > </form> </table> "; if($edittype = "update"){ $updtbl = "UPDATE info SET mac_address='$_POST[mac]', os='$_POST[os]', service_pack='$_POST[sp]', processor='$_POST[cpu]', ram='$_POST[ram]', hard_drive='$_POST[hdd]', optical_type='$_POST[cdr]', floppy='$_POST[fdd]', dell_service_tag='$_POST[dell]', store='$_POST[store]', dept='$_POST[dept]', location='$_POST[locat]', comments='$_POST[comment]' WHERE hostname = '$hostname'"; } else if($edittype = "addnew"){ $updtbl = "INSERT INTO info VALUE '$_POST[host]', '$_POST[mac]', '$_POST[os]', '$_POST[sp]', '$_POST[cpu]', '$_POST[ram]', '$_POST[hdd]', '$_POST[cdr]', '$_POST[fdd]', '$_POST[dell]', '$_POST[store]', '$_POST[dept]', '$_POST[comment]', '$_POST[locat]'"; } $updqry = pg_query($db, $updtbl); } [/code]
-
when i use that code, the query fails... [code] [Tue Mar 28 10:17:51 2006] [error] PHP Warning: pg_query(): Query failed: ERROR: Unable to identify an ordering operator '<' for type 'unknown' Use an explicit ordering operator or modify the query . in /home/test/public_html/test/test4.php on line 258 [Tue Mar 28 10:17:51 2006] [error] PHP Warning: pg_fetch_array(): supplied argument is not a valid PostgreSQL result resource in /home/test/public_html/test/test4.php on line 261 [Tue Mar 28 10:17:51 2006] [error] PHP Warning: pg_num_rows(): supplied argument is not a valid PostgreSQL result resource in /home/test/public_html/test/test4.php on line 273 [/code]
-
hopefully from the database, they are table names. the SQL looks like this: [code]$lsd = "SELECT DISTINCT location FROM info UNION ALL SELECT DISTINCT store FROM info UNION ALL SELECT DISTINCT dept FROM info"; [/code] this is the only way i could get the query to return the proper results... now getting it to return the proper results in the right format will be the tricky part...
-
when i use that code, it outputs the following... [code]Array ( [0] => CHEVROLET [location] => CHEVROLET ) [/code]
-
ok, so im trying to input the result of a query into a multidimensional array. i know that the query returns the results i want, but im having problems inputting it into the array correctly. theoretically, what should come out would be an array equal to the following: [code] $myarray = array ("location" => array ("CHEVROLET", "OLYMPIA", "TACOMA"), "store" => array ("CHEVROLET", "NISSAN", "SUBARU", "MITSUBISHI", "CHRYSLER"), "dept" => array ("BODY SHOP", "FINANCE", "OFFICE", "SALES", "SERVICE", "SHOP")); [/code] currently, i am inputing the code into an array in the following fashion: [code]$qryres = pg_query($db, $lsd); $myarray = array(); $lsdres = pg_fetch_array($qryres); while ($lsdres = pg_fetch_array($qryres)) { $myarray[] = $lsdres; } [/code] this inputs all the information, but not the correct way. the result of doing it this way returns the follwing: [code] Array ( [0] => Array ( [0] => OLYMPIA [location] => OLYMPIA ) [1] => Array ( [0] => TACOMA [location] => TACOMA ) [2] => Array ( [0] => CHEVROLET [location] => CHEVROLET ) [3] => Array ( [0] => CHRYSLER [location] => CHRYSLER ) [4] => Array ( [0] => MITSUBISHI [location] => MITSUBISHI ) [5] => Array ( [0] => NISSAN [location] => NISSAN ) [6] => Array ( [0] => SUBARU [location] => SUBARU ) [7] => Array ( [0] => BODY SHOP [location] => BODY SHOP ) [8] => Array ( [0] => FINANCE [location] => FINANCE ) [9] => Array ( [0] => OFFICE [location] => OFFICE ) [10] => Array ( [0] => PARTS [location] => PARTS ) [11] => Array ( [0] => RECEPTION [location] => RECEPTION ) [12] => Array ( [0] => SALES [location] => SALES ) [13] => Array ( [0] => SERVICE [location] => SERVICE ) [14] => Array ( [0] => SHOP [location] => )) [/code] if anyone could point me in the right direction, i would greatly appreciate it.
-
here is a function i wrote to query a database and populate a SELECT box based on the results of that query if thats what you're looking for. there are probably better ways of doing it, but i know this one works. one thing i should note, this POSTS the information, and keeps whatever you selected selected. you might want to modify it if thats not what you want to do. and i was using PostgreSQL, so you might need to change some things from there too. [code]function first_form($db, &$location){ //Getting the data from Postgres table for first list box $quer1="SELECT DISTINCT location FROM info"; $result1 = pg_query($db, $quer1); $rows1 = pg_num_rows($result1); $location = $_POST["loc"]; //creat first form echo "<form method=POST name=f1 action=$PHP_SELF>"; echo "<select name=loc onchange=\"Javascript:submit()\"><option value=\"\">Location</option>"; for($i = 0; $i < $rows1; $i++) { $results1 = pg_fetch_array($result1, NULL, PGSQL_ASSOC); if($results1[location] == $location) { echo "<option selected value=$location>$location</option>"; } else { echo "<option value=\"$results1[location]\">$results1[location]</option>"; } } echo "</select>"; } [/code]