Jump to content

Recommended Posts

I am working on a script for job postings and applications.

It seemed like a simple solution, I simply used a conditional if, else if, else shown below but no go.

<?php
if ($cmd =="List")
{echo 'align="center"';}
elseif ($cmd == "Details")
{echo 'align="center"';}
else {echo 'align="left"';}
?>


The layout is basically this.

<table>
<tr>
<td>

($cmd content places here)

</ts>
</tr>
</table>

then below that we have 3 things that go here.

1- $cmd=list  (needs to align center)

2- $cmd=details (needs to align center)

3- This one is the problem, it is a <table><tr><td> $cmd=apply </td></tr></table> and it needs to apply left on the page and it just wont go. I have my code put on the server as a text pagfe so you can see the code and I will paste the link to the php page live so you can navigate to see the alignment.

text link is: [url=http://"http://www.aplusplumbingandseptic.com/jobs/index.txt"]http://www.aplusplumbingandseptic.com/jobs/index.txt[/url]

php live page is at: [url=http://"http://www.aplusplumbingandseptic.com/jobs/index.php"]http://www.aplusplumbingandseptic.com/jobs/index.php[/url]
Here's an implementation:
[code]
<?php
<table>
<tr>
<td>

<div

<?php

if ($cmd =="List") {
    echo 'align="center"';
}elseif ($cmd == "Details") {
    echo 'align="center"';
} else {
    echo 'align="left"';
}
?>
OH MY!
</div>

</ts>
</tr>
</table>
?>
[/code]

Using a switch statement would be cleaner, however (since you have a passthrough.)
I am not knowledgeable in PHP enough quite yet to know what to call it except if you follow the link to the php live page($cmd=list is the page you start on), click on a job opening (your now on $cmd=details)-> then on the lower part of the page, click on apply($cmd=apply is the application you get to last). the first 2 commands need to align in the center, the last one needs to align left. But it throws the wrench in there when it is in a seperate table because now a if, elseif, else will not qwork because it will never call that third one to that in a whil. If you go look at the page, it is more than obvious what the trouble is and I just cant figure out how to fix it.
We actually aren't competing. We are trying to get this stuff on the website to cut down on office traffic. Too many people coming in to look for work, the customers cant get through the door, so we are moving our application process to the website, the will apply there and then we can call back the ones we was to interview.
Based on your original layout, I'd go with the following, but that's just because I like using variables as opposed to just echoing the code out.

[code]<?php
if ($cmd =="List"){
  $align = "center";
}
elseif ($cmd == "Details"){
  $align = "center";
}
else {
  $align = "left";
}
?>

<table>
<tr>
  <td align="<?php echo $align; ?>">
  Your content goes here
  </td>
</tr>
</table>[/code]

Regards
Huggie
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.