Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-11-2013, 08:59 PM   PM User | #1
countrydj
Regular Coder

 
Join Date: Nov 2011
Location: Preston, UK
Posts: 130
Thanks: 36
Thanked 0 Times in 0 Posts
countrydj is an unknown quantity at this point
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
countrydj is offline   Reply With Quote
Old 02-11-2013, 09:39 PM   PM User | #2
countrydj
Regular Coder

 
Join Date: Nov 2011
Location: Preston, UK
Posts: 130
Thanks: 36
Thanked 0 Times in 0 Posts
countrydj is an unknown quantity at this point
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
countrydj is offline   Reply With Quote
Old 02-11-2013, 11:17 PM   PM User | #3
mlseim
Master Coder

 
mlseim's Avatar
 
Join Date: Jun 2003
Location: Cottage Grove, Minnesota
Posts: 9,045
Thanks: 8
Thanked 1,029 Times in 1,020 Posts
mlseim has a spectacular aura aboutmlseim has a spectacular aura aboutmlseim has a spectacular aura about
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>
mlseim is offline   Reply With Quote
Old 02-12-2013, 11:10 AM   PM User | #4
countrydj
Regular Coder

 
Join Date: Nov 2011
Location: Preston, UK
Posts: 130
Thanks: 36
Thanked 0 Times in 0 Posts
countrydj is an unknown quantity at this point
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
countrydj is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:58 AM.


Advertisement
Log in to turn off these ads.