MasterACE14 Posted January 22, 2008 Share Posted January 22, 2008 Evening PHP Freaks, I have 3 mains sections on my webpage, Left panel, content and right panel. The problem is in the way I have to include them, and the way the CSS works in floating them. I have them all set to float left, so I have to include them like this: <?php include("leftpanel.php"); ?> <?php include("content.php"); ?> <?php include("rightpanel.php"); ?> but then when I do a mysql query in content by POSTing to content.php, it doesn't display the new database results in content.php or leftpanel.php because of the way it is included. Is there a way to make leftpanel.php include after content.php, but still make the CSS think it has been included first?? or something like that?? any help is greatly appreciated! Regards ACE Quote Link to comment https://forums.phpfreaks.com/topic/87187-solved-include-order-is-the-wrong-order/ Share on other sites More sharing options...
MasterACE14 Posted January 22, 2008 Author Share Posted January 22, 2008 any ideas? or things I could try whatsoever?? I'm getting desperate lol Quote Link to comment https://forums.phpfreaks.com/topic/87187-solved-include-order-is-the-wrong-order/#findComment-445995 Share on other sites More sharing options...
aschk Posted January 22, 2008 Share Posted January 22, 2008 We've not seen any of the underlying code. Once you let us know what contact.php is actually doing we might be able to help... Quote Link to comment https://forums.phpfreaks.com/topic/87187-solved-include-order-is-the-wrong-order/#findComment-446041 Share on other sites More sharing options...
MasterACE14 Posted January 22, 2008 Author Share Posted January 22, 2008 basically I have index.php setup like this: <?php include_once('leftnav.php'); ?> <div id="content"> <?php switch ($_GET['page']) { default: case "home": require_once ("lib/home.php"); break; case "bank": require_once ("lib/bank.php"); break; }// end switch ?> </div> <?php include_once('rightnav.php'); ?> with this CSS for leftnav.php(#nav in CSS), bank.php and home.php(#content) and for rightnav.php(#ads) #nav,#content,#ads {float:left} and heres bank.php with the queries: <?php // Bank // error_reporting(E_ALL); player_session(); // player info to be used $player_accountid = player_table("id"); $player_bank = player_table("bank"); $player_money = player_table("money"); // POST variables $amount_deposit = addslashes($_POST['amount_deposit']); $amount_withdraw = addslashes($_POST['amount_withdraw']); // check if its a deposit or withdraw if(isset($_POST['amount_deposit'])) { if(is_numeric($amount_deposit)) { if($amount_deposit > $player_money) { $msg = "You do not have that much money on hand"; die($msg); } else { // work out new money $new_money = $player_money - $amount_deposit; // work out money in bank $bank_money = $player_bank + $amount_deposit; // update money and bank $sql = "UPDATE `cf_users` SET `money` = '$new_money', `bank` = '$bank_money' WHERE `id`='" . $player_accountid . "' LIMIT 1"; $rs = mysql_query($sql) or die('Query:<br />' . $sql . '<br /><br />Error:<br />' . mysql_error()); } } unset($amount_deposit); } elseif(isset($_POST['amount_withdraw'])) { if(is_numeric($amount_withdraw)) { if($amount_withdraw > $player_bank) { $msg = "You do not have that much money in the bank"; die($msg); } else { // work out new money $new_money = $player_money + $amount_withdraw; // work out money in bank $bank_money = $player_bank - $amount_withdraw; // update money and bank $sql = "UPDATE `cf_users` SET `money` = '$new_money', `bank` = '$bank_money' WHERE `id`='" . $player_accountid . "' LIMIT 1"; $rs = mysql_query($sql) or die('Query:<br />' . $sql . '<br /><br />Error:<br />' . mysql_error()); } } unset($amount_withdraw); } ?> <table align="center" class = "standard"> <tr> <td colspan="4"> <center><b>Bank</b></center> </td> </tr> <?php if(isset($msg)) { ?> <tr> <td colspan="4"> <center><font color="red"><?php echo $msg; ?></font></center> </td> </tr> <?php unset($msg); } ?> <tr> <td>Money on Hand</td> <td>$<?php echo number_format($player_money); ?></td> <td>Money in the Bank</td> <td>$<?php echo number_format($player_bank); ?></td> </tr> <tr> <td colspan="4"></td> </tr> <form name="deposit" action="index.php?page=bank" method="post"> <tr> <td><b>Deposit</b></td> <td colspan="2"> <center> <input type="submit" value="Deposit"> </center> </td> <td> <center> <input type="text" size="15" name="amount_deposit" value="<?=$player_money?>"> </center> </td> </tr> </form> <form name="withdraw" action="index.php?page=bank" method="post"> <tr> <td><b>Withdraw</b></td> <td colspan="2"> <center> <input type="submit" value="Withdraw"> </center> </td> <td> <center> <input type="text" size="15" name="amount_withdraw" value="<?=$player_bank?>"> </center> </td> </tr> </form> </table> Quote Link to comment https://forums.phpfreaks.com/topic/87187-solved-include-order-is-the-wrong-order/#findComment-446044 Share on other sites More sharing options...
MasterACE14 Posted January 22, 2008 Author Share Posted January 22, 2008 bump Quote Link to comment https://forums.phpfreaks.com/topic/87187-solved-include-order-is-the-wrong-order/#findComment-446421 Share on other sites More sharing options...
teng84 Posted January 22, 2008 Share Posted January 22, 2008 Evening PHP Freaks, I have 3 mains sections on my webpage, Left panel, content and right panel. The problem is in the way I have to include them, and the way the CSS works in floating them. I have them all set to float left, so I have to include them like this: <?php include("leftpanel.php"); ?> <?php include("content.php"); ?> <?php include("rightpanel.php"); ?> you can include your files at the top and use a variable to output what you want.. notice that when you inlude the file it like you merge the content of that file in your current page but then when I do a mysql query in content by POSTing to content.php, it doesn't display the new database results in content.php or leftpanel.php because of the way it is included. Is there a way to make leftpanel.php include after content.php, but still make the CSS think it has been included first?? or something like that?? any help is greatly appreciated! Regards ACE Quote Link to comment https://forums.phpfreaks.com/topic/87187-solved-include-order-is-the-wrong-order/#findComment-446424 Share on other sites More sharing options...
teng84 Posted January 22, 2008 Share Posted January 22, 2008 Evening PHP Freaks, I have 3 mains sections on my webpage, Left panel, content and right panel. The problem is in the way I have to include them, and the way the CSS works in floating them. I have them all set to float left, so I have to include them like this: <?php include("leftpanel.php"); ?> <?php include("content.php"); ?> <?php include("rightpanel.php"); ?> but then when I do a mysql query in content by POSTing to content.php, it doesn't display the new database results in content.php or leftpanel.php because of the way it is included. Is there a way to make leftpanel.php include after content.php, but still make the CSS think it has been included first?? or something like that?? any help is greatly appreciated! Regards ACE you can include your files at the top and use a variable to output what you want.. when you include the file its like you merge the content of that file in your current page sorry.... edited.. Quote Link to comment https://forums.phpfreaks.com/topic/87187-solved-include-order-is-the-wrong-order/#findComment-446430 Share on other sites More sharing options...
MasterACE14 Posted January 23, 2008 Author Share Posted January 23, 2008 sorry, I dont understand what you mean ??? Quote Link to comment https://forums.phpfreaks.com/topic/87187-solved-include-order-is-the-wrong-order/#findComment-446638 Share on other sites More sharing options...
MasterACE14 Posted January 24, 2008 Author Share Posted January 24, 2008 I'm trying to display the new database information, by using the variables I used in the mysql UPDATE query. But I'm having alittle trouble using the isset() and unset() functions to work out if the variables have been set or not(as I use forms to POST the database back to the same page). here's my latest code for content.php: <?php // Bank // error_reporting(E_ALL); player_session(); // player info to be used $player_accountid = player_table("id"); $player_bank = player_table("bank"); $player_money = player_table("money"); // POST variables $amount_deposit = addslashes($_POST['amount_deposit']); $amount_withdraw = addslashes($_POST['amount_withdraw']); // check if its a deposit or withdraw if(isset($_POST['amount_deposit'])) { if(is_numeric($amount_deposit)) { if($amount_deposit > $player_money) { $msg = "You do not have that much money on hand"; die($msg); } else { // work out new money $new_money = $player_money - $amount_deposit; // work out money in bank $bank_money = $player_bank + $amount_deposit; // update money and bank $sql = "UPDATE `cf_users` SET `money` = '$new_money', `bank` = '$bank_money' WHERE `id`='" . $player_accountid . "' LIMIT 1"; $rs = mysql_query($sql) or die('Query:<br />' . $sql . '<br /><br />Error:<br />' . mysql_error()); } } //unset($amount_deposit); } elseif(isset($_POST['amount_withdraw'])) { if(is_numeric($amount_withdraw)) { if($amount_withdraw > $player_bank) { $msg = "You do not have that much money in the bank"; die($msg); } else { // work out new money $new_money = $player_money + $amount_withdraw; // work out money in bank $bank_money = $player_bank - $amount_withdraw; // update money and bank $sql = "UPDATE `cf_users` SET `money` = '$new_money', `bank` = '$bank_money' WHERE `id`='" . $player_accountid . "' LIMIT 1"; $rs = mysql_query($sql) or die('Query:<br />' . $sql . '<br /><br />Error:<br />' . mysql_error()); } } //unset($amount_withdraw); } ?> <table align="center" class = "standard"> <tr> <td colspan="4"> <center><b>Bank</b></center> </td> </tr> <?php if(isset($msg)) { ?> <tr> <td colspan="4"> <center><font color="red"><?php echo $msg; ?></font></center> </td> </tr> <?php unset($msg); } ?> <tr> <td>Money on Hand</td> <td>$<?php if(isset($amount_deposit) || isset($amount_withdraw)) { echo number_format($new_money); } else { echo number_format($player_money); } ?></td> <td>Money in the Bank</td> <td>$<?php if(isset($amount_deposit) || isset($amount_withdraw)) { echo number_format($new_bank); } else { echo number_format($player_bank); } ?></td> </tr> <tr> <td colspan="4"></td> </tr> <form name="deposit" action="index.php?page=bank" method="post"> <tr> <td><b>Deposit</b></td> <td colspan="2"> <center> <input type="submit" value="Deposit"> </center> </td> <td> <center> <input type="text" size="15" name="amount_deposit" value="<?php if(isset($amount_deposit) || isset($amount_withdraw)) { echo $new_money; unset($new_money); } else { echo $player_money; } ?>"> </center> </td> </tr> </form> <form name="withdraw" action="index.php?page=bank" method="post"> <tr> <td><b>Withdraw</b></td> <td colspan="2"> <center> <input type="submit" value="Withdraw"> </center> </td> <td> <center> <input type="text" size="15" name="amount_withdraw" value="<?php if(isset($amount_deposit) || isset($amount_withdraw)) { echo $new_bank; unset($new_bank); } else { echo $player_bank; } ?>"> </center> </td> </tr> </form> </table> Quote Link to comment https://forums.phpfreaks.com/topic/87187-solved-include-order-is-the-wrong-order/#findComment-447508 Share on other sites More sharing options...
MasterACE14 Posted January 24, 2008 Author Share Posted January 24, 2008 bump Quote Link to comment https://forums.phpfreaks.com/topic/87187-solved-include-order-is-the-wrong-order/#findComment-448295 Share on other sites More sharing options...
teng84 Posted January 24, 2008 Share Posted January 24, 2008 can you explain your problem a little more and your expected output out of that codes? Quote Link to comment https://forums.phpfreaks.com/topic/87187-solved-include-order-is-the-wrong-order/#findComment-448299 Share on other sites More sharing options...
MasterACE14 Posted January 24, 2008 Author Share Posted January 24, 2008 basically, I have 2 separate forms. 1 has a text box in it called "amount_deposit" and the other one has a text box called "amount_withdraw" basically, I want them to have the default value of whatever is in $player_money for amount_deposit, and $player_bank for amount_withdraw. now, when they click either one of the submit buttons, it checks whether $_POST['amount_deposit'] is set, or if $_POST['amount_withdraw'] is set. depending on which one "is set" it will run mysql_query's on the database. Which change $player_money and $player_bank. but when someone clicks one of the submit buttons, it posts back to the same page, does the queries, but the new amount for $player_money and $player_bank isn't shown in amount_withdraw or amount_deposit. The person has to refresh the page there self after pressing submit just to see the new amounts in $player_money and $player_bank. So what I'm trying to do is grab $new_money and $new_bank and echo them into the page if amount_deposit or if amount_withdraw has been set. and then unset them so they can use one of the 2 forms again and see the right amounts for $player_money and $player_bank. I hope that makes it clearer Quote Link to comment https://forums.phpfreaks.com/topic/87187-solved-include-order-is-the-wrong-order/#findComment-448331 Share on other sites More sharing options...
teng84 Posted January 24, 2008 Share Posted January 24, 2008 yes.. HERE's what im suspecting you do a select query before you update? is that right? so it will get the old value form the db then display it thats why when you refresh the page it gets the real value. Quote Link to comment https://forums.phpfreaks.com/topic/87187-solved-include-order-is-the-wrong-order/#findComment-448350 Share on other sites More sharing options...
MasterACE14 Posted January 24, 2008 Author Share Posted January 24, 2008 that makes sense now! thank you for your help Regards ACE Quote Link to comment https://forums.phpfreaks.com/topic/87187-solved-include-order-is-the-wrong-order/#findComment-448358 Share on other sites More sharing options...
teng84 Posted January 24, 2008 Share Posted January 24, 2008 men three days for this kind of problem LOL any how glad that solve it Quote Link to comment https://forums.phpfreaks.com/topic/87187-solved-include-order-is-the-wrong-order/#findComment-448364 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.