Updating with select forms

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jamrop
Forum Commoner
Posts: 80
Joined: Fri May 16, 2003 5:38 pm

Updating with select forms

Post by jamrop »

Hey, I am trying to do an update php page.

E.g. Someone adds a news post. I have a select form when adding a peice of news

Code: Select all

<?php
<select name="condition">
 <option value="none">Please Select One</option>
<option value="Poor">Poor</option>
<option value="Average">Average</option>
<option value="Good">Good</option>
<option value="Very good">Very Good</option>
                        </select>

?>
What i am shruggling on , is if they want to update it, a page displays the info what they put, but i want to be able to have what they had chosen on the select form, already shown. It gets the info from mysql database.


Sorry hard to explain .

Many thanks
User avatar
skateis2s
Forum Commoner
Posts: 37
Joined: Fri Aug 08, 2003 7:22 am
Location: colorado

Post by skateis2s »

I kinda get where your going but dont understand... What are you having troubles with? And what are you trying to do exactly?
jamrop
Forum Commoner
Posts: 80
Joined: Fri May 16, 2003 5:38 pm

Post by jamrop »

when the update page comes up, i want to show all the info they had put, e.g. title, description and condition. I can make script to show the title and description and they can edit that, but cause i used a select form for condition ,when adding news, i want that to appear again, but with what they had selected when adding news

Hope this explains it a bit more

many thanks
User avatar
Kriek
Forum Contributor
Posts: 238
Joined: Wed May 29, 2002 3:46 am
Location: Florida
Contact:

Post by Kriek »

Simple query string should do the trick ;)

Code: Select all

<FORM method="POST">
  <TD> <SELECT name="condition" onChange="if(options[selectedIndex].value)
    window.location.href= (options[selectedIndex].value);"
style="font-family: Verdana, Arial">
      <OPTION value="">Please Select One</OPTION>
      <OPTION value=<?php
    echo $PHP_SELF . '?dropid=Poor';
    if ($_GET['dropid'] == Poor) {
        echo ' SELECTED';
    }
?>>Poor</OPTION>
      <OPTION value=<?php
    echo $PHP_SELF . '?dropid=Average';
    if ($_GET['dropid'] == Average) {
        echo ' SELECTED';
    }
?>>Average</OPTION>
      <OPTION value=<?php
    echo $PHP_SELF . '?dropid=Good';
    if ($_GET['dropid'] == Good) {
        echo ' SELECTED';
    }
?>>Good</OPTION>
      <OPTION value=<?php
    echo $PHP_SELF . '?dropid=VeryGood';
    if ($_GET['dropid'] == VeryGood) {
        echo ' SELECTED';
    }
?>>Very Good</OPTION>
    </SELECT> </TD>
</FORM>
Last edited by Kriek on Sun Aug 10, 2003 9:29 am, edited 1 time in total.
User avatar
skateis2s
Forum Commoner
Posts: 37
Joined: Fri Aug 08, 2003 7:22 am
Location: colorado

Post by skateis2s »

So on your edit page you want it to be able to show what they chose on the select form (poor, average, good, etc...)? Do you want it to just display it, or do you want them to be able to change it also?
jamrop
Forum Commoner
Posts: 80
Joined: Fri May 16, 2003 5:38 pm

Post by jamrop »

thanks for that, but would it not need to be referred to the database, to get the info?
,to get to the update page, i would have

Code: Select all

<?php
update.php?news_id=123
?>
and then on update page, i would have

Code: Select all

<?php
select * from news where news_id=$news_id
?>
And yeah i want them to be able to change it

many thanks
Post Reply