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 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Aug 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile Fetch mysql data and insert into a form

    Hi, I have a form that i want to be able to reload mysql data into it and a user can click the next or previous button to scroll through the data and update it

    my form is

    <form action="addrest1.php" method="POST">
    <table width="264" border="0" cellspacing="2">
    <tr>
    <td width="180">&nbsp;</td>
    <td width="10">&nbsp;</td>
    <td width="62">&nbsp;</td>
    </tr>
    <tr>
    <td><label>Resturant Name: </label>&nbsp;
    <label for="name"></label>
    <input type="text" value="" name="name" id="name"></td>
    <td>&nbsp;</td>
    <td><input type="submit" name="first5" id="first5" value="ADD"></td>
    </tr>
    <tr>
    <td>Location:
    <input type="text" name="location" id="location"></td>
    <td>&nbsp;</td>
    <td><input type="button" name="first6" id="first6" value="UPDATE"></td>
    </tr>
    <tr>
    <td>Address:
    <input type="text" name="address" id="address"></td>
    <td>&nbsp;</td>
    <td><input type="button" name="first7" id="first7" value="DELETE"></td>
    </tr>
    <tr>
    <td>Email:
    <input type="text" name="email" id="email"></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td>Telephone:
    <input type="text" name="telephone" id="telephone"></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td><p>Cuisine Type:
    <?php
    mysql_connect("localhost", "root", "coatez") or die(mysql_error());
    mysql_select_db("restaurant") or die(mysql_error());
    $query="SELECT type FROM cuisine_type";
    $result = mysql_query($query);

    echo '<select name="cuisine_id" id="cuisine_id">';
    while($nt=mysql_fetch_array($result)){ //Array or records stored in $nt
    echo '<option name="select" value="' . $nt['type'] . '">' . $nt['type'] . '</option>';
    /* Option values are added by looping through the array */
    }
    echo '</select>'; // Closing of list box
    ?>

    </p>
    <p><a href="cuisineform.php" target="frame"><input type="button" value="Add new Type"/></a><A HREF="javascript:history.go(0)"><input type="button" value="Refresh List"/></A></p>
    <p>
    <label for="cuisine_id"></label>
    </p>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td>Signature Dish:
    <input type="text" name="signature_dish" id="signature_dish"></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td>Price Range:
    <input type="text" name="price_range" id="price_range"></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td>Payment Type:
    <input type="text" name="payment_type" id="payment_type"></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td><input type="button" name="first" id="first" value="Prev">
    <input type="button" name="first2" id="first2" value="Next"></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    </table>
    </form>

    Thanks
    James


  • #2
    New Coder
    Join Date
    Sep 2011
    Posts
    80
    Thanks
    0
    Thanked 13 Times in 12 Posts
    Where are you struggling?

    Also using session data with the global array $_SESSION might be a better way to go. It'll be easier and you don't have to worry about database connections until you finally store it.

  • #3
    New to the CF scene
    Join Date
    Aug 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile

    Quote Originally Posted by MarkR View Post
    Where are you struggling?

    Also using session data with the global array $_SESSION might be a better way to go. It'll be easier and you don't have to worry about database connections until you finally store it.
    I am struggling to make the form fetch the data back from the MySQL table, and when the user clicks the < > buttons it will change the data in the form fields and then they can simply update them.

    I will be similar to how ms access does it to add a new record or update a present record

    can you direct me to some tutorials on how to do a global array for $_SESSION
    Thanks

    James


  •  

    Tags for this Thread

    Posting Permissions

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