#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    2
    Rep Power
    0

    Unhappy Update table using isset() shows nothing


    Hi all I'm trying to update records from my table and i used isset() function which neither shows success message nor error. Where am I going wrong? Please suggest!!! Here's My CODE!!!!

    PHP Code:
    <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title></title> <link rel="stylesheet" href="main.css" type="text/css"> </head> <body background="media/dark_blue_background-wallpaper-1920x1200.jpg"> <center> <?php session_start(); if ($_SESSION['uname']) { ?> <div id="bus"> <p><img src="media/rk_logo2.png" height="100" width="220"></p> <ul> <li style="float: right; padding-right: 10px; font-family: sans-serif; font-weight: bold;">You are Logged in as, <?php echo "" $_SESSION['uname'] . "!"?></li> </ul><br> <div id="menu"> <ul> <li><a href="add.php">Add Bus and Service</a></li> <li><a href="edit.php">Change Bus and Service</a></li> <li><a href="del.php">Delete Bus and Service</a></li> <li><a href="show.php">View Bus and Service</a></li> </ul> </div> <?php $host "localhost"$uname "root"$pass "pranit"$db_name "rk_bookings"$tbl_name "bus_details"; if (isset($_POST['update'])) { $rate $_POST['rate']; $coname $_POST['coname']; $dest $_POST['destination']; mysql_connect("$host""$uname""$pass") or die(mysql_error()); mysql_select_db($db_name); $sql1 "UPDATE $tbl_name SET price='$rate' WHERE company='$coname' AND destination='$dest'"$result mysql_query($sql1); if ($result) { echo "Successful"; } else { echo mysql_error(); } } ?> </body> </html>
  2. #2
  3. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,141
    Rep Power
    9398
    If you take a look at your post you'll see all the code is on one line. That makes it hard for us to read. Please edit your post, select everything between the [php] tags, and paste your code again. Next time don't use the popup dialog to enter code: paste your code into the textbox, select it, and then click the code button.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    2
    Rep Power
    0

    update table using isset() function shows nothing


    Originally Posted by requinix
    If you take a look at your post you'll see all the code is on one line. That makes it hard for us to read. Please edit your post, select everything between the [php] tags, and paste your code again. Next time don't use the popup dialog to enter code: paste your code into the textbox, select it, and then click the code button.
    well am sorry i'm totally new here so never knew this.
    any way here u go

    PHP Code:
    <!DOCTYPE html>
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title></title>
            <link rel="stylesheet" href="main.css" type="text/css">
        </head>
        <body background="media/dark_blue_background-wallpaper-1920x1200.jpg">
        <center>
            <?php
            session_start
    ();
            if (
    $_SESSION['uname']) {
                
    ?>   
                <div id="bus">
                    <p><img src="media/rk_logo2.png" height="100" width="220"></p>
                    <ul>
                        <li style="float: right; padding-right: 10px; font-family: sans-serif; font-weight: bold;">You are Logged in as, <?php echo "" $_SESSION['uname'] . "!"?></li>
                    </ul><br><hr>
                    <?php
                
    }
                
    $host "localhost";
                
    $uname "root";
                
    $pass "pranit";
                
    $db_name "rk_bookings";
                
    $tbl_name "bus_details";

                
    mysql_connect("$host""$uname""$pass") or die("cannot connect");
                
    mysql_select_db("$db_name") or die("cannot select DB");

                
    $coname $_POST['coname'];
                
    $dest $_POST['destination'];
                
    $sql "SELECT * FROM $tbl_name WHERE company='$coname' and destination='$dest'";
                
    $result mysql_query($sql) or die(mysql_error());
                
    $rows mysql_fetch_array($resultMYSQLI_ASSOC);
                
    ?>
                <div id="disp">
                    <form action="update.php">
                        <table>                
                            <tr>
                                <th>Company Name</th>
                                <th>Bus Facilities</th>
                                <th>Depart Time</th>
                                <th>Arrival Time</th>
                            </tr>                                        
                            <tr>
                                <td><input type="text" name="coname" value="<?php echo $rows['company']; ?>"></td>
                                <td><input type="text" name="aminities" value="<?php echo $rows['aminities']; ?>"></td>
                                <td><input type="text" name="depart" value="<?php echo $rows['depart']; ?>"></td>
                                <td><input type="text" name="arrive" value="<?php echo $rows['arrive']; ?>"></td>
                            </tr>
                            <tr>
                                <th>Duration</th>
                                <th>Rate</th>
                                <th>From</th>
                                <th>To</th>                    
                            </tr>
                            <tr>
                                <td><input type="text" name="duration" value="<?php echo $rows['duration']; ?>"></td>
                                <td><input type="text" name="rate" value="<?php echo $rows['price']; ?>"></td>
                                <td><input type="text" name="start" value="<?php echo $rows['start']; ?>"></td>
                                <td><input type="text" name="destination" value="<?php echo $rows['destination']; ?>"></td>
                            </tr> 
                            <tr>
                                <th style="border: none; background: none;"></th>
                                <td></td>
                                <th style="border: none; background: none; float: right;"></th>                
                            </tr>
                        </table>
                        <button type="submit" name="submit">Update!</button><br><br><br>
                    </form>                                
                    <strong><a href="home.php">Click Here to Go Back!</a></strong>
                    <br><br><br>
                </div>
                </body>
                </html>
    Last edited by psonawane; January 11th, 2013 at 11:26 PM. Reason: Code was hard to read
  6. #4
  7. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,141
    Rep Power
    9398
    Well that's interesting.

    Originally Posted by psonawane
    well am sorry i'm totally new here so never knew this.
    any way here u go

    PHP Code:
    <!DOCTYPE html>
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title></title>
            <link rel="stylesheet" href="main.css" type="text/css">
        </head>
        <body background="media/dark_blue_background-wallpaper-1920x1200.jpg">
        <center>
            <?php
            session_start
    ();
            if (
    $_SESSION['uname']) {
                
    ?>   
                <div id="bus">
                    <p><img src="media/rk_logo2.png" height="100" width="220"></p>
                    <ul>
                        <li style="float: right; padding-right: 10px; font-family: sans-serif; font-weight: bold;">You are Logged in as, <?php echo "" $_SESSION['uname'] . "!"?></li>
                    </ul><br><hr>
                    <?php
                
    }
                
    $host "localhost";
                
    $uname "root";
                
    $pass "pranit";
                
    $db_name "rk_bookings";
                
    $tbl_name "bus_details";

                
    mysql_connect("$host""$uname""$pass") or die("cannot connect");
                
    mysql_select_db("$db_name") or die("cannot select DB");

                
    $coname $_POST['coname'];
                
    $dest $_POST['destination'];
                
    $sql "SELECT * FROM $tbl_name WHERE company='$coname' and destination='$dest'";
                
    $result mysql_query($sql) or die(mysql_error());
                
    $rows mysql_fetch_array($resultMYSQLI_ASSOC);
                
    ?>
                <div id="disp">
                    <form action="update.php">
                        <table>                
                            <tr>
                                <th>Company Name</th>
                                <th>Bus Facilities</th>
                                <th>Depart Time</th>
                                <th>Arrival Time</th>
                            </tr>                                        
                            <tr>
                                <td><input type="text" name="coname" value="<?php echo $rows['company']; ?>"></td>
                                <td><input type="text" name="aminities" value="<?php echo $rows['aminities']; ?>"></td>
                                <td><input type="text" name="depart" value="<?php echo $rows['depart']; ?>"></td>
                                <td><input type="text" name="arrive" value="<?php echo $rows['arrive']; ?>"></td>
                            </tr>
                            <tr>
                                <th>Duration</th>
                                <th>Rate</th>
                                <th>From</th>
                                <th>To</th>                    
                            </tr>
                            <tr>
                                <td><input type="text" name="duration" value="<?php echo $rows['duration']; ?>"></td>
                                <td><input type="text" name="rate" value="<?php echo $rows['price']; ?>"></td>
                                <td><input type="text" name="start" value="<?php echo $rows['start']; ?>"></td>
                                <td><input type="text" name="destination" value="<?php echo $rows['destination']; ?>"></td>
                            </tr> 
                            <tr>
                                <th style="border: none; background: none;"></th>
                                <td></td>
                                <th style="border: none; background: none; float: right;"></th>                
                            </tr>
                        </table>
                        <button type="submit" name="submit">Update!</button><br><br><br>
                    </form>                                
                    <strong><a href="home.php">Click Here to Go Back!</a></strong>
                    <br><br><br>
                </div>
                </body>
                </html>
  8. #5
  9. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,141
    Rep Power
    9398

IMN logo majestic logo threadwatch logo seochat tools logo