Jump to content

Simon Mayer

Members
  • Posts

    44
  • Joined

  • Last visited

    Never

Everything posted by Simon Mayer

  1. You should set this in your MySQL query, rather than your PHP You would need to use LIMIT to specify the maximum number of results (and an offset if you are doing a later page). At the end of your query, add something like ' LIMIT ' . $offset . ', ' . $limit You would have to define $offset and $limit by something else, such as $_GET attributes in the URL.
  2. Yes, there are a few options, but anything you do would take time to implement, as you would need to have a corresponding load option. The biggest obstacle would be getting the data from where it is stored, into the relevant rows. You could: Store the data locally (suitable on a temporary basis) by using cookies Save the data to a database, then give the user a permalink or a password to access it Output the data to some kind of file, like CSV, Json or XML and then get the user to download it. I think the database would be your best option, but you would need to structure the tables properly and then develop the queries to write to and read from the database.
  3. What is the problem you're having? The more detail you give, the more likely someone is going to be able to help.
  4. Try this: <?php $array = array('t1', 't2', 't3', 't4', 't5', 't6', 't7', 't8'); $j = count($array); for ($a=0; pow(2, $a) <= $j; $a++) //determine the highest power of 2 that will go into the array count { $y[$a] = 1; $maxpower = $a; } for ($i=1; $i < $j*2; $i++) { if($i % 2 != 0) //odd number rows for teams { $line[$i] = '<td><input type=button class="team" value="' . $array[($i-1)/2] . '"></td>'; } else { for($b=0; $b<=$maxpower; $b++) { if($i % pow(2, $b) == 0) //even rows for future rounds. every 2^1 rows for first winner, 2^2 for second winner, 2^3 for third and so on. { if($i % pow(2, $b+1) != 0) //does not divide by the next power of 2, so this must be the last available cell { $line[$i] .= '<td><input type=button class="team" value="">name="WIN'.$b.'_'.($y[$b]++).'</td>'; } else //the input will be added in a future round { $line[$i] .= '<td> </td>'; } } } } } ?> <html> <body> <table> <?php foreach($line as $row) { ?> <tr> <?php echo $row; ?> </tr> <?php } ?> </table> </body> </html> particular changes: $y[$a] = 1; name="WIN'.$b.'_'.($y[$b]++)
  5. each row has a value $i - perhaps that could be useful. If not, you should be able to create a new incrementing value as you work through the loops. I didn't go too deeply into that, as I'm not familiar with your code and didn't want to interfere with what you've done already.
  6. Changing the name is one solution, but it is good practice to use grave accents (backticks) ` ` ideally avoid reserved words AND use grave accents Eventually you may be unlucky enough to come up against another reserved word. Perhaps if the table was built by someone else. If you are used to using grave accents, you are unlikely to encounter any unexpected syntax errors.
  7. It looks like you are not validating contents before calling mail(). Try something like this. if ($_POST['codigo'] == $_POST['seguranca']) { if(strlen($_POST['relevantfieldname']) > 0) { if (mail($para,$assunto,$conteudo,$headers) == true)
  8. Here is something that works as a standalone example. You will need to customise it to work with your script, but I suspect you will find that relatively straight forward. The most difficult thing here was getting the mathematics right in order to place the rows in the right place. <?php $array = array('t1', 't2', 't3', 't4', 't5', 't6', 't7', 't8'); $j = count($array); for ($a=0; pow(2, $a) <= $j; $a++) //determine the highest power of 2 that will go into the array count { $maxpower = $a; } for ($i=1; $i < $j*2; $i++) //needs almost twice as many rows as teams { if($i % 2 != 0) //odd number rows for teams { $line[$i] = '<td><input type=button class="team" value="' . $array[($i-1)/2] . '"></td>'; } else { for($b=0; $b<=$maxpower; $b++) { if($i % pow(2, $b) == 0) //even rows for future rounds. every 2^1 rows for first winner, 2^2 for second winner, 2^3 for third and so on. { if($i % pow(2, $b+1) != 0) //does not divide by the next power of 2, so this must be the last available cell { $line[$i] .= '<td><input type=button class="team" value=""></td>'; } else //the input will be added in a future round { $line[$i] .= '<td> </td>'; } } } } } ?> <html> <body> <table> <?php foreach($line as $row) { ?> <tr> <?php echo $row; ?> </tr> <?php } ?> </table> </body> </html>
  9. I think I can do something, but it probably won't be tonight. In case it helps, I've worked out that the teams appear on every other row in round 1 on every fourth row in round 2, every eighth row in round 3, etc.
  10. Just so I understand, are you wanting to produce something like this? A -A or B B --A or B or C or D C -C or D D
  11. Just a thought... Did you mean to use $name? If you have $this->id, I'd expect you to be using $this->name too.
  12. The repeating background image in the footer (/style/black/menu.png) looks like a tyre-tread, viewed from above. I think it is distracting to have it fade, then be followed by the dark top edge of the same image, then fade, and so on. Also, I think you should consider have the same username/password for the main site and the forum. You can probably merge these from the outset, but once you have users registering separately for both, it becomes extremely difficult.
  13. I think there is too much contrast between the dark-blue background and the white space - particularly the "Need a Mortgage" banner. Perhaps either a lighter background colour, or a way of blurring it into the white spaces would be better. Also, the "New listings" are too tightly packed. Perhaps increase the margin/padding below each listing.
  14. Will something like this do? <?php $array = array('t1', 't2', 't3', 't4', 't5', 't6', 't7', 't8'); $j = count($array); for ($i=0; $i < $j/2; $i++) { echo $array[$i] . ' V ' . $array[$j - $i - 1] . '<br/>'; } ?>
  15. It's not possible to see where you need to echo, as we cannot see the bit of the page that contains your submit button. It would be easiest to explain if you can provide your full code (including HTML) for the page.
  16. That sounds like your browser is caching the results. The new timestamp maybe allowing another download. What happens if you load the page in the browser with a different GET value each time? e.g. yourlink.com/index.php?stopcache=1 yourlink.com/index.php?stopcache=2 , etc In theory that should prevent caching, as each load has a unique URL. It's a primitive method, but suitable for testing purposes.
  17. I think extract() is the problem. I suspect that when extract() has run once, id has already been defined and so the value is not overwritten the second time extract() is called. You could use EXTR_OVERWRITE, as per the PHP manual: http://php.net/manual/en/function.extract.php, but I really wouldn't recommend it. I think that extract() probably causes more problems than it solves. You would be better avoiding extract() and using $row->id, $row->bedrijfsnaam, etc instead
  18. Are you wanting to generate fixtures for the teams, or just display fixtures according to a particular order? Also, what is the exact data in your $teamname array? i.e. what happens if you print_r() it?
  19. have you identified what EXACT query is being executed? Why not try echoing your query to the page. (just noticed you did that already) I suspect that there is something wrong with it, a misplaced quote, a backslash in the wrong place, etc. Once you have echoed it, if you can't work out the problem, post the query here.
  20. You can do the following: if($_POST['rat'] == 'Attack') { //rat was attacked } elseif($_POST['slime'] == 'Attack') { //slime was attacked } which would get quite long if you have lots of attacks. Or you could do the following: HTML <p>Choose which monster you want to hunt:</p> <form action='main.php?p=hunt' method='post'> <input type='submit' name='attack' value='Rat' /><br /><br /> <input type='submit' name='attack' value='Slime' /><br /><br /> <input type='submit' name='attack' value='Something Else' /> </form> PHP switch($_POST['attack']) { case 'Rat': //rat was attacked break; //this is needed to prevent your slime attack scenario being called at the same time case 'Slime': //slime was attacked break; //this is needed to prevent your something else attack scenario being called at the same time case 'Something Else': //something else was attacked break;//break is optional for the final event, but it does no harm to leave it there }
  21. There is something a little bit odd about your From header. If you are just including the email address, it's not normal to use <> I'm not sure if it's non-standard, but I would expect to either see: $success = mail($EmailTo, $Subject, $Body, "From: $Email"); or $success = mail($EmailTo, $Subject, $Body, "From: $FName $LName <$Email>"); Generally, I'm also against putting variables inside quotes. It's better to do this, so you can work out what is going on more easily: "From: " . $FName . " " . $LName . " <" . $Email . ">" I see spaces in the name value for First Name and Last Name. You should avoid spaces. Use an underscore instead. Just out of interest, the following is a better way of redirecting // redirect to success page if ($success){ header('Location: thankyou.php'); } else{ header('Location: error.php'); }
  22. It might be that gmail is sifting the message out. Have you checked your junkmail? Also, do you have another address you can send to? (preferably not @gmail) If it fails to send to other addresses, it may be something with the php installation/configuration. If you have a web-host, you may need to speak to them. Not sure I can offer any more advice than that, as the code appears correct.
  23. Eloquently put. I was simply stating that because default was at the end of that example, a break wasn't needed. I agree it's good practice to include it though, for the reasons you've specified.
  24. Ah, just realised that $cart is not defined in mail.php You will need to define it in mail.php as well: $cart = $_SESSION['cart'];
  25. What is the exact problem you get? Does the mail deliver? You don't have any header information, such as a From address, which may cause you problems. Try: if($_POST['sendemail'] == 'Email') { $headers = 'From: Sender <address@domain.com>'; mail('youraddress@domain.com', 'Subject', $cart, $headers); echo 'Your mail has been sent'; } else { echo 'Your mail was not sent'; } The echoed text will tell you if the mail function is being called. Also, it's best not to put your real email address in forum posts, as it will increase the likelihood of you receiving spam in the future.
×
×
  • 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.