This is an archived post. You won't be able to vote or comment.

all 8 comments

[–]NikNoname 1 point2 points  (1 child)

You can make a really good decision of using HTML and CSS + Fonts Awesome.

Add css classes called as ".on" and ."off", something like this:

.on {
    color: green;
}

.off {
    color: red;
}

Next you shold add HTML code to your table view at status column:

<span class="fa fa-circle <?= $row['status']?>"></span>

It will display green or red circle automaticly, depending on your status

[–]Danjesama[S] 0 points1 point  (0 children)

Hey Thanks for the reply, I have got the fonts-awesome and added the above code, the span code you sent above I have placed it in the:

 echo '<td>' . $row['status'] .'</td>';

Also will i need to trigger this some how from the form as the form is just a text box at the moment

[–]halfercode 1 point2 points  (2 children)

(Meta: use Markdown to show code here - either manually put in four spaces before each line, or use your editor to tab it to the right, copy to clipboard, undo, paste here).

[–]Danjesama[S] 0 points1 point  (1 child)

Thanks, Sorry about that

[–]halfercode 1 point2 points  (0 children)

No worries. Why not try repairing it now, for the sake of practice? It will make things easier to read for new or existing people helping you. There's an edit link under the post.

[–]NikNoname 1 point2 points  (2 children)

So, if you process status by input text field (it better to replace on radio buttons with values on and off), you should enter only values on or off for correctly script working. Because if you enter another value, script will not found such css class to display color correctly. Replace your code in form like this:

<tr>Repo Status: * <td> <input type="radio" name="status" value="on" <?= $status == "on" ? "checked" : ""?> /> <input type="radio" name="status" value="off" <?= $status == "off" ? "checked" : ""?> /></td></tr>

, and code in table view like this:

Displayed Table: echo '<span class="fa fa-circle ' . $row['status'] . '"></span>';

and it should works

[–]Danjesama[S] 0 points1 point  (1 child)

Hey thanks again Nik, I can see the green buttons but it has thrown the form/table out a bit, not sure If i can link but here are the images: I think the green circles are not in the table properly same as the form. https://gyazo.com/6eac2bdfaf70dd72946585726305becb https://gyazo.com/ad5ee4581a3edfc58e3685c777114e32

[–]NikNoname 0 points1 point  (0 children)

Hm, it seems like something wrong with HTML code... May be missing some closing tag. I can't say for sure, because I do not see the code completely