Jump to content

Stryves

Members
  • Posts

    79
  • Joined

  • Last visited

Everything posted by Stryves

  1. Use Sessions? That way when they view the first page you can update their $_SESSION['firstpage'] variable or something. With Sessions you could have this all on one page, and this display only what they are supposed to see.
  2. If Else? $sql = "SELECT DATEDIFF (ThinDate, CURDATE()) AS intval FROM `vegeschedule` "; $result = mysql_query($sql); if (!$result) { echo "Could not successfully run query ($sql) from DB: " . mysql_error(); } else if (mysql_num_rows($result) == 0) { echo "No rows found, nothing to print so am exiting"; } else if ($result <= 0) { echo "N/A"; } else { while ($row = mysql_fetch_assoc($result)) { echo $row["intval"]."<br />\n"; } }
  3. I'm guessing it's the redirect after the message is sent. The if($sent) then header: blah blah thankyou.html
  4. I'd do it like this <?php include('include/function.php'); session_start(); if(isset($_SESSION['userName'])) { echo $_SESSION['userName']; } else { echo "<META HTTP-EQUIV = 'Refresh' Content = '0; URL =login.php'>"; } ?> <html> <head> <title>Home</title> </head> <body bgcolor="cyan"> <center></br></br> Home View <a href="login.php">Logout</a> </form> </center> </body> </html> And for the logout: <?php session_start(); unset($_SESSION['userName']); echo "<META HTTP-EQUIV = 'Refresh' Content = '0; URL =login.php'>"; ?> I changed the redirect to login, because the index should redirect them to login now anyways.
  5. You allow any type of file to be uploaded? That's scary!
  6. So let's say I run a query: <?php $query = "SELECT * FROM table"; $result = mysql_query($query) or die(mysql_error()); $array = mysql_fetch_array($result) or die(mysql_error()); ?> So now I would use $array['ID'] somewhere in my code... Isn't this a Global Variable considering it can be used almost anywhere?
  7. I have this <?php include "summary.php"; include "stufftodo.php"; ?> I want the summary to load AFTER stufftodo is ran... Or at least show at the top of the page. The problem is obviously if it loads first, it will load out dated data. I'd like the summary to be that the top of the page, and not at the bottom or on the right side. Is there anyway to have a php wait for the whole page to process before it loads something that's before it?
  8. $query = "SELECT * FROM vehicles ORDER BY somecolumn DESC, somecolumn2 LIMIT 10 "; If you want to go from highest to lowest, add DESC beside the column name, otherwise it's always ascending. Just put a comma between the 2 column names.
  9. "Also, you can add in a WHERE `clientname`='NAMEHERE' to show one result, with position" Oooo nice, I didn't know if the where clientname=clientname was used, it would still show the position. I'll give it a whirl, thanks a lot!
  10. Haha, that was my concern as well... I was using the i++ increment to determine the position, but it's always better to make the DB do the work. My other solution was creating a table for results, and cron job it to run/refresh every night... Just have static results per day. I wasn't sure if there was an easier way to do this... Guess not
  11. The query is is running, from top sales down. $i=1 when the while is running, if the client name is not the current result, i increments, and then the while runs again. If the clientname is matched during the 5th run through the while, the $clientrank = 5. This way I'd know they are 5th best in sales.
  12. Yes I could, but then it would just show me how many sales they have. I was hoping to determine where they rank VS the other staff.
  13. $query = "SELECT * FROM vehicles LIMIT 10"; Additionally, you can use the following to order by the somecolumn being a real column to select what area of first 10 you want. $query = "SELECT * FROM vehicles ORDER BY somecolumn LIMIT 10 ";
  14. I'm trying to determine what place someone is based on a query. <?php Query is "SELECT clientname, sales FROM clients ORDER BY sales DESC" $i=1; while($query) { if($query['clientname']==$_POST['clientname']) { $clientrank=$i; } i++; } ?> Is there any easier way to do this?
  15. I think the question is 1. Someone goes to one.domain.com 2. How do you grab the "one" and do a query to grab the links for anyone that goes to "one".domain.com, because someone going to "two".domain.com would receive a different set of links. mod rewrite would probably be easiest, because then you could have it specified via path and string... I'm guess if that's what you are looking for.
  16. I've been doing minor adjustments to my code lately and I was curious about the following... 1. Let's say we run $query = "select * from clients" (I'm suming up here... ) 2. If I declare that $clientname=$query['clientname']; 3. I use the variable $clientname 10 times in my code. Does it check the database ten times to find the clientname, or does it only check the first time to determine the variable value? The reason I ask, I don't want to constantly check the database if it can be avoided... It may be very minimal, but I was lead to believe that using $query['clientname'] ten times would check the database each time. Sometimes I use variable 50-100 times in my code I'm building.
  17. I knew this was the right place to come... Just seconds after posted and trying to ensure I didn't sound like an idiot it clicked... "Oh right, brackets!" Thanks everyone!
  18. I'll try a test run using brackets like: ((x=='1' && y=='1') || (x=='2' && y=='5')) and see if this helps... lol.
  19. I'm not sure if this is bad practise or not, but is it possible to do this: <?php if(x=='1' && y=='1' || x=='2' && y=='5') { // Do This } Instead of <?php if(x=='1' && y=='1') { // Do This } else if(x=='2' && y=='5') { // Do This } I'd prefer the first method so that I am not duplicating code. I'm noticing that it looks like the code checks "|| x=='2'" and ignore's the && so that if x=='2' it runs, and ignores whatever y is equal to. Is that intended? Worst case scenario I'll just use included files to try and avoid reproducing a lot of code.
  20. Just curious if anyone had any issue's with have 4 && conditions in an IF statement. I've had several fail checks, and I don't know why. If I do 1==1 && 2==2 && 3==3 It will work fine... if I do 1==1 && 2==2 && 3==3 && 4==4 it fails? It's easy to work around, just have if 1==1 then check if 2==2 - 4==4 etc... but wasn't sure if it's known issue?
  21. nevermind, I forgot to add the percenttotal. ($randomnum>=$percenttotal && $randomnum<=$result[priority]+percenttotal) Sigh.
  22. Can't figure out what's wrong here: $query=mysql_query("select * from current where priority > '0' and type='played' order by priority DESC, name"); $percenttotal='0'; $randomnum=rand(1,100); while($result=mysql_fetch_array($query)) { if($randomnum>=$percenttotal && $randomnum<=$result[priority]) { $winner=$result[name]; } $percenttotal=$percenttotal+$result[priority]; } Basically I'd have like 10 people, and the table would be like TABLE: CURRENT Name, Played, Priority I was hoping during the while, it would grab those with highest priority first, see if they match the random number. If they don't, then use their percentage as the starting point for the next guy, and check to see if they are above or below the number drawn. If they won, declare a winner. No errors are reported, and when I echo the $winner nothing is shown... Any ideas? Made an edit, had an accidental plural
  23. If you really want someone to spend the time to answer your question, spend the time to ask it properly.
×
×
  • 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.