unitedintruth Posted December 4, 2006 Share Posted December 4, 2006 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.<?phpif ($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] Quote Link to comment https://forums.phpfreaks.com/topic/29354-very-confusing-conditional-statement-problem/ Share on other sites More sharing options...
btherl Posted December 4, 2006 Share Posted December 4, 2006 Is your problem that the conditional statement is not generating the correct "align=", or that the "align=" instruction is not being followed by the browser? Quote Link to comment https://forums.phpfreaks.com/topic/29354-very-confusing-conditional-statement-problem/#findComment-134620 Share on other sites More sharing options...
keeB Posted December 4, 2006 Share Posted December 4, 2006 Here's an implementation:[code]<?php<table><tr><td><div <?phpif ($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.) Quote Link to comment https://forums.phpfreaks.com/topic/29354-very-confusing-conditional-statement-problem/#findComment-134622 Share on other sites More sharing options...
unitedintruth Posted December 4, 2006 Author Share Posted December 4, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/29354-very-confusing-conditional-statement-problem/#findComment-134629 Share on other sites More sharing options...
keeB Posted December 4, 2006 Share Posted December 4, 2006 It's going to be pretty hard to compete with Dice, Hot Jobs, Monster, etc etc ;x Quote Link to comment https://forums.phpfreaks.com/topic/29354-very-confusing-conditional-statement-problem/#findComment-134661 Share on other sites More sharing options...
unitedintruth Posted December 4, 2006 Author Share Posted December 4, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/29354-very-confusing-conditional-statement-problem/#findComment-134723 Share on other sites More sharing options...
HuggieBear Posted December 4, 2006 Share Posted December 4, 2006 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]<?phpif ($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]RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/29354-very-confusing-conditional-statement-problem/#findComment-134726 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.