I have an online page with a number of icons displayed, in pre-determined columns. Some of the icons are omitted based on the authority level of the admin person accessing the page. Even if an icon is omitted, I want following icons in the same line to be displayed in the correct columns. An example of what I am trying is (in C): The code in the else path being intended to cause a blank field to be output to take up the space taken by the "Member History" icon, so that the following icon will be in the same place irrespective of whether the "Member History" icon has been displayed.
fprintf(ouFile, "\<td align=center>");
If (Authority > 5)
{
fprintf(ouFile, "<button class=\"button1\" type=submit name=u049>");
fprintf(ouFile, "Member History");
fprintf(ouFile, "\</button\>\</td>");
else
{
fprintf(ouFile, "\<\"\ \ \ \ \");
fprintf(ouFile, "\</td\>");
}
fprintf(ouFile, "\<td align=center>");
However, the result is as if I had not inserted the else path. The next icon in the row is shown in the column of the "Member History" icon if it had been included.
What am I doing wrong? How do I achieve what I wanted?
I have an online page with a number of icons displayed, in pre-determined columns. Some of the icons are omitted based on the authority level of the admin person accessing the page. Even if an icon is omitted, I want following icons in the same line to be displayed in the correct columns. An example of what I am trying is (in C): The code in the else path being intended to cause a blank field to be output to take up the space taken by the "Member History" icon, so that the following icon will be in the same place irrespective of whether the "Member History" icon has been displayed.
fprintf(ouFile, "\<td align=center>");
If (Authority > 5)
{
fprintf(ouFile, "<button class=\"button1\" type=submit name=u049>");
fprintf(ouFile, "Member History");
fprintf(ouFile, "\</button\>\</td>");
else
{
fprintf(ouFile, "\<\"\ \ \ \ \");
fprintf(ouFile, "\</td\>");
}
fprintf(ouFile, "\<td align=center>");
However, the result is as if I had not inserted the else path. The next icon in the row is shown in the column of the "Member History" icon if it had been included.
What am I doing wrong? How do I achieve what I wanted?
Share Improve this question edited Jan 8 at 0:50 WarwickW 455 bronze badges asked Jan 6 at 9:51 WarwickWrWarwickWr 6 | Show 1 more comment2 Answers
Reset to default 0fprintf(ouFile, "<td align=center>");
if (Authority > 5)
{
fprintf(ouFile, "<button class=\"button1\" type=\"submit\" name=\"u049\">");
fprintf(ouFile, "Member History");
fprintf(ouFile, "</button></td>");
}
else
{
fprintf(ouFile, " </td>");
}
You need to ensure a <td>
cell is always rendered, even if it's empty or contains a placeholder.
I have a whole series of these buttons, each representing a call to an application and called if particular conditions are true. When a button is not needed some of them leave a blank field and others do not. I have solved the problem empirically by putting in an extra <td></td>
where necessary, to leave a blank spot for the omitted buttons, so that following buttons in the row end up in the correct column. That worked, but I do not understand why it is sometimes necessary to put in one set and other times to put in two sets. It does not seem to be caused by the cell width.
fprintf()
in the Else path has three double quotes ("
) on it, making the quotes unterminated. Was that just a typo in your post, or is that error in the original too? And when posting scripts or program code, please use the editing tools to apply code formatting (the{}
button in the question/answer editing toolbar) to it, so the site won't re-wrap the lines and indentation works as appropriate for code. – telcoM Commented Jan 6 at 10:43<
in theelse
clause, as you are not supplying a tag? Also remove the superfluous quote adjacent to it – Vercingatorix Commented Jan 6 at 15:38<fprintf
supposed to be? – Barmar Commented Jan 6 at 23:30<
and&
? Were those added automatically by the Stacks Editor? – Barmar Commented Jan 6 at 23:31else
block makes no sense. You have<
with no matching>
. There's no tag name, just a bunch of
. – Barmar Commented Jan 6 at 23:35