Jump to content

Edit Function doesn't pick the respective values


helpmeout

Recommended Posts

i'm creating a ticketing system and i need some assistance. The code directly below displays the database records and the delete works fine. The edit however isn't picking the values in the various fields.

<?Php
        require "config.php";           

        $page_name="currentout.php";  
        $start=$_GET['start'];
        if(strlen($start) > 0 and !is_numeric($start)){
        echo "Data Error";
        exit;
        }


        $eu = ($start - 0); 
        $limit = 10;                                 
        $this1 = $eu + $limit; 
        $back = $eu - $limit; 
        $next = $eu + $limit; 

        $nume = $dbo->query("select count(id) from receipt")->fetchColumn();


        echo "<TABLE class='t1'>";
        echo  "<tr><th>ID</th><th>Name</th><th>Pass</th><th>Amount</th><th>Action</th></tr>";


        $query=" SELECT * FROM receipt  limit $eu, $limit ";


        foreach ($dbo->query($query) as $row) {

        @$m=$i%2;
        @$i=$i+1;   
        echo "<tr class='r$m'><td>$row[id]</td><td>$row[name]</td><td>$row[phone_num]</td><td>$row[Amount]</td><td><a href='delete.php?id=$row[id]'>delete</a></td><td><a href='edit.php?id=$row[id]'>Edit</a></td></tr>";
        }
        echo "</table>";

        if($nume > $limit ){ 
        echo "<table align = 'center' width='50%'><tr><td  align='left' width='30%'>";

        if($back >=0) { 
        print "<a href='$page_name?start=$back'><font face='Verdana' size='2'>PREV</font></a>"; 
        } 

        echo "</td><td align=center width='30%'>";
        $i=0;
        $l=1;
        for($i=0;$i < $nume;$i=$i+$limit){
        if($i <> $eu){
        echo " <a href='$page_name?start=$i'><font face='Verdana' size='2'>$l</font></a> ";
        }
        else { echo "<font face='Verdana' size='4' color=red>$l</font>";}        
        $l=$l+1;
        }


        echo "</td><td  align='right' width='30%'>";

        if($this1 < $nume) { 
        print "<a href='$page_name?start=$next'><font face='Verdana' size='2'>NEXT</font></a>";} 
        echo "</td></tr></table>";

        } 
        ?>

The code below is edit.php. It's supposed to display the various fields when clicked to allow for editing but it isn't picking any field, PLEASE assist.

<?Php
require "config.php";   
$sql = "SELECT FROM receipt  WHERE ID=  :ID";

$stmt = $dbo->prepare($sql);
$stmt->bindParam(':ID', $_GET['id'], PDO::PARAM_INT);  
$stmt->execute();
?>

    <form action="update.php" method="post" enctype="multipart/form-data">
    <table align="center">
   <tr>
   <td> <label><strong>Full Names</strong></label></td>
     <td> <input type='text' name='name' value=" <?php echo $row['name']; ?>"  />
      <input type="hidden" name="id" value="<?php echo $id; ?> " /> <br /></td>
    </tr>
    <tr>

     <td><label><strong>ID/Passport No. </strong></label></td>
  <td> <input type="text" name="pass" value="<?php echo $row['id_passno']; ?> " /><br /></td>
  </tr>
   <tr>
    <td> <label><strong>Phone No. </strong></label></td>
    <td><input type="text" name="phone" value="<?php echo $row['phone_num']; ?>" /> <br /></td>
    </tr>
    <tr>

    <td> <label><strong>Amount (KShs.) </strong></label></td>
    <td><input type="text" name="amount" value="<?php echo $row['Amount']; ?> "/> <br /></td>
   </tr>
    <tr>
  <td> 
          <input type="reset" name="Reset" value="CANCEL" onClick="return confirm('Discard changes?');" />
      <br></td>


     <td> 
          <input type="submit" name="Submit2" value="SUBMIT" />
      </td>
   </tr>
</table>
</form>
Link to comment
Share on other sites

Do you have PHP errors and warnings enabled...and being shown? Note that you can do that by adding the following to the top of your edit.php script:

<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
?>
Of course, you'll want to remove the above code once you are done debugging.
 
 
Based on a cursory look through the code, it looks like $row is undefined in your edit.php script.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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