Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 02-18-2008, 03:20 PM Forms and PHP
MoForce's Avatar
Super Talker

Posts: 145
Name: Jack Shalt
Trades: 0
So I thought this would work

PHP Code:
<form action="<?=$_SERVER['PHP_SELF']?>" method="post">
<?
$countrylist 
mysql_query ("SELECT * FROM countries");
while (
$list=mysql_fetch_array($countrylist)) {
        
?>
Choose a company to attack: 
<select name="company">
<option value="none">--- None Selected ---</option>
<option value="<?=$list['country'];?>"><?=$list['country'];?></option>
</select>
<form type="hidden" value="list" name="list">
<input type="submit" name="submit" value="GO">
</form>
I was trying to create an automatic option list based on the number of rows and such... and it doesn't work the way I thought it would. The script above just ends up creating totally separate option lists instead. Any ideas on how to get this done?

I would like it to be a regular drop down menu based on the # of companies I've got listed
http://www.w3schools.com/tags/tag_select.asp
Something like that except instead of me having to write out each option PHP automatically adds it on as users register

Last edited by MoForce; 02-18-2008 at 03:22 PM..
MoForce is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 02-19-2008, 12:56 AM Re: Forms and PHP
mtishetsky's Avatar
King Spam Talker

Posts: 1,226
Name: Mike
Location: Mataro, Spain
Trades: 0
Holy sht. You should have inside your cycle only those instructions which should be repeated on each iteraton. And you not only draw separate <select> for each selected row but also make absolutely screwed <form> tags having <form> inside <form> and not closing the first opened <form> (at least I don't see here that you do close it). And why do you place the submit biutton into separate form at all? And where did you get form type="hidden"? It is not present in any html specification.

I sincerely hope that you made this stoopeed mistakes just because you are tired and haven't sleep for twenty hours. If not then I insistently recommend you to put away php and html and take up something like drawing or sculpture or whatever else, but not the webdev.
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

And don't forget to give me talkupation!
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Old 02-19-2008, 01:34 AM Re: Forms and PHP
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
I'm inclined to disagree with mtishetsky as far as the giving up on php and development. And hidden fields are 'present in html specifications', they are fairly common:
http://www.tizag.com/htmlT/htmlhidden.php

try this code:

PHP Code:
<form action="<? $_SERVER['PHP_SELF'?>" method="post">
Choose a company to attack: 
<select name="company">
<option value="none">--- None Selected ---</option>
<?php
$countrylist 
mysql_query ("SELECT * FROM countries");
while (
$list=mysql_fetch_array($countrylistMYSQL_ASSOC)) 
{
     echo 
'<option value="' $list['country'] . '">' $list['country'] . '</option>';
}
 
?>
</select>
<input type="hidden" value="list" name="list">
<input type="submit" name="submit" value="GO">
</form>
Also, I noticed that you are consistently adding an = to your opening php tag:
<?=[code here]

That's not necissary just do the following:
<?php [code here, make sure to use a space] ?>

Hope that helps.

Last edited by NullPointer; 02-19-2008 at 02:27 AM..
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 02-19-2008, 01:52 AM Re: Forms and PHP
mtishetsky's Avatar
King Spam Talker

Posts: 1,226
Name: Mike
Location: Mataro, Spain
Trades: 0
NullPointer, please be so kind to show me the place in official specification from w3c about <form type="hidden">.
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

And don't forget to give me talkupation!
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Old 02-19-2008, 02:28 AM Re: Forms and PHP
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
I'm assuming form was a typo, <input type="hidden"> is completely valid.
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 02-19-2008, 01:53 PM Re: Forms and PHP
MoForce's Avatar
Super Talker

Posts: 145
Name: Jack Shalt
Trades: 0
Quote:
Originally Posted by NullPointer View Post
I'm assuming form was a typo, <input type="hidden"> is completely valid.
Yeah that's a typo... and yes I didn't have any sleep lol
and no I'll never stop php and webdev... lol


<input type="hidden"> is valid

Thanks NullPointer... it worked

Last edited by MoForce; 02-19-2008 at 02:00 PM..
MoForce is offline
Reply With Quote
View Public Profile
 
Old 02-19-2008, 02:20 PM Re: Forms and PHP
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Mtishetsky, the syntax
PHP Code:
<? =
is a shortcut to
PHP Code:
<?php echo
I haven't seen it for years, and it's not very known, I believe.
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 02-19-2008, 05:05 PM Re: Forms and PHP
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
Really? I've never seen that. It just looked like broken code to me. Well you learn something new everyday.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Reply     « Reply to Forms and PHP
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.47204 seconds with 12 queries