PHP - Puzzle
Hello dear friends,
My mind no longer able to think about it so please help me let say we have 2 database tables Table_one (id,user,code) example user can post many codes (1,user1,code1) (2,user1,code2) (3,user2,code3) (4,user3,code4) Table_Two (id,code,hits) example (1,code1,100) (2,code2,50) (3,code3,40) (4,code4,80) the common between both is the code but i wanna say Get me the sum of hits - of - all codes that is only for user1 i did tried this but didn't works logically maybe by saying Code: [Select] $sql = "SELECT COUNT(hits) AS totalhits FROM table1,table2 Where table2.code=table1.code and table1.code=?????????"; $cus= mysql_query($sql) or die($sql); $count = mysql_fetch_array($cus); if we know how to say instead of ???????? the following; and table1.code added by user1 maybe we can get it right can we really get it thanks results should be totalhist = 150 Similar TutorialsI am trying to write a script for a puzzle based on the user's IP address, but I just can't wrap my head around how to do it. Essentially, when the visitor loads the page two things happen: (1) a PHP application returns an image to serve as a background for the formula, (2) implement the algorithm of generating the formula based on IP, that is displayed on the image.
The puzzle itself would be in the form of ABC.DEF.GHI.JKL where each letter would be associated with the corresponding digit in their IP addy. The user is trying to solve for partial map coordinates. So, let's say the correct answer is N 35 54.374 W 084 01.829 and the user's IP is 075.036.025.058. The formula returned and placed on the image would be N 35 54. (E) (B) (F - H) W 084 01. (L) (H) (B + H) Whatever I use as the final correct answer will not change and be the same for all users; only the puzzle formula would differ for each user as it would be based on their IP at the moment. Any help here would be greatly appreciated. Thanks! Gary I am very new to PHP and very eager to just understand all of the stuff i have been desperately trying to get to work for the last week. I decided to give up on copy pasting and actually find help. My main project right now is this: I want to have a website that I can edit from within a logged in section of the site (I've got the login part figured out - that is I have some code that at least has a pass and usrnm). I have a events page with 4 events, each event consisting of date, header and text: Code: [Select] <div id="event"> <p class="date"> <? include_once('date.txt')?> </p> <h3> <? include_once('header.txt')?> </h3> <p class="eventinfo"> <? include_once('text.txt')?> </p> </div> I use .txt includes so that I can edit the actual texts inside of a form. My first attempt was to edit each file inside of one page. Failed due to Code: [Select] <?php echo $_SERVER["PHP_SELF"] ?>. Second attempt was to have the page get edit.php file: Code: [Select] <?php $fn1 = 'date.txt'; if (isset($_POST['content'])) { $content = stripslashes($_POST['content']); $fp1 = fopen($fn1,"w") or die ("Error opening file in write mode!"); fputs($fp1,$content); fclose($fp1) echo("Date has been saved") or die ("Error closing file!"); } ?> <form action="<?php echo $_SERVER["PHP_SELF"] ?>" method="post"> <textarea rows="5" cols="40" name="content"><?php readfile($fn1); ?></textarea> <input type="submit" value="Save"/> </form> And have the page reload and get edit header section, then reload again for the text. But didn't see how to do this without making three pages. What I want is that I can within at least tow pages do all the following: Login, choose which event to edit, then adit all three parts and save. My brains are fried from the combination of learning PHP and being over excited about having a working system. Hopefull for some answers! Thanks!! PS: my events page http://naturalhorse.me/sites/testing/events.php Thanks, Isa. |