Jump to content

Shattered

Members
  • Posts

    16
  • Joined

  • Last visited

    Never

Everything posted by Shattered

  1. It still works.  And if you know a PHP version then by all means post the code.  I could use it for my own project Im working on but havent had the time to quickly find one that worked.
  2. Fantastic, thank you much, exactly what I wanted.
  3. Cool that got rid of the error.  Now Im just trying to get them all into a combo box.  Code runs fine, the combo box pops up, but the array data isnt in it. [code] $loc=$row['PC_LOC']; <tr><td>Location</td><td><select name='status'> <?php     $location = $array = array(); for($x=1; $x<31; $x++)     {$array[]="Shelf ".$x;} foreach($location as $locat) {   if($locat == $loc) { echo "<option selected>".$locat."</option>"; } else { echo "<option>".$locat."</option>"; } } ?> </select></td></tr> [/code]
  4. [code] <select name=navi onChange="go()"> <option value=''>--- Select your destination --- <option value="js.html">General Introduction <option value="placejs.html">Placing JavaScripts <option value="links.html">JavaScript Links </select> [/code] [code] function go() { box = document.forms[0].navi; destination = box.options[box.selectedIndex].value; if (destination) location.href = destination; } [/code] This might work for you.
  5. Is it possible to make a loop inside of an array? IE: [code] array(for($x=1;$x<31;$x++) {echo "Shelf $x";}); [/code] I have tried this already in my code, and I get: Parse error: parse error, unexpected T_FOR, expecting ')' in C:\Server\wamp\www\update.php on line 68 So I think either its A) Not possible, or B) coding it wrong.
  6. Dont quit, you never learn that way. When Im just outright lost though on whats going on, I just uninstall everything I worked on, and start with a fresh slate and see if I might have forgotten something somewhere. From one beginner to another :D
  7. Ahh!  That worked awesome.  Thanks. Now, would I pretty much do the same thing if I wanted to add a combo box to a Location, or to Status? $type=$row['PC_LOC']; $type=$row['PC_STATUS']; etc.? And obviously the code for the combo box. I have more questions that dont really have anything to do with the select option thing.  Could I just keep asking questions in this thread, or go ahead and make new ones? And I answered my own question up there, that worked wonders, thanks :)
  8. For me the quickest way to get PHP up and running with no errors, was to download a program called WAMP.  Suggest you give it a shot :)
  9. Thanks for the help.  Ive tried to implement all of what you guys have shown me, still cant seem to get it to work though. Ill post the scripts, sorry for the length. My first 'sorta large' php project, so be gentle on any constructive criticism. [b]index.php[/b] [code]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <link rel="stylesheet" href="styles.css"> <title>PC Overview</title> </head> <body> <a href="add_pc.php">Add a PC</a><br> <a href="delete_pc.php">Remove a PC</a><br> <br><br> <?php $con = mysql_connect("localhost","root",""); if(!$con) {   die('Could not connect: ' . mysql_error()); } mysql_select_db("PCLab", $con); $result = mysql_query("SELECT * FROM desktops"); echo "<form action=update.php method='post'>"; echo "<input type='submit' value='Update Selected'><br><br><table class=tealtable border=1 rules=rows cellpadding=3 cellspacing=1 frame=box>"; echo "<th>Update</th><th>Type</th><th>Name</th><th>Asset #</th><th>Service Tag</th><th>Status</th><th>Date Built</th><th>Lab Tech.</th><th>Lab Location</th><th>Deployed To</th><th>Tech.</th><th>Notes/Comments</th>"; while($row = mysql_fetch_array($result)) {   echo "<tr><td><input type='radio' value=".$row['ID']." name='pcid' checked='true'></td><td name='pctype'>".$row['PC_TYPE']."</td><td>".$row['PC_NAME']."</td><td>".$row['PC_ASSET']."</td><td>".$row['PC_SERTAG']."</td><td>".$row['PC_STATUS']."</td><td>".$row['PC_BLDDATE']."</td><td>".$row['PC_BLDTECH']."</td><td>".$row['PC_LABLOC']."</td><td>".$row['PC_DEPLOYED']."</td><td>".$row['PC_BYWHO']."</td><td>".$row['PC_NOTES']."</td></tr>"; } echo "</table><br><input type=submit value='Update Selected'></form>"; mysql_close($con); ?> </body> </html> [/code] [b]update.php[/b] [code]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <link rel="stylesheet" href="styles.css"> <title>Update PC</title> </head> <body> <?php $id=$_POST['pcid']; $type=$_POST['pctype']; $con = mysql_connect("localhost","root",""); if(!$con) {   die('Could not connect: '.mysql_error()); } mysql_select_db("PCLab", $con); $result = mysql_query("SELECT * FROM desktops WHERE ID=".$id.""); $row = mysql_fetch_array($result); echo "<br><a href='index.php'>Return to Main</a><br>"; echo "Selected: ".$id."<br>"; echo "<form action='update_result.php' method='post'><input type='hidden' name='id' value=".$id."><table>"; ?> <tr><td>Type</td><td><select name='type'> <?php     $pctypes = array("GX260","GX270","GX270MT","GX280","GX280MT","GX620","Precision 360","Precision 370","Precision 380","Precision 390"); foreach($pctypes as $pc) {   if($pc == $type) { echo "<option selected>".$pc."</option>"; } else { echo "<option>".$pc."</option>"; } } ?> </select></td></tr> <?php //echo "<tr><td>Type</td><td><input type='text' name='type' value=".$row['PC_TYPE']."></td></tr>"; echo "<tr><td>Name</td><td><input type='text' name='name' value=".$row['PC_NAME']."></td></tr>"; echo "<tr><td>Asset #</td><td><input type='text' name='asset' value=".$row['PC_ASSET']."></td></tr>"; echo "<tr><td>Service Tag</td><td><input type='text' name='service' value=".$row['PC_SERTAG']."></td></tr>"; echo "<tr><td>Status</td><td><input type='text' name='status' value=".$row['PC_STATUS']."></td></tr>"; echo "<tr><td>Date Built</td><td><input type='text' name='built' value=".$row['PC_BLDDATE']."></td></tr>"; echo "<tr><td>Lab Tech.</td><td><input type='text' name='labtech' value=".$row['PC_BLDTECH']."></td></tr>"; echo "<tr><td>Lab Location</td><td><input type='text' name='location' value=".$row['PC_LABLOC']."></td></tr>"; echo "<tr><td>Deployed To</td><td><input type='text' name='deployed' value=".$row['PC_DEPLOYED']."></td></tr>"; echo "<tr><td>Tech</td><td><input type='text' name='bywho' value=".$row['PC_BYWHO']."></td></tr>"; echo "<tr><td>Notes/Comments</td><td><textarea cols='40' rows'6' name='notes' value=''>".$row['PC_NOTES']."</textarea></td></tr>"; echo "<tr><td><input type='submit' value='Submit Changes'></td></tr>"; echo "</table></form>"; mysql_close($con); ?> </body> </html> [/code] [b]update_results.php[/b] [code]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <link rel="stylesheet" href="styles.css"> <title>Update PC</title> </head> <body> <?php $id=$_POST['pcid']; $con = mysql_connect("localhost","root",""); if(!$con) {   die('Could not connect: '.mysql_error()); } mysql_select_db("PCLab", $con); mysql_query("UPDATE desktops SET PC_TYPE='".$_POST['type']."', PC_NAME='".$_POST['name']."',PC_ASSET='".$_POST['asset']."', PC_SERTAG='".$_POST['service']."', PC_STATUS='".$_POST['status']."',PC_BLDDATE='".$_POST['built']."', PC_BLDTECH='".$_POST['labtech']."', PC_LABLOC='".$_POST['location']."',PC_DEPLOYED='".$_POST['deployed']."', PC_BYWHO='".$_POST['bywho']."', PC_NOTES='".$_POST['notes']."' WHERE ID='".$_POST['id']."'"); if(!mysql_query) {   echo 'No changes made<br>'; echo "<a href='index.php'>Return to Main</a><br>"; } else {   echo 'Computer updated<br>'; echo "<a href='index.php'>Return to Main</a><br>"; } mysql_close($con); ?> </body> </html> [/code]
  10. Hey guys. Im having some problems with a piece of code that Im using to update a value in a field. What I have happening now, is you select a radio button, click on the update button, and it takes you to a new page.  One of my values (PC Type) I have setup in a drop down box.  When they go to update a PC though, the dropdown box automatically goes to the first value in the selection list. My question:  How do I code it so that when they goto the update page, the PC Type that was listed initially is the same and not the first value on the selection? Also while I am asking questions.  When they update a pc, I have a status field and a few of them are like "In Progress" or "Being Built".  But, when they go to update the field, it only shows up until the first part, "In" or "Being".  Is there a way to make it output the whole string?
  11. Okay I understand that part.  Is there a way so that I can change my "ID" column into checkboxes, so that I would be able to select one or more systems and update them that way, and then actually be able to implement that code?
  12. I am kinda stuck on where to even start with working on this part of my little project.  I want to be able to update a row, thats it.  Im pretty much at the limits of my PHP knowledge and Im just doing a lot of guesswork now. This is what I have thus far: [b]index.php[/b] [code] <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>PC Overview</title> </head> <body> <a href="add_pc.php">Add a PC</a><br> <a href="delete_pc.php">Remove a PC</a><br> <br><br> <?php $con = mysql_connect("localhost","root",""); if(!$con) {   die('Could not connect: ' . mysql_error()); } mysql_select_db("PCLab", $con); $result = mysql_query("SELECT * FROM desktops"); echo "<table border=1>"; echo "<th>ID</th><th>Type</th><th>Name</th><th>Asset #</th><th>Service Tag</th><th>Status</th><th>Date Built</th><th>Lab Tech.</th><th>Lab Location</th><th>Deployed To</th><th>Tech.</th><th>Notes/Comments</th>"; while($row = mysql_fetch_array($result)) {   echo "<tr><td>".$row['ID']."</td><td>".$row['PC_TYPE']."</td><td>".$row['PC_NAME']."</td><td>".$row['PC_ASSET']."</td><td>".$row['PC_SERTAG']."</td><td>".$row['PC_STATUS']."</td><td>".$row['PC_BLDDATE']."</td><td>".$row['PC_BLDTECH']."</td><td>".$row['PC_LABLOC']."</td><td>".$row['PC_DEPLOYED']."</td><td>".$row['PC_BYWHO']."</td><td>".$row['PC_NOTES']."</td></tr>"; } echo "</table>"; mysql_close($con); ?> </body> </html> [/code] [b]add_pc.php[/b] [code] <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="Content-type" content="text/html;charset=UTF-8"> <title>Add a PC</title> </head> <body> <div> <a href="index.php">Home</a> <br><br> </div> <form action="add_pc_result.php" method="post"> <table> <tr><td>Type</td><td><select name="pc_type"> <option value="GX260">GX260</option><option value="GX270">GX270</option> <option value="GX270MT">GX270MT</option><option value="GX280">GX280</option> <option value="GX280MT">GX280MT</option><option value="Precision360">Precision 360</option> <option value="Precision370">Precision 370</option><option value="Precision380">Precision 380</option> <option value="Precision390">Precision 390</option><option value="GX410">GX410</option> <option value="GX420">GX420</option><option value="GX530">GX530</option> <option value="GX620">GX620</option> </select></td></tr> <tr><td>Name</td><td><input type="text" name="pc_name"></td></tr> <tr><td>Asset #</td><td><input type="text" name="pc_asset"></td></tr> <tr><td>Service Tag</td><td><input type="text" name="pc_sertag"></td></tr> <tr><td>Status</td><td><select name="pc_status"> <option value="Ready">Ready</option> <option value="Deployed">Deployed</option> <option value="In Repair">In Repair</option> <option value="Donation">Donation</option> <option value="In Progress">In Progress</option> <option value="Warehouse">Warehouse</option> <option value="Building">Building</option> <option value="Rebuilt">Rebuild</option> </select></td></tr> <tr><td>Date Built</td><td><input type="text" name="pc_blddate"></td></tr> <tr><td>Lab Tech.</td><td><input type="text" name="pc_labtech"></td></tr> <tr><td>Lab Location</td><td><input type="text" name="pc_labloc"></td></tr> <tr><td>Deployed To</td><td><input type="text" name="pc_deployedto"></td></tr> <tr><td>Tech.</td><td><input type="text" name="pc_tech"></td></tr> <tr><td>Notes/Comments</td><td><input type="text" name="pc_notes"></td></tr> <tr><td><input type="submit" value="Submit"></td><td><input type="reset"></td></tr> </table> </form> </body> </html> [/code] [b]add_pc_result.php[/b] [code] <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>Page title</title> </head> <body> <?php $con = mysql_connect("localhost","root",""); if(!$con) {   die('Could not connect: ' . mysql_error()); } mysql_select_db("PCLab", $con); mysql_query("INSERT INTO desktops (PC_TYPE, PC_NAME, PC_ASSET, PC_SERTAG, PC_STATUS, PC_BLDDATE, PC_BLDTECH, PC_LABLOC, PC_DEPLOYED, PC_BYWHO, PC_NOTES) VALUES ('$_POST[pc_type]', '$_POST[pc_name]', '$_POST[pc_asset]', '$_POST[pc_sertag]', '$_POST[pc_status]', '$_POST[pc_blddate]', '$_POST[pc_labtech]', '$_POST[pc_labloc]', '$_POST[pc_deployedto]', '$_POST[pc_tech]', '$_POST[pc_notes]')"); if(!mysql_query) {   die('Error: ' . mysql_error()); } else {   echo "<a href=index.php>Back to Main</a>";   echo "<br />"; echo "<a href=add_pc.php>Add another PC</a>";   echo "<br />";   echo "1 Record Added"; } mysql_close($con); ?> </body> </html> [/code] [b]delete_pc.php[/b] [code] <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>Remove a PC</title> </head> <body> <a href="index.php">Back to Main</a> <form action="delete_pc_result.php" method="post"> <table> <tr><td>Asset #</td><td><input type="text" name="pc_asset"></td> <tr><td><input type="submit" value="Submit"></td><td><input type="reset"></td></tr> </table> </form> </body> </html> [/code] [b]delete_pc_result.php[/b] [code] <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>Page title</title> </head> <body> <?php $con = mysql_connect("localhost","root",""); if(!$con) {   die('Could not connect: ' . mysql_error()); } mysql_select_db("PCLab", $con); mysql_query("DELETE FROM desktops WHERE PC_ASSET = '$_POST[pc_asset]'"); if(!mysql_query) {   die('Error: ' . mysql_error()); } else {   echo "<a href=index.php>Back to Main</a>";   echo "<br />"; echo "<a href=delete_pc.php>Remove another PC</a>";   echo "<br />";   echo "1 Record Removed"; } mysql_close($con); ?> </body> </html> [/code] MySQL fields: ID, PC_TYPE, PC_NAME, PC_ASSET, PC_SERTAG, PC_STATUS, PC_BLDDATE, PC_BLDTECH, PC_LABLOC, PC_DEPLOYED, PC_BYWHO, PC_NOTES
  13. Sorry I got caught up with some things here. I think really I just might be going about it the wrong way.  I dont really know.  I just wrote something up without really thinking about it and went from there.  (Yes I know I skipped the design process) For now Im just not going to worry about the ID numbers.  I think for maybe doing a "Update PC" type deal Ill use another field instead, a PC name or service tag perhaps.  Make it pretty after I get it fully functional. Speaking of which, should I make another topic for getting help with updating the page, or could I just squeeze it into this thread?
  14. Im a little picky, and it looks tacky to see the numbers jumping around like that. I wont be the only person using this page, and if it was, I wouldnt care.  Id rather not be asked about it. When I get to it, for the editing of rows, I thought using the ID to select which computer you would want to update.  Still working on that part though.
  15. Then would you have another suggestion/route that I should go?
  16. Hey everyone.  This is my first post here so bare with me :) Im also a newbie when it comes to any PHP programming, but Im getting the hang of it I think. Anyway onto my issue. I am creating a page for my work to show an inventory of the computers we have in our lab.  Its all in an Excel format, but only one person can use it at a time, at least edit it.  Its a little inconvenient when there are about 15 or 20 people that want to work with it. So, with my extensive knowledge here I be. I got the main portions of it together so far.  I can add a PC to the list, and remove a PC to the list.  And output a total list of everything.  So far so good. When I try to delete a row though is my problem.  I have it showing the ID column cause I was gonna later use it for editing computers (which I am stuck on by the way).  Well, this ID is the auto-increment number.  Here is the real problem. (Dodged it a bit didn't I?).  When I delete a row from the list, and then add a new PC, the ID number keeps going up instead of taking place of a new number, make sense? Example:  I have 10 rows.  I delete row 4.  Now I have 9 rows, listed 1-3 and 5-10.  Is there a way so that when I delete a row, that the ID number will change and keep everything numbered correctly?  (IE: Deleting row 4 makes it list 1-9) Sorry if this is a dodgey post, at work and Im doing about 10 things at once.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.