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
can I make the select form get the chosen option from the
Old 10-12-2009, 11:11 AM can I make the select form get the chosen option from the
Novice Talker

Posts: 9
Name: mohsen elgendy
Trades: 0
http://www.youtube.com/watch?v=V3IDH5-6QyQ

this is an video explains everything when i chose 'Show 3 thumbs' and click on submit query it will return to 'Show 0 thumbs' i want to make it stay as i picked .

and this is the code

PHP Code:
<?php    if ( isset ( $_POST['submit'] ) )
        {
            
#set variables
            
$example_input $_POST['thumbs_num'];
            
$readmore_text $_POST['readmore_text'];
            
            
$query mysql_query("UPDATE wp_villaarts_settings SET examble='$example_input' , readmore_text='$readmore_text'");
            
            if ( 
$query )
            {
                
#successful entering of data
                
"the value have been updated successfully. Now check the database.";
            }
            else
            {
                
#unsuccessful entering of data
                
"there a problem occurred while updateing your value in the database";
            }
            
        }
        
        
        function 
ss_thumbs_count(){
            
$result mysql_query("SELECT examble FROM wp_villaarts_settings WHERE id='1' ");
            if (!
$result) {
                die(
"Database query failed: " mysql_error());
            }
    
            while (
$row mysql_fetch_array($result)) {
                    
$show_value =  $row["examble"] ;
                    echo 
$show_value ;
            }
        }
        
        function 
readmore_text(){
            
$result mysql_query("SELECT readmore_text FROM wp_villaarts_settings WHERE id='1' ");
            if (!
$result) {
                die(
"Database query failed: " mysql_error());
            }
    
            while (
$row mysql_fetch_array($result)) {
                    
$show_value =  $row["readmore_text"] ;
                    echo 
$show_value ;
            }
        }

?>
    <form method="post" action="<?php echo $_SERVER['']; ?>">
        <label>How many thumbs shows beside the slideshow: 
        <select name="thumbs_num">
            <option value="1">Show One Thumb</option>
            <option value="2">Show Tow Tuhmbs</option>
            <option value="3">Show Three Thumbs</option>
        </select></label> <small style="color:#F00;">Default: <strong>3</strong></small><br /><br />
        
        <label>write the read more text the way u like: <input type="text" name="readmore_text" id="readmore_text" value="<?php readmore_text(); ?>"/></label><br /><br />
        <input type="submit" name="submit" id="submit" /> 
        <br /><br />
    </form>

Last edited by m-elgendy; 10-12-2009 at 11:57 AM..
m-elgendy is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 10-12-2009, 11:17 AM Re: can I make the select form get the chosen option from the
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,384
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
add selected="selected" to the chosen option when the page is rendered
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 10-12-2009, 11:31 AM Re: can I make the select form get the chosen option from the
Novice Talker

Posts: 9
Name: mohsen elgendy
Trades: 0
Quote:
Originally Posted by chrishirst View Post
add selected="selected" to the chosen option when the page is rendered
i have 3 options if i chose the second one and refresh the page it will go back to the first one how can i make it stay as i picked from the database
m-elgendy is offline
Reply With Quote
View Public Profile
 
Old 10-12-2009, 11:36 AM Re: can I make the select form get the chosen option from the
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,384
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
you can't if you refresh the page, it will always show the default (first) or the one with selected specified.

If you submit the page and write in the selected attribute serverside then it will show that one as the default.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 10-12-2009, 11:59 AM Re: can I make the select form get the chosen option from the
Novice Talker

Posts: 9
Name: mohsen elgendy
Trades: 0
Quote:
Originally Posted by chrishirst View Post
you can't if you refresh the page, it will always show the default (first) or the one with selected specified.

If you submit the page and write in the selected attribute serverside then it will show that one as the default.
you know im not that professional with php anyway can you take me code and update it as the way it should work

if u don't mind
m-elgendy is offline
Reply With Quote
View Public Profile
 
Old 10-12-2009, 12:32 PM Re: can I make the select form get the chosen option from the
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,384
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
This code shows how to set it for the first option;
PHP Code:
    <select name="thumbs_num">
            <option<?php if($example_input == '1') echo(' selected=/"selected /"'); ?> value="1">Show One Thumb</option>
            <option value="2">Show Tow Tuhmbs</option>
            <option value="3">Show Three Thumbs</option>
        </select>
repeat that for the other options (change the equality check value to match each line first.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 10-12-2009, 12:44 PM Re: can I make the select form get the chosen option from the
Novice Talker

Posts: 9
Name: mohsen elgendy
Trades: 0
Quote:
Originally Posted by chrishirst View Post
This code shows how to set it for the first option;
PHP Code:
    <select name="thumbs_num">
            <option<?php if($example_input == '1') echo(' selected=/"selected /"'); ?> value="1">Show One Thumb</option>
            <option value="2">Show Tow Tuhmbs</option>
            <option value="3">Show Three Thumbs</option>
        </select>
repeat that for the other options (change the equality check value to match each line first.
sorry it's not working

is there any idea
m-elgendy is offline
Reply With Quote
View Public Profile
 
Old 10-12-2009, 12:55 PM Re: can I make the select form get the chosen option from the
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,384
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
define "not working"

does nothing? causes an error? or ....?
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 10-12-2009, 01:46 PM Re: can I make the select form get the chosen option from the
Novice Talker

Posts: 9
Name: mohsen elgendy
Trades: 0
no error or anything it's doing nothing the problem still exists as can u see in the video
m-elgendy is offline
Reply With Quote
View Public Profile
 
Old 10-12-2009, 01:53 PM Re: can I make the select form get the chosen option from the
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,384
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
the video is no use at all.

can't debug that!
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 10-12-2009, 02:43 PM Re: can I make the select form get the chosen option from the
Novice Talker

Posts: 9
Name: mohsen elgendy
Trades: 0
Quote:
Originally Posted by chrishirst View Post
the video is no use at all.

can't debug that!
okay i'll check the internet and look for it again
and if there any problems i'll text u

thanks
m-elgendy is offline
Reply With Quote
View Public Profile
 
Old 10-12-2009, 03:03 PM Re: can I make the select form get the chosen option from the
lizciz's Avatar
Super Spam Talker

Posts: 807
Name: Mattias Nordahl
Location: Sweden
Trades: 0
Or you could post you new updated code, so people could take a look at it.
__________________
Your answers will only be as good as your question. Formulate it well and give all the necessary information.
lizciz is offline
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
Old 10-12-2009, 05:11 PM Re: can I make the select form get the chosen option from the
Novice Talker

Posts: 9
Name: mohsen elgendy
Trades: 0
Quote:
Originally Posted by chrishirst View Post
the video is no use at all.

can't debug that!
okay i'll check the internet and look for it again
and if there any problems i'll text u

thanks
m-elgendy is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to can I make the select form get the chosen option from the
 

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 1.72998 seconds with 12 queries