Jump to content

PHP MYSQL help


avincent

Recommended Posts

I have a problem I am trying to get figured out. I have gone over the code about a million times and cant see why it is not working. HELP :( I am trying to pull client requests from the database and display them. Once they are displayed I want the user to be able to check the "checkbox or pre-filled textbox like this code is" for completed and then it updates the database with the information "yes" or "true" so that the records with this info in that field do not display again.

 

------Start Page ------

<?php

//Create registration form (register.php)

include "db_connect.php";

 

if(!isset($_POST['submit']))

{

echo "<fieldset><legend><h2>Trouble Ticket List</h2></legend>";

 

$sql = "SELECT * FROM `online-form` WHERE `completed` = ''";

      $query = mysql_query($sql) or die(mysql_error());

 

      while ($row = mysql_fetch_array($query))

              {

              $name= $row["name"];

  $phone= $row["phone"];

  $email= $row["email"];

  $domain= $row["domain-name"];

              $comments= $row["comments"];

  $completed= $row["completed"];

             

 

?>

<form action="completed.php" method="post" >

 

        <dl>

        <dt >Name:</dt>

            <dd><?php echo "$name" ?><br><br></dd>

        </dl>

        <dl>

        <dt><label for="phone">Phone:</label></dt>

            <dd><?php echo "$phone" ?><br><br></dd>

        </dl>

<dl>

        <dt><label for="domain">Domain Name:</label></dt>

            <dd><?php echo "$domain" ?><br><br></dd>

        </dl>

        <dl>

        <dt><label for="email">Email Address:</label></dt>

            <dd><?php echo "$email" ?><br><br></dd>

        </dl>

        <dl>

        <dt><label for="comments">Comments:</label></dt>

            <dd><?php echo "$comments" ?><br><br></dd>

        </dl>

        <dl>

        <dt><label for="completed">Completed:</label></dt>

            <dd><input type="type" name="completed" id="completed" value="yes" /><br><br></dd>

        </dl>       

<?php

}

}

?>

<dl>

        <dt><input type="submit" name="submit" id="submit" value="Submit" /></dt>

        </dl>

    </fieldset>

</form>

 

 

--------Once the form has been submitted--------------

<?php

//Create registration form (register.php)

include "db_connect.php";

 

if(isset($_POST['submit']))

{

  $completed = $_REQUEST['completed'];

  $sql = "UPDATE `online-form` SET `completed` = '$completed'";

}else{

echo "your request has already been submitted";

}

?>

Link to comment
https://forums.phpfreaks.com/topic/180168-php-mysql-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.