PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Sat Oct 20, 2018 11:15 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Sat Oct 06, 2018 8:50 am 
Offline
Forum Contributor

Joined: Thu Feb 23, 2012 7:51 am
Posts: 301
Hello:

I hope this is the correct forum for this question.

I am trying to construct a dynamic <select><option> list based off of results from a SELECT statement. And I'm running into problems. Specifically - the final output looks like the attached .png file.

There is an extra \ slash in the last </option> tag. Even though I don't have the \ slash in the code snippet. Following is my code snippet. Does anyone have any idea why the forward slash is being inserted into my </option> tag????

Syntax: [ Download ] [ Hide ]
$prep_LogAccess = $link->prepare($select_LogAccess);
                $prep_LogAccess->execute(array());
       
                $list = "<option value=''>test</option>";
       
        $LogAccess_Results = $prep_LogAccess->fetchAll();
        foreach($LogAccess_Results as $LogAccess) {
        $list = $list .  "<option class='optPrivileges' value=" . $LogAccess['ActivityCode'] . ">" . stripslashes($LogAccess['ActivityDesc'])  . "</option>";
        }
               
        echo(json_encode($list));


Thanks in advance - Pavilion


Attachments:
selectOption.png
selectOption.png [ 45.44 KiB | Viewed 148 times ]
Top
 Profile  
 
PostPosted: Sat Oct 06, 2018 9:39 am 
Offline
Forum Contributor

Joined: Thu Feb 23, 2012 7:51 am
Posts: 301
Figured it out. I don't need to json_encode() the $list variable. Once I simply echoed it, all was well...


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group