Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: php and sql

  1. #1
    New to the CF scene
    Join Date
    Nov 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question php and sql

    i want to create submit button...when we click for submit it auto show all information about that name..just click no need to insert any input

    here the code

    <html>
    <head><title>Show Item</title></head>
    <body bgcolor ='white'>
    <center>
    <br>
    <br>
    <br>
    <h3><b>Item </b></h3>
    <br>

    <tr>
    <table background="formal_background.gif" width=1100 height=200>
    <td>
    </center>


    <?php

    $con=mysqli_connect("127.0.0.1","root","","system");
    // Check connection
    if (mysqli_connect_errno())
    {
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
    }



    $name='item_used';


    $result1 = mysqli_query($con,"SELECT * FROM `item_used` ");




    if ($result1) {

    echo "<center><br><br><br><br>";
    echo "<table border='1'>
    <tr>
    <th>Item Name</th>


    </tr>";

    while($row = mysqli_fetch_array($result1))
    {
    echo "<tr>";
    echo "<td>" . $row['item_name'] . "</td>";;
    echo "<td>" . "<a href='try3.php'><input type='submit' name='submit' value='show'></a>" . "</td>";
    echo "</tr>";
    }
    echo "</table>";
    echo " </center>";
    }



    mysqli_close($con);




    ?>


    <br><br><br>
    <center>
    <script language="javascript">
    <!--
    today = new Date();
    document.write("<BR>Time : ", today.getHours(),":",today.getMinutes(), "| |");
    var days= ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
    var today = new Date();
    document.write(days[today.getDay()],"| |");
    document.write("Date : ", today.getDate(),"/",today.getMonth()+1,"/",today.getFullYear());
    //-->
    </script>
    <br>
    <br>
    <br>
    </center>
    </form>
    <table align='right'>
    <tr>
    <td><b><a href='homepage.php'>| Sign Out |</a></b></td>
    <td><b><a href='staff_manu.php'>| Main Menu |</a></b></td>
    <td><b><a href='item_menu.php'>| Item Menu |</a></b></td>
    </tr>
    </table>

    </body>
    </html>


    but for another code to show i didnt know..help me.. :'(

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    There's two options, the first is to not use the submit button and just use the anchor. The second is to use the submit button without the anchor. Technically you can render it to appear like it is a button as well.

    In either case, you are required to provide it with some input information to pass it to the next script. HTTP is stateless, and without providing all information required it hasn't a clue what you are trying to do since it doesn't know what you've previously done. So that would require either a querystring for the anchor or a value for the submit button.
    PHP Code:
    printf('<a href="try3.php?itemid=%s">%s</a>'$row['item_name'], $row['item_name']); 
    For example. I don't suggest the form object since you'd need to either show the value you intend to submit, or use a name="itemid[$row['item_name']]" approach which means you need to deal with it as an array.
    When clicked, the $_GET or $_POST will contain the itemid querystring, depending on if you use a get or post request.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 


  •  

    Posting Permissions

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