Page 1 of 1

Updating with select forms

Posted: Sun Aug 10, 2003 8:54 am
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

Posted: Sun Aug 10, 2003 9:00 am
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?

Posted: Sun Aug 10, 2003 9:14 am
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

Posted: Sun Aug 10, 2003 9:22 am
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>

Posted: Sun Aug 10, 2003 9:24 am
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?

Posted: Sun Aug 10, 2003 9:54 am
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