Jump to content

tet3828

Members
  • Posts

    107
  • Joined

  • Last visited

    Never

Everything posted by tet3828

  1. Is it possible to turn a $variable into a super_global ($_POST) without the user having to submit a form?
  2. Incase anyone cares.... this worked: case ($fieldLength >= 8):       <blah,blah,blah> }
  3. when I do that I get the following error: Parse error: parse error, unexpected T_IS_GREATER_OR_EQUAL in /home/content/t/e/t/tetunity/html/shell/data/edit.php on line 166
  4. In my script I have a "Switch" switch ($fieldLength) {       case "1":       <blah,blah,blah> it carries out just fine. how ever one of my cases is "if the number is equal to or greater than 8" this doesn't seem to work: switch ($fieldLength) {       case ">=8":       <yak,yak,yak> what do I need to type in the case to get the results I need? also how do I paste my script in this window with the proper colors? Im using dreamweaver. all black is driving me nuts
  5. It just "becomes" POST['id'] after it leaves the function? or do change the script to read POST['id']?
  6. [quote author=tet3828 link=topic=113841.msg462936#msg462936 date=1162666582] I am unable to retrieve the data that is sopposed to be posted by these forms.... any suggestions of why this is happening? function edit_what () { echo "Which value would you like to edit? <br />"; echo "<form method='post' action='{$_SERVER['PHP_SELF']}'>"; echo "<input type='hidden' name='id'  value='{$_GET['id']}'>"; echo "<input type='radio' name='edit' value='itemName'> Edit Name <br>"; echo "<input type='radio' name='edit' value='itemDesc'> Edit Description<br />"; echo "<input type='radio' name='edit' value='itemPrice'> Edit Price <br />"; echo "<input type='radio' name='edit' value='itemAvil'> Edit Avialibilty<br />"; echo "<input type=submit name=submit value=Submit /></form>"; } [/quote]
  7. function display_item () { $id = $_GET['id']; $qry = "SELECT itemName,itemCat,itemSub,itemId,itemAvil,itemPrice,itemDesc,itemSmall FROM `products` WHERE `itemId`=\"$id\""; $result = mysql_query($qry) or die(mysql_error()); echo "Listed below is the stored data for the item #$id <br /> Use the fields below the item table to modify the information."; while($row = mysql_fetch_array($result)) { echo "<table border=\"1\"><tr><td>".$row['itemName']."<td>Item ID# ".$row['itemId']."</td></td></tr>"; echo "<tr><td><img src=\"".$row['itemSmall']."\" /></td><td valign=top width=150>Description: ".$row['itemDesc']."</td>"; echo "</tr><tr><td>Price: $".$row['itemPrice']."</td><td>Avilibility: ".$row['itemAvil']." </td></tr>"; echo "<tr><td width=150>Catagory: ".$row['itemCat']."</td><td width=150>Sub-Catagory:".$row['itemSub']."</td></tr>"; } echo "</table>"; }
  8. I am unable to retrieve the data that is sopposed to be posted by these forms.... any suggestions of why this is happening? function edit_what () { echo "Which value would you like to edit? <br />"; echo "<form method='post' action='{$_SERVER['PHP_SELF']}'>"; echo "<input type='hidden' name='id'  value='{$_GET['id']}'>"; echo "<input type='radio' name='edit' value='itemName'> Edit Name <br>"; echo "<input type='radio' name='edit' value='itemDesc'> Edit Description<br />"; echo "<input type='radio' name='edit' value='itemPrice'> Edit Price <br />"; echo "<input type='radio' name='edit' value='itemAvil'> Edit Avialibilty<br />"; echo "<input type=submit name=submit value=Submit /></form>"; }
  9. Thanks C.V I tried turning this block of code into PHP from HTML because I needed it to be a [color=green]case[/color] in a [color=green]switch[/color] im having a hard time converting it from html to php. I fix one line and the next give me a parse error. the times you are requiered to use piticular brackets and quotes in this language ( or any other is throwing me off. I think the first line is okay but the rest I could really use some help. echo "<form method='post' action='$PHP_SELF}'>"; echo "<input type=hidden name=edit value='$_POST['edit']'>"; echo "<input type="hidden" name="id" value="{$_GET['id']}">"; echo "<input type="radio" name="newName" value="yes"> Yes <br />"; echo "<input type="radio" name="newName" value="no"> No <br />"; echo "<input type="submit" name="submit" value="Submit" />";
  10. Do I need to echo "" before that line? or is there some options other then echo ""?
  11. This should be an easy one... If this line of code was already inside a PHP bracket  ( [color=red]<?php  ?> [/color] ) how would I re-write it?    <form method="post" action="[color=red]<?[/color]php echo $PHP_SELF;[color=red]?>[/color]">
  12. I have a SQL database containing some product information. The php script displays the information of each item in the database. Below the [b]information display[/b] is some fields (soon to be 7) that give the user the option to modify the database. The user will most likely [i]not[/i] want to change all the information at once. say for instance he/she  just wants to [b]change the price but not the item name[/b]; in this case I want the user to be able to [b]leave the name field blank and fill in the price field[/b]. My script isn't smart enough yet to achieve this... I tried but I need a new approach I think. [b]should I use checkboxs near each form that needs updating to decide which fields get updated? or is there a way to revise my if statement I've attemped below?[/b] here is the whole script<br><?php [color=orange]/// if submit button is pressed[/color] if (isset($_POST['submit'])) { $id = $_GET['id']; $qry = "SELECT itemName,itemCat,itemSub,itemId,itemPrice,itemDesc,itemSmall FROM `products` WHERE `itemId`=\"$id\""; $result = mysql_query($qry) or die(mysql_error()); if(!empty($_POST['newName'])) {$newName =  $_POST['newName']; $query = "UPDATE products SET itemName='$newName' WHERE `itemId`=\"$id\""; $result = mysql_query($query); } else { $newName = "['itemName']"; $query = "UPDATE products SET itemName='$newName' WHERE `itemId`=\"$id\""; $result = mysql_query($query); } if(!empty($_POST['newDesc'])) {$newDesc =  $_POST['newDesc']; $query = "UPDATE products SET itemDesc='$newDesc' WHERE `itemId`=\"$id\""; $result = mysql_query($query); } else { $newDesc = "['itemDesc']"; $query = "UPDATE products SET itemDesc='$newDesc' WHERE `itemId`=\"$id\""; $result = mysql_query($query); } } ?> <?php /// Store Passed Data as $id $id = $_GET['id']; $qry = "SELECT itemName,itemCat,itemSub,itemId,itemPrice,itemDesc,itemSmall FROM `products` WHERE `itemId`=\"$id\""; /// Select data from  mySQL table $result = mysql_query($qry) or die(mysql_error()); ///  page header echo "Listed below is the stored data for the item #$id <br /> Use the fields below the item table to modify the information."; /// Display item data loop while($row = mysql_fetch_array($result)) { echo "<table border=\"1\"><tr><td>".$row['itemName']."<td>Item ID#".$row['itemId']."</td></td></tr>"; echo "<tr><td><img src=\"".$row['itemSmall']."\" /></td><td valign=top width=150>Description: ".$row['itemDesc']."</td>"; echo "</tr><tr><td>Price: $".$row['itemPrice']."</td><td>Avilibility: </td></tr>"; echo "<tr><td width=150>Catagory: ".$row['itemCat']."</td><td width=150>Sub-Catagory:".$row['itemSub']."</td></tr>"; } echo "</table>"; echo " "; ?> <form method="post" action="<?php echo $PHP_SELF;?>"> <p> Item Name: </p> <input type=hidden name=id value="<?=$_GET['id']?>"> <input type="text" name="newName" size="10" maxlength="10" value="<?=$row['itemName']?>" /><br /> <textarea name="newDesc" rows="3" cols="25" > <?=$row['itemDesc']?></textarea> <br /> <input type=submit name=submit value=Submit /> </form>
  13. I don't think my question was intruperted properly. Must be due to my lack of explanation. In my script an HTML script displays the current information of an SQL row. item name, price, description ect... the forms below that table give the user the option to modify the existing data say I have 4 forms and a submit button.... *name *price *description and *idnumber. but if the user only wants to modify the *name, he/she would leave *price *descripton *idnumber blank. As of now my script stores the empty field into the table ereasing the existing data. [b]is there a way to process the forms that are filed out and ignore the null fields?  [/b] I apologise if this is just a repeat of my last question. If I get no response ill assume I can use the suggestion from the prior script to do what I need. THanks
  14. So I began adding more forms to my edit item script. naturally I need my users to have the option to change any aspects of an item in my product database. Everything works fine whichever fields I add the data is modified and displayed. PERFECT Now my question is.... [b]what if the user only wants to change the itemName field and not itemDesc? he/she will leave the field they do not want to edit blank.[/b] [b]as of now my script doesn't have the potential to ignore the processing of a empty field. What to I need to add to my script to make this happen?[/b] I am guessing some something like IF <the form> = NULL THEN <new value> = <existing value> here is the revised script: (thanks to all phpfreak contributers) <?php /// if submit button is pressed if (isset($_POST['submit'])) { $id = $_GET['id']; $newName =  $_POST['newName']; $newDesc = $_POST['newDesc']; $query = "UPDATE products SET itemDesc='$newDesc', itemName='$newName' WHERE `itemId`=\"$id\""; $result = mysql_query($query); if ($result)  echo "<p>Update done.</p>"; else echo "<p>yeah that sux, shit didn't work</p>"; } ?> <?php /// Store Passed Data as $id $id = $_GET['id']; /// Select data from  mySQL table $qry = "SELECT itemName,itemCat,itemSub,itemId,itemPrice,itemDesc,itemSmall FROM `products` WHERE `itemId`=\"$id\""; $result = mysql_query($qry) or die(mysql_error()); ///  page header echo "Listed below is the stored data for the item #$id <br /> Use the fields below the item table to modify the information."; /// Display item data loop while($row = mysql_fetch_array($result)) { echo "<table border=\"1\"><tr><td>".$row['itemName']."<td>Item ID#".$row['itemId']."</td></td></tr>"; echo "<tr><td><img src=\"".$row['itemSmall']."\" /></td><td valign=top width=150>Description: ".$row['itemDesc']."</td>"; echo "</tr><tr><td>Price: $".$row['itemPrice']."</td><td>Avilibility: </td></tr>"; echo "<tr><td width=150>Catagory: ".$row['itemCat']."</td><td width=150>Sub-Catagory:".$row['itemSub']."</td></tr>"; } echo "</table>"; echo " "; ?> <form method="post" action="<?php echo $PHP_SELF;?>"> <p> Item Name: </p> <input type=hidden name=id value="<?=$_GET['id']?>"> <input type="text" name="newName" size="10" maxlength="10" value="<?=$row['itemName']?>" /><br /> <textarea name="newDesc" rows="3" cols="25" > <?=$row['itemDesc']?></textarea> <br /> <input type=submit name=submit value=Submit /> </form>
  15. ray and alpine... thank you. between your responses I was able to get the exact results I needed however... I don't understand some of the basics could someone explain the functions of thes line in detail <input type=hidden name=id value="<?=$_GET['id']?>"> <input type="text" name="newId" size="10" maxlength="10" value="<?=$row['itemName']?>" /> <input type=submit name=submit value=Submit />
  16. The porpose of the script below is to display and edit data from a mysql table. the row that is being edited is dependant upon the varible passed by the previous page. well the script DOES view the item and DOES change column of the row I want to edit. BUT the column I want to edit shows itself as a blank field until I enter data. In other words the script updates a null (or empty) value and overwrites the current data b4 the user gets to see what the exiting data was.. ??? I think my if statement is being carried out before the form data is entered.. why is that? and how can I avoid that? <?php /// if submit button is pressed if (!isset($_POST['submit'])) { $id = $_GET['id']; $newId =  $_POST['newId']; $query = "UPDATE products SET itemName='$newId' WHERE `itemId`=\"$id\""; $result = mysql_query($query); if ($result)  echo "<p>Update done.</p>"; else echo "<p>yeah that sux, it didn't work</p>"; } ?> <?php /// Store Passed Data as $id $id = $_GET['id']; /// Select data from  mySQL table $qry = "SELECT itemName,itemCat,itemSub,itemId,itemPrice,itemDesc,itemSmall FROM `products` WHERE `itemId`=\"$id\""; $result = mysql_query($qry) or die(mysql_error()); ///  page header echo "Listed below is the stored data for the item #$id <br /> Use the fields below the item table to modify the information."; /// Display item data loop while($row = mysql_fetch_array($result)) { echo "<table border=\"1\"><tr><td>".$row['itemName']."<td>".$row['itemId']."</td></td></tr>"; echo "<tr><td><img src=\"".$row['itemSmall']."\" /></td><td valign=top width=150>Description: ".$row['itemDesc']."</td>"; echo "</tr><tr><td>Price: $".$row['itemPrice']."</td><td>Avilibility: </td></tr>"; echo "<tr><td width=150>Catagory: ".$row['itemCat']."</td><td width=150>Sub-Catagory:".$row['itemSub']."</td></tr>"; } echo "</table>"; echo " "; ?> <form method="post" action="<?php echo $PHP_SELF;?>"> <p> Item Name: </p> <input type="text" name="newId" size="10" maxlength="10" value="" /> </form> </body>
  17. I tried to read up on posting and getting info but im still not fully grasping the concept. I added the line to explictlly modify the item... worked great. The script now changes the data in my MySQL database. However, I don't understand why the submit button is not working? Also when the page is refreshed after pressing enter for the field. it doesn't change the value in my table until the second time I submit data with the enter key?  ???
  18. My script is driving me nuts >:( The script gets the an item number from a previous page and displays all its stored info as an html table. Great! that part is cool. Then below the table is some html/php forms that give the use the option to modify the data. However, instead of modifying the data I am pinpointing; it ereases it from the mySQL database. why is this happening and what can I do to get the result I am expecting? I am obviously approaching this incorrectly. pls help me get back on track here. thanx again the script: <?php /// Store Passed Data as $id $id = $_GET['id']; /// Select data from  mySQL table $qry = "SELECT itemName,itemCat,itemSub,itemId,itemPrice,itemDesc,itemSmall FROM `products` WHERE `itemId`=\"$id\""; $result = mysql_query($qry) or die(mysql_error()); ///  page header echo "Listed below is the stored data for the item #$id <br /> Use the fields below the item table to modify the information."; echo "<br /> "; echo "<br />"; echo "<br />"; /// Display item data loop while($row = mysql_fetch_array($result)) { echo "<table border=\"1\"><tr><td>".$row['itemName']."<td>".$row['itemId']."</td></td></tr>"; echo "<tr><td><img src=\"".$row['itemSmall']."\" /></td><td valign=top width=150>Description:<br />".$row['itemDesc']."</td>"; echo "</tr><tr><td>Price: $".$row['itemPrice']."</td><td>Avilibility: </td></tr>"; echo "<tr><td width=150>Catagory: ".$row['itemCat']."</td><td width=150>Sub-Catagory:".$row['itemSub']."</td></tr>"; } echo "</table>"; echo "<br /> "; /// modification form and query ?> <?php if (!isset($_POST['submit'])) { $newId =  $_POST['newId']; $query = "UPDATE products SET itemName='$newId' WHERE `itemId`=\"$id\""; $result2 = mysql_query($query); if ($result2) echo "<p>Update done.</p>"; else echo "<p>yeah that sux, shit didn't work</p>"; } ?> <form method="post" action="<?php echo $PHP_SELF;?>"> <p> Item Name:<br /> </p> <input type="text" name="newName" size="10" maxlength="10" value="" /> <input type="submit" name="submit" value="Modify" /> </form> </body>
  19. Moving right along. Theses forums are helping me LEARN in INTREPRUT alot more than my 700 page php/mySQL book. I have a script that i've written. So far it selects the information form a row in a table and displays it in a conventinol html table. I want  to have forms below my table to edit the stored data. The only stored data I am looking to modify for now is item Name, Price and description as I have not even thought of a way to approach the avilibilty and catagories. Ill tackel that later. the comments I've made in the script show what I have so far and where I left off: Thanks in advance if anyone can help: <?php /// Store Passed Data as $id $id = $_GET['id']; /// Select data from  mySQL table $qry = "SELECT itemName,itemCat,itemSub,itemId,itemPrice,itemDesc,itemSmall FROM `products` WHERE `itemId`=\"$id\""; $result = mysql_query($qry) or die(mysql_error()); /// edit page header echo "Listed below is the stored data for the item #$id <br /> Use the fields below the item table to modify the information."; echo "<br /> "; echo "<br />"; echo "<br />"; /// Display item data loop while($row = mysql_fetch_array($result)) { echo "<table border=\"1\"><tr><td>".$row['itemName']."<td>".$row['itemId']."</td></td></tr>"; echo "<tr><td><img src=\"".$row['itemSmall']."\" /></td><td valign=top width=150>Description:<br />".$row['itemDesc']."</td>"; echo "</tr><tr><td>Price: $".$row['itemPrice']."</td><td>Avilibility: </td></tr>"; echo "<tr><td width=150>Catagory: ".$row['itemCat']."</td><td width=150>Sub-Catagory:".$row['itemSub']."</td></tr>"; } echo "</table>"; echo "<br / "; /// Display fields for data modification.... This is where Im stumped. Help :o if(!isset($_POST['submit'])) { die("<html><body><form action=\"".$_SERVER['PHP_SELF']."\" method=\"POST\"> ?>
  20. in the commented line below.... why is the whole H REF tag being echoed insted of the actual link between the tags? echo "<table border=\"1\"><tr><td>".$row['itemName']."</td></tr>"; echo "<tr><td><img src=\"".$row['itemSmall']."\" /></td>"; echo "</tr><tr><td>Price: $".$row['itemPrice']."</td>"; echo "</tr>"; echo "<tr><td><a href=\"edit.php?id=".$row['itemId']." />Edit This Item</a>";  \\\\this line actually echos the whole a href tag, what am I doing wrong? echo "</td></tr>"; echo "<br>"; echo "<br>";
  21. you php ppl rock my frickin socks ThankX -Trev
  22. and if it makes a difference... the currently stored entities on the mySQL table 'products' is as follows itemName itemDesc itemID itemPrice itemCat itemSub itemAval itemSmall itemImage
  23. yep I deff need help with the php. do I have to put some sort of form action inside the while loop?
  24. The script below gives the user a visual of items in the mySQL database I've setup. I added an edit button to the script (commented below) what script do I need to add in order to modify the entities of  an item's row in the DB when the edit button is pressed? :-\ <?php if(!isset($_POST['submit'])) { die("<html><body><form action=\"".$_SERVER['PHP_SELF']."\" method=\"POST\"> <select name=\"cat\"> <option value=\"Holiday\">Holiday</option> <option value=\"Animals\">Animals</option> </select> <input type=\"submit\" name=\"submit\" value=\"Search!\"> </form> </body> </html>"); } $qry = "SELECT itemName,itemPrice,itemSmall FROM `products` WHERE itemCat='".$_POST['cat']."'"; $result = mysql_query($qry) or die(mysql_error()); while($row = mysql_fetch_array($result)) { echo "<table border=\"1\"><tr><td>".$row['itemName']."</td></tr>"; echo "<tr><td><img src=\"".$row['itemSmall']."\" /></td>"; echo "</tr><tr><td>Price: $".$row['itemPrice']."</td>"; echo "</tr>"; echo "<tr><td> <input type=\"submit\" name=\"submit\" value=\"Edit This Item\">    \\\EDIT button   </form>"; echo "</td></tr>"; echo "<br>"; echo "<br>";   } echo "</table>"; ?>
  25. WOW thanks that worked like a charm... PHP is a bear. all the "", / , \ ect. how do you know where to put all that garbage. I've got a 700 page php book Novice to Professional but pin pointing that information (if its in there) would have been Impossible.
×
×
  • 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.