Jump to content

captain_scarlet87

Members
  • Posts

    43
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

captain_scarlet87's Achievements

Member

Member (2/5)

0

Reputation

  1. Hey, Just a simple one hopefully. I need help displaying the appropriate radio button as checked when matching data in a table. At the moment the code snippet below just displays the <% content code on the page when it shouldn't. Cheers. <p> <b>Administrator? </b> <input type="radio" name="admin" value="1" <% If admin="1" Then Response.Write("checked") %> /> Yes <input type="radio" name="admin" value="0" <% If admin="0" Then Response.Write("checked") %> /> No </p>
  2. Hi, I need help trying to add the two buttons to another page: echo ("<td> <input type='button' onClick=\"window.location='edit_form_instructions.php?id={$row['instructions_id']}';\" value='Edit' /></td>"); echo ("<td> <input type='button' style='color: red' onClick=\"window.location='delete_instructions.php?id={$row['instructions_id']}';\" value='Delete' /></td></tr></table>");} This is the page they need to be added to: <?php # Script 13.8 - search_results(admin).php // This is the login page for the site. // Include the configuration file for error management and such. require_once ('./includes/config.inc.php'); // Set the page title and include the HTML header. $page_title = 'Search Results'; include ('./includes/header.html'); ?> <h1>View Instructions</h1> <?php // TAKE THE INFORMATION FROM FORM. $search = $_GET['search']; // IF THERE IS NOT A KEYWORD GIVE A MISTAKE. if (!$search) echo "You didn't enter a keyword"; else { echo "<fieldset><td>You searched for: <strong>$search </strong></td>"; require_once ('../mysql_connect.php'); // Connect to the database. //QUERY IS THE CODE WHICH WILL MAKE THE SEARCH IN YOUR DATABASE. //I WROTE AN EXPLANATION ABOUT IT AFTER THE CODE. $query="SELECT * FROM uploaded_instructions WHERE ( title) LIKE('%$search%')"; $result1 = MySQL_query($query); if(!$result1) { echo MySQL_error()."<br>$query<br>"; } if(MySQL_num_rows($result1) > 0) { echo "<table width='750' align='center' border='0' cellspacing='0' cellpadding='0'>"; while($result2 = MySQL_fetch_array($result1)) { echo '<br><tr><td><strong><a href="view_instructions.php?instructions_id='.$result2['instructions_id'].'">'.$result2['title'].'</strong></td></tr>'; } echo "</table></fieldset"; }else { echo "No Results were found in this category.<br>"; }echo "<br>"; } include ('./includes/footer.html'); ?> I need them echoed alongside the view_instructions a href already there. I've tried myself however the buttons don't seem to appear there at all whether working or not. Please help if you can. Thanks.
  3. Hi, I just need help making the 'Edit' link in the following code a button. if(isset($_POST['topic'])){ // anything posted???? require_once ('../mysql_connect.php'); // Connect to the database. $dState = $_POST["topic"]; $sqlQuery = "SELECT title, instructions_id FROM uploaded_instructions WHERE topic=\"$dState\""; $result = mysql_query($sqlQuery); while ($row=mysql_fetch_array($result)){ echo ("<p><tr><td>• <a href=view_instructions.php?instructions_id=$row[instructions_id]> $row[title] </a></td>"); echo ("<td> | <a href=edit_form_instructions.php?id=$row[instructions_id]> Edit <a/></td></tr></p>");} } // end anything posted??? I've tried: echo ("<td><form action="edit_form_instructions.php?id=$row[instructions_id"><input type="Submit" value="Edit"></form></td></tr></p>");} but this error appears: Parse error: syntax error, unexpected T_STRING in C:\wamp\www\html\filter(admin).php on line 47 Help me please! Thanks.
  4. Oops my fault, had a extra } that wasn't needed. By removing that the id is being passed over and the text in the title box is showing but nothing in the instructions box. Exactly the same code is used for both except the instructions one is a textarea, this shouldn't make a difference though??? b>Title: </b> <input type="text" name="title" size="20" value="<?php echo $row['title'];?>"> </p> <p> <b>Instructions: </b><br><textarea name="instructions" maxlength="1000" rows="30" cols="120" value="<?php echo $row['instructions'];?>" /></textarea> </p> </fieldset> <p> Anyone know why this is happening?
  5. The instructions_id is not displaying in the url to be passed over to the edit_form_instructions.php page. So must be a problem with the filter(admin).php page but can't seem to find it. The weird thing is the instructions_id is being passed over from the filter page with the view instructions function that works fine but no with the edit link.
  6. I echoed the query: SELECT * FROM uploaded_instructions where instructions_id='' It seems that 'id' isn't being passed over. Any ideas?
  7. Hi, I've got 3 bits of code: filter(admin).php allows the user to filter the results using a drop down menu. Each result then have an edit button next to each which takes them to the edit_form_instructions page. edit_form_instructions.php should display the form with the current data already in it, however I'm only getting the form to appear with no data inside. Tried to submit some different content into the blank boxes but the database table did not update. edit_data_instructions deals with updating the data. Can you please help, I am getting no error messages to guide me where the problem is. <?php # Script 13.8 - filter(admin).php // Include the configuration file for error management and such. require_once ('./includes/config.inc.php'); // Set the page title and include the HTML header. $page_title = 'filter'; include ('./includes/header.html'); ?> <h1>View Instructions:</h1> <fieldset><p><b>Search instructions by keyword:</b><p> <form action="search_results.php" method="get"> <div align="center"> <p> <input name="search" type="text" size="30"/> <input name="submit" type="submit" value="Search" /> </p> </div> </form> <p><b>Filter instructions:</b><p> <form action="filter(admin).php" method="post"> <select name="topic"> <option value="crm">CRM</option> <option value="email">Email</option> </select> <input type="submit" value="Filter" /> </form> <br> <?php if(isset($_POST['topic'])){ // anything posted???? require_once ('../mysql_connect.php'); // Connect to the database. $dState = $_POST["topic"]; $sqlQuery = "SELECT title, instructions_id FROM uploaded_instructions WHERE topic=\"$dState\""; $result = mysql_query($sqlQuery); while ($row=mysql_fetch_array($result)){ echo ("<tr><td><a href=view_instructions.php?instructions_id=$row[instructions_id]> $row[title] </a> | </td>");} // <tr><td>$row[title]</td> echo ("<td><a href=\"edit_form_instructions.php?id=$row[instructions_id]\"><b>Edit</b></a></td>"); include ('./includes/footer.html'); } // end anything posted??? include ('./includes/footer.html'); ?></fieldset> <?php # Script 13.8 - edit_form_instructions.php // Include the configuration file for error management and such. require_once ('./includes/config.inc.php'); // Set the page title and include the HTML header. $page_title = 'Edit Instructions'; include ('./includes/header.html'); ?> <h1>Edit Instructions</h1> <?php require_once ('../mysql_connect.php'); // Connect to the database. $id = mysql_real_escape_string($_GET['id']); $order = "SELECT * FROM uploaded_instructions where instructions_id='$id'"; $result = mysql_query($order); $row = mysql_fetch_array($result); ?> <fieldset> <form method="post" action="edit_data_instructions.php"> <input type="hidden" name="id" value="<?php echo $row['instructions_id'];?>"> <p> <b>Title: </b> <input type="text" name="title" size="20" value="<?php echo $row['title'];?>"> </p> <p> <b>Instructions: </b><br><textarea name="instructions" maxlength="1000" rows="30" cols="120" value="<?php echo $row['instructions'];?>" /></textarea> </p> </fieldset> <p> <div align="center"><input type="submit" name="submit value" value="Edit"></div> </p> <?php // Include the HTML footer. include ('./includes/footer.html'); ?> <?php //edit_data.php require_once ('../mysql_connect.php'); // Connect to the database. $id = mysql_real_escape_string($_POST['id']); // added this, need to get the id from $_POST $title = mysql_real_escape_string($_POST['title']); $instructions = mysql_real_escape_string($_POST['instructions']); $order = "UPDATE uploaded_instructions SET title='$title', instructions='$instructions' WHERE instructions_id='$id'"; mysql_query($order); header("location:filter(admin).php"); ?>
  8. Tried this but this error came up: An error occurred in script 'C:\wamp\www\html\view_instructions.php' on line 26: Use of undefined constant instructions - assumed 'instructions' Any further ideas?
  9. Hi, I need the submitted textarea called instructions to record all the blank spaces that are within the box. For example I have submitted some data such as this: 1. Do this. 2. Do that. There is a space between them however when I display the contents it comes up as: 1. Do this. 2. Do that. So basically I need exactly the same formating to be displayed as to what has been submitted in the form. Please help me. Thanks. Code submitting the form: <?php # Script 13.6 - upload_instructions.php // Include the configuration file for error management and such. require_once ('./includes/config.inc.php'); // Set the page title and include the HTML header. $page_title = 'Upload Instructions'; include ('./includes/header.html'); if (isset($_POST['submitted'])) { // Handle the form. require_once ('../mysql_connect.php'); // Connect to the database. $topic = $_POST['topic']; // Check for a title. if (eregi ('^[[:alpha:]\.\' \-]{2,50}$', stripslashes(trim($_POST['title'])))) { $t = escape_data($_POST['title']); } else { $t = FALSE; echo '<p><font color="red" size="+1">Please enter your title.</font></p>'; } // Check for a instructions. if (strlen (stripslashes(trim($_POST['instructions'])))) { $i = escape_data($_POST['instructions']); } else { $i = FALSE; echo '<p><font color="red" size="+1">Please enter your instructions.</font></p>'; } if ($t && $i) { // If everything's OK. // Add the user. $query = "INSERT INTO uploaded_instructions (title, topic, instructions) VALUES ('$t', '$topic', '$i' )"; $result = mysql_query ($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error()); if (mysql_affected_rows() == 1) { // If it ran OK. // Finish the page. echo '<h3>Instructions submission successful!</h3>'; include ('./includes/footer.html'); // Include the HTML footer. exit(); } else { // If it did not run OK. echo '<p><font color="red" size="+1">You could not be registered due to a system error. We apologize for any inconvenience.</font></p>'; } } else { // If one of the data tests failed. echo '<p><font color="red" size="+1">Please try again.</font></p>'; } mysql_close(); // Close the database connection. } // End of the main Submit conditional. ?> <h1>Upload Instructions</h1> <form action="upload_instructions.php" method="post"> <fieldset> <p><b>Title:</b> <input type="text" name="title" size="100" maxlength="100" value="<?php if (isset($_POST['topic'])) echo $_POST['title']; ?>" /></p> <p><b>Topic:</b> <select name="topic"><option value="crm">CRM</option><option value="email">Email</option><option value="internet">Internet</option><option value"other">Other</option><p></select> <p><b>Instructions:</b><br><textarea name="instructions" maxlength="1000" rows="30" cols="120" value="<?php if (isset($_POST['instructions'])) echo $_POST['instructions']; ?>" /></textarea> </p> <div align="center"><input type="submit" name="submit" value="Upload Instructions" /></div> <input type="hidden" name="submitted" value="TRUE" /> </form> <?php // Include the HTML footer. include ('./includes/footer.html'); ?> Code to display the submitted data: <?php # Script 13.8 - view_instructions.php // Include the configuration file for error management and such. require_once ('./includes/config.inc.php'); // Set the page title and include the HTML header. $page_title = 'View Instructions'; include ('./includes/header.html'); $instructions_id = $_GET['instructions_id']; ?> <h1>View Instructions:</h1> <fieldset> <table> <tr> <td> <table> <?php require_once ('../mysql_connect.php'); // Connect to the database. $order = "SELECT * FROM uploaded_instructions WHERE instructions_id=$instructions_id"; $result = mysql_query($order); while ($row=mysql_fetch_array($result)){ echo ("<tr><td><b>$row[title]</b></td>"); echo ("<tr><td></td>"); echo ("<tr><td>$row[instructions]</td>"); } ?> </table> </td> </tr> </table> </fieldset> <?php include ('./includes/footer.html'); ?>
  10. Thank you mate! That has got to the quickest response i've ever got on here and it was correct! Many thanks again.
  11. Hi, Can anyone tell me where I have gone wrong with this code? It's aim is to display all the usernames with an edit button alongside each to take you to a different page displaying the username in a textbox which can be edited. Up to this point it all works correctly however when I change the username it doesnt update in the database table. No error messages are appearing either. Thanks. edit.php: <?php # Script 13.8 - edit.php // Include the configuration file for error management and such. require_once ('./includes/config.inc.php'); // Set the page title and include the HTML header. $page_title = 'Edit Users'; include ('./includes/header.html'); ?> <table> <tr> <td align="center"><p><h1>Edit Users:</h1></p></td> </tr> <tr> <td> <table border="1" bgcolor=grey> <?php require_once ('../mysql_connect.php'); // Connect to the database. $order = "SELECT username FROM users"; $result = mysql_query($order); while ($row=mysql_fetch_array($result)){ echo ("<tr><td>$row[username]</td>"); echo ("<td><a href=\"edit_form.php?id=$row[username]\">Edit</a></td>"); echo ("<td><a href=\"delete.php?id=$row[username]\">Delete</a></td></tr>"); } ?> </table> </td> </tr> </table> <?php include ('./includes/footer.html'); ?> edit_form.php: <table border=1> <tr> <td align=center>Form Edit Employees Data</td> </tr> <tr> <td> <table> <?php require_once ('../mysql_connect.php'); // Connect to the database. $id = mysql_real_escape_string($_GET['id']); $order = "SELECT username FROM users where username='$id'"; $result = mysql_query($order); $row = mysql_fetch_array($result); ?> <form method="post" action="edit_data.php"> <input type="hidden" name="id" value="<?php echo $row['username'];?>"> <tr> <td>Username</td> <td> <input type="text" name="username" size="20" value="<?php echo $row['username'];?>"> </td> </tr> <tr> <td align="right"> <input type="submit" name="submit value" value="Edit"> </td> </tr> </form> </table> </td> </tr> </table> edit_data.php: <?php //edit_data.php require_once ('../mysql_connect.php'); // Connect to the database. $username = mysql_real_escape_string($_POST['username']); $order = "UPDATE users SET username='$username' WHERE username='$id'"; mysql_query($order); header("location:edit.php"); ?>
  12. This is the error I now get: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'video' at line 1 Can't see what's up, the video in the player is working fine. Any advice?
×
×
  • 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.