Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Software Development
Programming
Programming Q&A
PHP - JSON Question
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Skythrust" data-source="post: 467690" data-attributes="member: 87030"><p>Back again..</p><p></p><p>I am trying to loop after item, this is working when I am doing it with this code;</p><p></p><p>[CODE=php]echo "<td><div class='TextOff'>"[/CODE]</p><p></p><p>But because the class is changing if the Online value is 0 or 1</p><p></p><p>so I thaught I need to use this but that isn't working.</p><p>[CODE=php]echo "<td>".</p><p>if ($record['Online'] == 1) { "<div class='TextOn'>"; } else { "<div class='TextOff'>"; }[/CODE]</p><p></p><p>I also have tried this</p><p>[CODE=php]// A</p><p>echo "<td><div class=". if ($record['Online'] == 1) {'TextOn'.} else {'TextOff'.} ">"</p><p></p><p>// B</p><p>echo "<td><div class=". if ($record['Online'] == 1) {'TextOn'} else {'TextOff'} . ">"</p><p> </p><p>// C (is working but not an if else solution)</p><p>echo "<td><div class=". 'TextOn'. ">"[/CODE]</p><p></p><p>The code for the switch/checkbox is working fine</p><p>Full Code;</p><p>[CODE=php]<section></p><p> <?php</p><p> $i =0;</p><p> echo "<table><tr>";</p><p> foreach($data as $record)</p><p> {</p><p> $i++;</p><p> echo "<td><div class='TextOff'>"</p><p> // echo "<td>".</p><p> // if ($record['Online'] == 1) { "<div class='TextOn'>"; } else { "<div class='TextOff'>"; }</p><p> .$record['Name']; ?></p><p></p><p> <label class="switch"></p><p> <input type="checkbox" <?php if ($record['Online'] == 1) { echo 'checked'; } else { echo 'unchecked'; } ?>></p><p> <span class="slider round"></span></p><p> </label></p><p> </div></p><p> <?php</p><p> '</td>';</p><p> $item++;</p><p> if ($item % 2 == 0) { echo '</tr><tr>'; }</p><p> }</p><p>?></p><p> </table> </p><p></section>[/CODE]</p></blockquote><p></p>
[QUOTE="Skythrust, post: 467690, member: 87030"] Back again.. I am trying to loop after item, this is working when I am doing it with this code; [CODE=php]echo "<td><div class='TextOff'>"[/CODE] But because the class is changing if the Online value is 0 or 1 so I thaught I need to use this but that isn't working. [CODE=php]echo "<td>". if ($record['Online'] == 1) { "<div class='TextOn'>"; } else { "<div class='TextOff'>"; }[/CODE] I also have tried this [CODE=php]// A echo "<td><div class=". if ($record['Online'] == 1) {'TextOn'.} else {'TextOff'.} ">" // B echo "<td><div class=". if ($record['Online'] == 1) {'TextOn'} else {'TextOff'} . ">" // C (is working but not an if else solution) echo "<td><div class=". 'TextOn'. ">"[/CODE] The code for the switch/checkbox is working fine Full Code; [CODE=php]<section> <?php $i =0; echo "<table><tr>"; foreach($data as $record) { $i++; echo "<td><div class='TextOff'>" // echo "<td>". // if ($record['Online'] == 1) { "<div class='TextOn'>"; } else { "<div class='TextOff'>"; } .$record['Name']; ?> <label class="switch"> <input type="checkbox" <?php if ($record['Online'] == 1) { echo 'checked'; } else { echo 'unchecked'; } ?>> <span class="slider round"></span> </label> </div> <?php '</td>'; $item++; if ($item % 2 == 0) { echo '</tr><tr>'; } } ?> </table> </section>[/CODE] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Software Development
Programming
Programming Q&A
PHP - JSON Question
Top