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 4 of 4
  1. #1
    Regular Coder
    Join Date
    Nov 2011
    Location
    Preston, UK
    Posts
    131
    Thanks
    36
    Thanked 0 Times in 0 Posts

    How do I write the code to create a form and include data

    I am writing a simple script for a subscriber to create a simple web page.

    I was doing quite well until I came across a problem.

    Up to now I have got working (part of script):
    PHP Code:
    print "<tr><td align='right'>Club Contact: </td><td><input name='club_contact' type='text' size='50' maxlength='100' value='$row->club_contact'></td></tr>\n";
                print 
    "<tr><td align='right'>Club Opening: </td><td><input name='club_open' type='text' size='50' maxlength='100' value='$row->club_open'></td></tr>\n"
    This will display a page and input any data that is in the database.

    However, I need to add this HTML code into the same PHP script:
    Code:
    <td align=right valign=top>Club Facilities:</td>
    	<td><textarea name="club_details2" cols=40 rows=6></textarea></td>
    This is what I have done up to now:
    PHP Code:
    print "<tr><td align='right' valign='top'>Club Facilities: </td><td><textarea name='club_details2' cols='40' rows='6' value='$row->club_details2'></textarea></td></tr>\n"
    This code displays the textarea, but does not display the data from the database.

    When this is solved, the next problem is that I want to display this HTML code in the PHP script:
    Code:
    <td>
    	<select name="background_colour">
    			<option value="PLEASE SELECT">PLEASE SELECT
                <option value="#ff9999">Light Red
    			<option value="#99ff99">Light Green
    			<option value="#0099ff">Light Blue
    			<option value="#6633cc">Purple
                <option value="#ff0000">Red
    			<option value="#00ff00">Green
    			<option value="#0000ff">Blue
    			<option value="#ffff00">Yellow
    			<option value="#990000">Dark Red
    			<option value="#003300">Dark Green
    			<option value="#000066">Dark Blue
    			<option value="#ff6600">Orange
    	</select>
    	</td>
    Now at this stage I have no idea where to start.

    It is important that I display all the data that is held in the database.

    Can anybody help me = PLEASE ???

    Thanks,
    The MAN, The MYTH, The LEGEND:
    John C
    ________________________________
    Support your local Country Music Club

  • #2
    Regular Coder
    Join Date
    Nov 2011
    Location
    Preston, UK
    Posts
    131
    Thanks
    36
    Thanked 0 Times in 0 Posts
    I have solved the first part of the above post with this script:
    PHP Code:
    print "<tr><td align='right' valign='top'>Club Facilities: </td><td><textarea name='club_details2' cols='40' rows='6'>$row->club_details2</textarea></td></tr>\n"
    I still have no idea where to start writing the second part.

    I want to display this HTML code in the PHP script:
    Code:
    <td>
    	<select name="background_colour">
    			<option value="PLEASE SELECT">PLEASE SELECT
                <option value="#ff9999">Light Red
    			<option value="#99ff99">Light Green
    			<option value="#0099ff">Light Blue
    			<option value="#6633cc">Purple
                <option value="#ff0000">Red
    			<option value="#00ff00">Green
    			<option value="#0000ff">Blue
    			<option value="#ffff00">Yellow
    			<option value="#990000">Dark Red
    			<option value="#003300">Dark Green
    			<option value="#000066">Dark Blue
    			<option value="#ff6600">Orange
    	</select>
    	</td>
    Now at this stage I have no idea where to start.

    It is NOT important that I display all this data because it is NOT held in the database. Only one of the above will be in the database. But it IS important that the selections are available.

    Can anybody help me - PLEASE ???

    Thanks,
    The MAN, The MYTH, The LEGEND:
    John C
    ________________________________
    Support your local Country Music Club

  • #3
    Master Coder mlseim's Avatar
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,396
    Thanks
    8
    Thanked 1,078 Times in 1,069 Posts
    You say that you want to display that <select> part on your page.

    Are you now saying that the options don't show up?

    Have you tried closing the <option> tags?


    <option value="#99ff99">Light Green</option>

  • #4
    Regular Coder
    Join Date
    Nov 2011
    Location
    Preston, UK
    Posts
    131
    Thanks
    36
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by mlseim View Post
    You say that you want to display that <select> part on your page.

    Are you now saying that the options don't show up?

    Have you tried closing the <option> tags?


    <option value="#99ff99">Light Green</option>
    Hi mlseim ...

    Thank you very much for getting back to me.

    I don't know what came over me.
    I was struggling with the <textbox> coding to get it to display the database contents, and I THOUGHT that I didn't know how to code the <select> into the PHP form.
    I was thinking that I needed to display the data from the database, and then realised that that was pointless because the user wouldn't be able to change it.

    When I had gathered my thoughts, and after reading your reply, I realised that it wasn't a problem. It was straight forward coding.

    Thank you.
    The MAN, The MYTH, The LEGEND:
    John C
    ________________________________
    Support your local Country Music Club


  •  

    Posting Permissions

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