Jump to content

Search the Community

Showing results for tags 'form if isset'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 1 result

  1. this page is used to display, add, edit and delete records from a table called 'valid_locations' so far, I can display the contents of the table (2 colums, 'id' and 'location') and the edit/delete button associated with each record. but when I click the edit button, the page displays the "confirm changes" button but no form elements to edit (from the section "//edit form" I'm stuck at this point and don't know where or how to go about moving forward. Cheers Zach <?php $pagetitle="Locations"; $menu="yes"; require 'header.php'; require 'dbvars.php'; require 'dafunc.php'; //set the referrer variable $self=htmlentities($_SERVER['PHP_SELF']); // Make a MySQL Connection $con=mysqli_connect($sqlhost,$sqluser,$sqlpass,$sqldb); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } //edit form if(isset($_POST['edit'])) { $id=$_POST['id']; $result = mysqli_query($con,"SELECT * FROM valid_locations WHERE id='$id'"); echo "$id"; if($result === false){ throw new Exception(mysqli_error($con)); } echo "<form action=\"$self\" method=\"post\">"; echo "<table>"; while($row = mysqli_fetch_array($result)) { echo "<tr><td>ID</td><td>" . $row['id'] . "</td></tr>"; echo "<input name=\"id\" type=\"hidden\" value=\"" . $row['id'] ."\" />"; echo "<tr><td>Location</td><td><input name=\"location\" type=\"text\" value=\"". $row['location'] ."\"/></td></tr>"; } echo "</table>"; echo "<input type=\"submit\" name=\"confirm\" id=\"confirm\" value=\"Confirm Changes\" />"; echo "</form>"; } //write the changes to the DB if(isset($_POST['confirm'])) { echo "write the changes to the database!"; } //delete a record if(isset($_POST['delete'])) { echo "delete the record!"; } //display the table containing the valid locations $result = mysqli_query($con,"SELECT * FROM valid_locations"); echo " <form action=\"$self\" method=\"post\"> <table> <tr><th>ID</th><th>Location</th></tr>"; while($row = mysqli_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['id'] . "</td>"; echo "<input type=\"hidden\" name=\"id\" id=\"" . $row['id'] . "\">"; echo "<td>" . $row['location'] . "</td>"; echo "<input type=\"hidden\" name=\"location\" id=\"" . $row['location'] . "\">"; echo "<td><input type=\"submit\" name=\"edit\" id=\"edit\" value=\"Edit\" /></td>"; echo "<td><input type=\"submit\" name=\"delete\" id=\"delete\" value=\"Delete\" /></td>"; echo "</tr>"; } echo "</table>"; echo "</form>"; mysqli_close($con); ?> </body> </html>
×
×
  • 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.