CroNiX Posted October 14, 2008 Share Posted October 14, 2008 Lee-Bartlett: <?php echo <form action="'.basename($_SERVER['PHP_SELF']).'" method="POST"> echo '<input type="hidden" name="id" value="' . $row['id'] . '">'; echo "<td> <input type=\"submit\" value=\"update\" name=\"updatebutton\" > </td>" echo "<td> <input type=\"submit\" value=\"update\" name=\"updatebutton\" > </td>" echo "<td><input type=\"submit\" value=\"delete\" name=\"deletebutton\" > </td>" echo "</form></td>" echo "</tr>" CroNiX: Your syntax is all messed up. You are missing quotes and semicolons everywhere... like your first echo doesn't start or end with a quote....you don't have a semicolon after each statement... Quote Link to comment Share on other sites More sharing options...
Lee-Bartlett Posted October 14, 2008 Author Share Posted October 14, 2008 Is this more cleaned up ? <?php echo "<form action="'.basename($_SERVER['PHP_SELF']).'" method="POST">"; (this is line 57) echo "<input type=\"hidden\" name=\"id\" value=\" . $row['id'] . \">"; echo "<td> <input type=\"submit\" value=\"update\" name=\"updatebutton\" > </td>"; echo "<td> <input type=\"submit\" value=\"update\" name=\"updatebutton\" > </td>"; echo "<td><input type=\"submit\" value=\"delete\" name=\"deletebutton\" > </td>"; echo "</form></td>"; echo "</tr>"; ?> error message im getting is Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in /home/nexodom/public_html/website/admin/du.php on line 57 Quote Link to comment Share on other sites More sharing options...
CroNiX Posted October 14, 2008 Share Posted October 14, 2008 Mostly cleaned up This: echo "<form action="'.basename($_SERVER['PHP_SELF']).'" method="POST">"; (this is line 57) should be: echo "<form action=\"".basename($_SERVER['PHP_SELF'])."\" method="POST">"; //some single quotes in there messing it up Quote Link to comment Share on other sites More sharing options...
Lee-Bartlett Posted October 14, 2008 Author Share Posted October 14, 2008 Now im getting Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/nexodom/public_html/website/admin/du.php on line 57 Quote Link to comment Share on other sites More sharing options...
CroNiX Posted October 14, 2008 Share Posted October 14, 2008 ah, sorry, didn't escape the quotes around post. method="POST" in that line should be: method=\"POST\" Quote Link to comment Share on other sites More sharing options...
Lee-Bartlett Posted October 14, 2008 Author Share Posted October 14, 2008 Now i got Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/nexodom/public_html/website/admin/du.php on line 58 maybe i should chaqnge that line all together? its this line here echo "<input type=\"hidden\" name=\"id\" value=\" . $row['id'] . \">"; Quote Link to comment Share on other sites More sharing options...
CroNiX Posted October 14, 2008 Share Posted October 14, 2008 The problem is in this part: value=\" . $row['id'] . \">"; You escaped the quote but didn't add an end quote here: value=\" And same thing here, you didn't start the quote and then escape a quote, you just escaped a quote: $row['id'] . \">"; much simpler to do: [echo '<input type="hidden" name="id" value="' . $row['id'] . '">'; or even better, do it in html and then add the php where you need it. You are confusing yourself. ?> (end the php) <input type="hidden" name="id" value="<?php echo $row['id']; ?>"> <?php //...continue php code Quote Link to comment Share on other sites More sharing options...
Lee-Bartlett Posted October 14, 2008 Author Share Posted October 14, 2008 If i do it in html, how do i get it to automatically enter all these submit buttons so when a new entry is put in, there is one in that row to. now im getting this error message, Parse error: syntax error, unexpected '[' in /home/nexodom/public_html/website/admin/du.php on line 58 i cant see these ending. How would you add an update button to a echoed database? so when i click that button, it pulls the data from the row it is and alows me to update it on my update page Quote Link to comment Share on other sites More sharing options...
CroNiX Posted October 14, 2008 Share Posted October 14, 2008 Looks like I somehow added a '[' preceding the echo statement and you copied it. Just remove it. You should be able to find these errors by the error messages... Quote Link to comment Share on other sites More sharing options...
Lee-Bartlett Posted October 14, 2008 Author Share Posted October 14, 2008 I didnt see that, must be late, ok thats got all of the form showing, how would i go about making the update button actually take the record in the row and go to my update page. I really appreciate all the effort here, i know i must be a pain Quote Link to comment Share on other sites More sharing options...
CroNiX Posted October 15, 2008 Share Posted October 15, 2008 Now that you've gone through all of that, let me say it would be easier to use a link instead of a form If you replaced the whole form thing we were just working on with something like: echo '<a href="http://mysite.com/process.php?action=update&id=' . $row['id'] . '">Update</a>'; echo "  "; echo '<a href="http://mysite.com/process.php?action=delete&id=' . $row['id'] . '">Delete</a>'; Obviously process.php should be changed to your script name. Then in your process.php: $action = isset($_GET['action']) ? $_GET['action'] : ""; $id = isset($_GET['id']) ? $_GET['id'] : ""; if(!empty($action) && !empty($id)) //check to see if $action and $id have values { switch($action) { case "update": //grab the data from the db using the $id, create a form and populate the form 'values' with the data; //then when you submit the form have it 'UPDATE' the database where the id=$id break; case "delete": //prompt if user is sure they want to delete //then just DELETE it from the database using WHERE id=$id break; } } Those are the basics, I don't want to write it all out... Quote Link to comment Share on other sites More sharing options...
Lee-Bartlett Posted October 15, 2008 Author Share Posted October 15, 2008 Thank you , im still learning so im not quite sure whats the quickest ways to go about stuff:P thanks for your help Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.