Page 3 of 3 FirstFirst 123
Results 21 to 28 of 28

Thread: php - mysql admin screen +++ Help Please

  1. #21
    Join Date
    Mar 2007
    Posts
    51
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    yea i had to change it to <a href="edit.php?RegID='.$u['RegID'].'">Edit</a>

    guess it didnt like .qry

  2. #22
    Join Date
    Aug 2006
    Location
    Ohio
    Posts
    266
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    ok, glad its working correctly now
    Thanks DD, you saved me countless times

  3. #23
    Join Date
    Apr 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi mdcloud,

    those edit page and delete page u showed on page 2 are not working.

    Would you mind posting the working edit page and delete page codes here?

    Thanks alot.

  4. #24
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    What isn't working on it? Do you get an error message or anything like that? The code that was posted should work (syntax wise).
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  5. #25
    Join Date
    Apr 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    It wont update and delete..

    here is the main page:
    Code:
    <title>Supplier Projects</title>
    <?php 
     
     require('../Connections/config.php');
     require('../Connections/opendb.php');
     
    $result = mysql_query( "SELECT * FROM supplier_projects ORDER BY Supplier ASC " )
    or die("SELECT Error: ".mysql_error());
    $num_rows = mysql_num_rows($result);
    print "There are $num_rows records.<P>";
            
           if ($num_rows < 1) { 
                echo 'There are no products in the database 
                    <br /> 
                <a href="option.php">&lt;&lt;Back</a>'; 
            } 
             
           else { 
             
                // Start table to display users 
                echo ' 
                    
                     
                <table border="1" width"800"> 
                    <tr> 
    <td></td><td></td>
                        <td><b>Supplier</b></td> 
                        <td><b>Project</b></td>
                         <td><b>Project Name</b></td>
                        <td><b>Project Code</b></td>
                        <td><b>sp_pri</b></td> 
                    </tr>'; 
                     
                // For each user found 
                while($u = mysql_fetch_array($result)) { 
                 
                    // Show data for each user 
                    echo ' 
                    <tr> 
    					<td><a href="updateproject2.php?sp_pri='.$u['sp_pri'].'">Edit</a></td>
    					<td><a href="deleteproject1.php?act=chk_del&id='.$u['sp_pri'].'">Delete</a></td>
    					<td>'.$u['Supplier'].'</td>
                        <td>'.$u['Project'].'</td> 
                        <td>'.$u['Project_Name'].'</td>
                        <td>'.$u['Project_Code'].'</td> 
                        <td>'.$u['sp_pri'].'</td>
                        
                    </tr>'; 
                } 
                 
                // End table 
                echo ' 
    			<form method="POST" action="insertproject1.php">
    <input type="submit" value="Insert New">
    </form>
                </table><br><br><a href="bih.html">Back</a>'; 
                
            } 
     
    
    
    
    
    ?>
    here is the edit page:
    Code:
    <?php
    include('../Connections/config.php');
    include('../Connections/opendb.php');
     
    
    // Get the user id
    $getid = $_GET['sp_pri'];
    echo $getid;
    
    // Get data from user with the specified id
    $query="SELECT * FROM supplier_projects WHERE sp_pri ='$getid'"; 
    $result=mysql_query($query) or die ('Error Getting User Data! <br />' .mysql_error());
    $chk = mysql_num_rows($result);
    $u = mysql_fetch_array($result);
    
    // If edit not hit
    if (!$_POST['edit']) {
    
        // If user id returns no results
        if ($chk < 1) {
            echo 'The supplier project does not exist!';
        }
        else {
            // Edit Form
            ?>
        <!-- Edit Form --><title>Update Project</title>
            <form method="post" action="">
                <table width="250">
                    <tr>
                        <td>Supplier:</td>
                        <td><input type="text" name="supplier" value="<?php echo $u['Supplier'] ?>" /></td>
                    </tr>
                    <tr>
                        <td>Project:</td>
                        <td><input type="text" name="project" value="<?php echo $u['Project'] ?>"  size="50"/></td>
                    </tr>
                    <tr>
                        <td>Project Name:</td>
                        <td><input type="text" name="projectname" value="<?php echo $u['Project_Name'] ?>" size="100"/></td>
    				<tr>
                        <td>Project Code:</td>
                        <td><input type="text" name="projectcode" value="<?php echo $u['Project_Code'] ?>" /></td>
                    </tr>
    				
                    <tr>
                        <td colspan="2"><input type="submit" name="edit" value="Update" /></td>
                    </tr>
                </table>
            </form>
        <!-- /Edit Form -->
            <?php
    }
    
    // If edit was hit
    if ($_POST['edit']) {
        $supp = $_POST['Supplier'];
        $proj = $_POST['Project'];
        $projname = $_POST['Project_Name'];
    	$projcode = $_POST['Project_Code'];
        
            // Update data
       $update = mysql_query("UPDATE supplier_projects SET sp_pri = '$supp$proj', Supplier='$supp', Project = 'proj', Project_Name = 'projname',Project_Code = 'projcode' WHERE sp_pri = '$getid'") or die ('Error Updating Data! <br />' .mysql_error());
            
            echo 'Update successfull';
     
    }
    }
    
    ?>
    here is the delete page:
    Code:
    <title>Delete Project</title>
    <?php    
      include('../Connections/config.php');
      include('../Connections/opendb.php');
    
    // If delete was hit, ask for confirm
    if ($_GET['act'] == 'chk_del') {
        $getid = $_GET['sp_pri'];
        echo 'Are you sure you want to delete this record? 
            <br />
        <a href="deleteproject1.php?act=delete&sp_pri='.$getid.'">Yes, delete it</a> | <a href="javascript:history.back();">Cancel</a>';
    }
    
    // If delete confirmed
    elseif ($_GET['act'] == 'delete') {
        $getid = $_GET['sp_pri'];
        $del = mysql_query("DELETE FROM supplier_projects WHERE sp_pri='$getid'") or die ('Error Deleting User! <br />' .mysql_error());
        echo 'The record has been deleted.
            <br />
        <form method="POST" action="editproject2.php">
    
    <input type="submit" value="Back to Project Forms">
    </form>';
    }
    
    ?>
    Please help me. Thanks a lot !

  6. #26
    Join Date
    Apr 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    the delete is working, now working on edit

  7. #27
    Join Date
    Apr 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    finally fixed the edit problem too..
    dam small mistake..

    thanks everyone

  8. #28
    Join Date
    Mar 2007
    Posts
    51
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    sorry chubcity,

    just looked back at this thread. would have posted earlier if i saw it.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •