Page 4 of 4

Posted: Tue May 29, 2007 1:53 pm
by revocause
superdesign, thanks but im aware of that
example :

Code: Select all

$name = $_POST['name'];
or the request:

Code: Select all

$name = $_REQUEST['name'];
I'm aware of the Super_Globals

Posted: Tue May 29, 2007 1:55 pm
by superdezign
Well, it sounds like you're asking to be taught, so I offered you a place to learn. W3School's tutorials are very short and simple, and don't take more than a few minutes to read.

No need to be so sarcastic. We help those who help themselves.

Posted: Tue May 29, 2007 1:59 pm
by revocause
I'm aware of Arrays , newArrays, associative arrays

Code: Select all

$price = array('product1' => $100.00, 'product2' => $200) etc.
but see what I been saying is, its just this code for this one page, I've never written before, not exactly sure what it should look like/ be coded like.

Thanks.

Posted: Tue May 29, 2007 2:00 pm
by revocause
super , Im not asking to be taught, I'm cert in php basics, and php/mySQL programming

but thanks for making yourself feel sporty :)

Posted: Tue May 29, 2007 2:02 pm
by revocause
correct if your next comment is to say im not an 'expert'

otherwise i wouldnt be here chasing around the mullberry bush getting 'schooled'.

kinda odd, my first day signing up to this forum , 4 hours later, and i have people basically scolding me like a school kid.

for asking a simple coding question, which turned into the 'youre an idiot' charade.

Im not trying to be rude, im just tyring to ask nicely if somebody could help me to see what that code would look like.

thanks

Posted: Tue May 29, 2007 2:04 pm
by RobertGonzalez

Code: Select all

<select name="a"  STYLE="width: 110 px">
      <option selected="selected" value="">Please Select</option>
      <option value="100">100</option>
      <option value="500">500</option>
      <option value="1,000">1,000</option>
      <option value="2000">2,000</option>
      <option value="3000">3,000</option>
      <option value="4000">4,000</option>
      <option value="5000">5,000</option>
      <option value="10000">10,000</option>
</select>
Can be translated like this, into PHP using an array...

Code: Select all

<?php
$selects = array();
$selects['a'] = array('100', '500', '1,000', '2000', '3000', '4000', '5000', '10000');
// So on with the other select lists

echo '<select name="a">';
foreach ($selects['a'] as $value) {
    echo '<option value="' . $value . '">' . $value . '</option>';
}
echo '</select>';
?>
To check equality in that loop, you would first need to know what the posted value for a is, if there is one at all.

Code: Select all

<?php
// Default values for posted form elements
$a = '100';
if (!empty($_POST['a'])) {
  $a = $_POST['a']; // This really should be validated before using it
}

// Other code from above, and now on to the loop
echo '<select name="a">';
foreach ($selects['a'] as $value) {
    $selected =  ($a == $value) ? ' selected="selected"' : ''; // Ternary operator used to set selected item
    echo '<option value="' . $value . '"' . $selected . '>' . $value . '</option>';
}
echo '</select>';
?>

Posted: Tue May 29, 2007 2:06 pm
by revocause
thank you very much Everah :)

Posted: Tue May 29, 2007 2:07 pm
by RobertGonzalez
@superdezign and @revocause: Please stop the bickering or I will close this thread. The goal is to help people. Let's get back to doing that here shall we?

Posted: Tue May 29, 2007 2:08 pm
by RobertGonzalez
revocause wrote:thank you very much Everah :)
Get the new code I posted as there was a small problem with it. It is clean now though.

Posted: Tue May 29, 2007 3:02 pm
by revocause
Everah,

in that code you made

whats the code look like to add values to 'string' display names ?

example if select options have
<option value ="1.50" > "widget 1"</option>
<option value ="2.50" > "widget 2"</option>
etc.

and from your code example, I'd have to use the PHP script for every individual select menu.
because i used it in <HEAD> PHP </HEAD>
and also put the HTML select menu in the body , and it caused 2 menus of the same type.
except the PHP menu was floating off in left field

How much do you charge to write this darn code?

Posted: Tue May 29, 2007 3:07 pm
by revocause
and whats with that avatar = forum commoner?

are moderators insulting new members?
you never know who's on here right?

Posted: Tue May 29, 2007 3:18 pm
by revocause
everah,

I will pay you to code the select menu.
That way i can see it in its entirety, and at that point I can rad the language well enough
to understand whats being done.

but this stuff is wasting a whole day.

let me know
thanks

Posted: Tue May 29, 2007 4:03 pm
by RobertGonzalez
revocause wrote:and whats with that avatar = forum commoner?

are moderators insulting new members?
you never know who's on here right?
Forum Commoner is a title for users. It is based on post count and nothing more.

PM me with what you want out of your script and what you currently have. I'll take a look and let you know if I will do it.