SitePoint Sponsor |
|
User Tag List
Results 26 to 50 of 76
Thread: Quick question.. thanks :)
-
Dec 9, 2003, 23:56 #26
- Join Date
- Oct 2003
- Location
- Germany
- Posts
- 2,195
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
PHP Code:return (isset($_POST[$_index])) ? $_POST[$_index] : '';
Your select box markup is a bit messed up. Do you want to let the user choose more then the current entry, which hasn't even got a name in your code?
-
Dec 10, 2003, 09:34 #27
- Join Date
- Dec 2001
- Location
- Midlands, UK
- Posts
- 284
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi
I simply want the previous selected option to be selected once again. If no option is selected, then it be blank (again) so they can select it.
The original code for that part was:
PHP Code:<td><select name="createdby_select" id="createdBy">
<OPTION SELECTED VALUE="">---------------</OPTION>
<?php
while ($createdby_q = mysql_fetch_array($createdby_query)) {
$createdby_id = $createdby_q["createdbyID"];
$createdby_name = $createdby_q["createdbyName"];
echo("<OPTION VALUE='$createdby_id'>$createdby_name<BR>\n");
}
?>
</select></td>
Thanks.
Mak
-
Dec 10, 2003, 13:01 #28
- Join Date
- Oct 2003
- Location
- Germany
- Posts
- 2,195
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
PHP Code:/* Ignore this line */ ?>
<td>
<select name="createdby_select" id="createdBy">
<option value="">---------------</option>
<?php
$preselection = safe_post('createdby_select');
while ($createdby_q = mysql_fetch_array($createdby_query)) {
$selected = ($preselection == $createdby_q['createdbyID']) ? 'selected' : '';
echo '<option '.$selected.' value="'.$createdby_q['createdbyID'].'>'.
$createdby_q['createdbyName'].'<br>'."\n";
}
?>
</select>
</td>
-
Dec 10, 2003, 13:18 #29
- Join Date
- Dec 2001
- Location
- Midlands, UK
- Posts
- 284
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi
I tried that but something odd happens.
The options I can select are:
1. Myself
2. Parent
3. Guardian
4. Other family member
5. Friend
When I select 'Myself' and post the form with the rest blank, it brings up the appropriate error messages and I would expect it to have 'Myself' selected again. Instead, it has:
"--------------
Parent
Other family member
Forename"
Equally, similar odd stuff happens when I select any other option. What I don't understand is where it is getting 'Forename' from? Is something wrong with the way I am accessing the $_POST array?
Thanks.
Mak
-
Dec 10, 2003, 13:22 #30
- Join Date
- Oct 2003
- Location
- Germany
- Posts
- 2,195
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
In the while loop echo out $createdby_q['createdbyName'], $createdby_q['createdbyID'] and $selected after the echo please.
-
Dec 10, 2003, 14:07 #31
- Join Date
- Dec 2001
- Location
- Midlands, UK
- Posts
- 284
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi
Sorry for being thick but do you mean:
PHP Code:<?php
$preselection = safe_post('createdby_select');
while ($createdby_q = mysql_fetch_array($createdby_query)) {
$selected = ($preselection == $createdby_q['createdbyID']) ? 'selected' : '';
//echo '<option '.$selected.' value="'.$createdby_q['createdbyID'].'>'.$createdby_q['createdbyName'].'<br>'."\n";
echo '<option '.$selected.' value="">'\n";
}
?>
Thanks.
Mak
-
Dec 10, 2003, 14:18 #32
- Join Date
- Oct 2003
- Location
- Germany
- Posts
- 2,195
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
PHP Code:echo 'Name: ' , $createdby_q['createdbyName'] , ' ID: ' , $createdby_q['createdbyID'] , ' Selected: ' , $selected' , ' Preselection: ' , $preselection , '<br />';
-
Dec 10, 2003, 15:19 #33
- Join Date
- Dec 2001
- Location
- Midlands, UK
- Posts
- 284
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi
With that I get:
Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';'
Any ideas?
Thanks.
Mak
-
Dec 10, 2003, 15:29 #34
- Join Date
- Oct 2003
- Location
- Germany
- Posts
- 2,195
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Sorry one quote to much.
PHP Code:echo 'Name: ' , $createdby_q['createdbyName'] , ' ID: ' , $createdby_q['createdbyID'] , ' Selected: ' , $selected , ' Preselection: ' , $preselection , '<br />';
-
Dec 10, 2003, 15:36 #35
- Join Date
- Dec 2001
- Location
- Midlands, UK
- Posts
- 284
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi
Then I get (in the re-displayed select box):
->Parent Name: Parent ID: 2: Preselection: 1
->Other family member Name: Other family member ID: 4 Selected: Preselection: 1
->Forename
Those are the three options it shows. What's odd is the 'Forename' as that is, as yet, just the next field:
PHP Code:<tr>
<td width="223">Forename</td>
<td width="241">
<input name="mForename" type="text" id="mForename" size="25" maxlength="25">
</td>
</tr>
Oh, btw, the database code is:
Code:# Table structure for table `createdby` # CREATE TABLE `createdby` ( `createdbyID` int(1) NOT NULL auto_increment, `createdbyName` varchar(20) default NULL, PRIMARY KEY (`createdbyID`) ) TYPE=MyISAM AUTO_INCREMENT=6 ; # # Dumping data for table `createdby` # INSERT INTO `createdby` VALUES (1, 'Myself'); INSERT INTO `createdby` VALUES (2, 'Parent'); INSERT INTO `createdby` VALUES (3, 'Guardian'); INSERT INTO `createdby` VALUES (4, 'Other family member'); INSERT INTO `createdby` VALUES (5, 'Friend');
Mak
-
Dec 10, 2003, 15:44 #36
- Join Date
- Oct 2003
- Location
- Germany
- Posts
- 2,195
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Can I have the full source, I would need everything to be able to successfully debug it. Thanks.
-
Dec 10, 2003, 16:00 #37
- Join Date
- Dec 2001
- Location
- Midlands, UK
- Posts
- 284
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi
It was a bit long to post so I have PM'd you it in sections.
Thanks.
Mak
-
Dec 10, 2003, 16:02 #38
- Join Date
- Oct 2003
- Location
- Germany
- Posts
- 2,195
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Yes, I will look into it tommorrow.
-
Dec 11, 2003, 07:07 #39
- Join Date
- Dec 2001
- Location
- Midlands, UK
- Posts
- 284
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi
Look foward to your reply
Thanks.
Mak
-
Dec 11, 2003, 12:47 #40
- Join Date
- Oct 2003
- Location
- Germany
- Posts
- 2,195
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Okay, I attached the PHP file, I hope it helps you.
-
Dec 11, 2003, 15:30 #41
- Join Date
- Dec 2001
- Location
- Midlands, UK
- Posts
- 284
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi
Where is the attached PHP file?
Thanks.
Mak
-
Dec 11, 2003, 15:31 #42
- Join Date
- Oct 2003
- Location
- Germany
- Posts
- 2,195
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
You have to wait till it is approved.
-
Dec 13, 2003, 17:59 #43
- Join Date
- Dec 2001
- Location
- Midlands, UK
- Posts
- 284
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi
I still can't see anything.. either here or in private messages.. and it has been a couple of days?
Thanks.
Mak
-
Dec 13, 2003, 19:00 #44
- Join Date
- Oct 2003
- Location
- Germany
- Posts
- 2,195
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I see it now.
-
Dec 14, 2003, 18:51 #45
- Join Date
- Dec 2001
- Location
- Midlands, UK
- Posts
- 284
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi
Thanks for that!
I just tried it and get this:
Parse error: parse error, unexpected ';' in d:\inetpub\wwwroot\site\join_form.php on line 6
I think it is referring to this line:PHP Code:return (isset($_POST[$_index]) ? $_POST[$_index] : '';
Mak
-
Dec 14, 2003, 19:51 #46
- Join Date
- Sep 2002
- Location
- The Restaurant at The End of The Universe
- Posts
- 1,423
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Should be
PHP Code:return (isset($_POST[$_index])) ? $_POST[$_index] : '';
-
Dec 15, 2003, 09:28 #47
- Join Date
- Dec 2001
- Location
- Midlands, UK
- Posts
- 284
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi
I fixed that but then I get:
Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in d:\inetpub\wwwroot\site\join_form.php on line 39
PHP Code:$selected = ($preselected == $createdby_id) 'selected' : '';
Any ideas?
Thanks.
Mak
-
Dec 15, 2003, 11:49 #48
- Join Date
- Oct 2003
- Location
- Germany
- Posts
- 2,195
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Must be
PHP Code:$selected = ($preselected == $createdby_id) ? 'selected' : '';
-
Dec 15, 2003, 12:33 #49
- Join Date
- Dec 2001
- Location
- Midlands, UK
- Posts
- 284
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi
What about:
Parse error: parse error, unexpected '=' in d:\inetpub\wwwroot\site\join_form.php on line 84
PHP Code:$preselection = safe_post('day_select');
Mak
-
Dec 15, 2003, 12:44 #50
- Join Date
- Oct 2003
- Location
- Germany
- Posts
- 2,195
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I hopefully cleared out some of the errors, see the attached file.
Bookmarks