Jump to content

WebStyles

Members
  • Posts

    1,216
  • Joined

  • Last visited

Everything posted by WebStyles

  1. <?php // defines what you want to select from the database table called users, in this case * means select everything. $query = 'SELECT * FROM users'; // requests the above task from your database server $result = mysql_query($query); // while each record is being pulled out, perform whatever is in between the curly braces {...} while ($query = mysql_fecth_assoc($result)) { // grabs whatever value is in field 'Name' (of your database table) and stores it in a variable called '$field01' $field01 = $result['Name']; // same as above, but for field 'Username' $field02 = $result['Username']; ... } ?> this code won't really work though, you have several errors.
  2. try this to create groups inside the select box: <?php $genre_list = array( array("ACTION", "First Person Shooter"), array("ACTION", "Third Person Shooter"), array("ACTION", "Tactical Shooter"), array("ACTION", "Fighting"), array("ACTION", "Arcade"), array("ADVENTURE", "Adventure"), array("ADVENTURE", "Platformer"), array("ADVENTURE", "Point and Click") ); $group = ''; echo '<select id="genres" name="genres">'; foreach($genre_list as $item){ if($group == '' || $group != $item[0]) echo '<optgroup label="'.$item[0].'">'; $group = $item[0]; echo '<option value="'.$item[0].'-'.$item[1].'">'.$item[1].'</option>'; } echo '</select>'; ?>
  3. you said it man: is it not working for some reason?
  4. Anything is possible! can you post your code please? thanks.
  5. As I said before, when someone logs in, you check the account type (once) and store it in a $_SESSION variable, to avoid database queries on every page load.
  6. hmmm... To be honest, I really don't like a lot of things there... Logo is too big (CJM means nothing to visitors, and shouldn't be so distractive, even if your goal is for them to remember the logo... when they get home at the end of the day, they'll remember CJM but still not know what it stands for, and it won't even help them find the site again, since a search for CJM returns too many other results), Top buttons are too big... then the italics don't seems to make sense... when you do this: Web design and Development you're giving the word 'Web' the same importance as the word 'and'... just feels wrong. The background image looks like a rip-off of the original Mac OS desktop backgrounds converted to black and white (and also lacks quality) Almost all the text is too big... (I'm on a screen that has 2560x1440 resolution and it still looks too big, on a laptop it must look huge) The text explaining the project details disappears under the limit line (gets cut off) - I'm using Firefox on a Macintosh... I would go for a 'cleaner', easier to read, more objective design... also, everything is too dark... Ever noticed how all the big sites (facebook, google, youtube, gmail, microsoft, etc... always use white as background, and simple small black text? and most of them adopt blue as their main color? There's a reason for that. Blue is the color that puts the less strain on your eyes, simplicity directs attention to where it's needed, etc...)
  7. I agree with the other guys: lose the splash page. (A couple of years ago, statistics said that for every extra click you lose 10% of your visitors...) I also don't like the double forward slashes (//) on the main menu items, and they don't behave the same with different letters ( before the A they're fine, because there's space to breathe, but they get glued to the C,B and H ). Other than that: Looking good. p.s. Maybe the images on the homepage could be optimized a bit more? I'm on a very fast company connection, and they still took a few seconds to load.
  8. sorry, I meant .csv (.txt .csv, same thing to me, they are flat text files...) if you open your .cvs in notepad, does it also contain the weird  thing? or only in excel? Try opening it in an editor that will allow you to change the encoding, or create a new one with the same encoding you're using in php.
  9. getElemebtById means you're accessing an element by it's id tag, if you don't have one, it won't work... if you simple add an id tag to your select, so instead if this: <select name="Activity"> you'll have something like this: <select name="Activity" id="myActivityCombo"> then you can easily grab the selected value with something like: var selectedValue = document.getElementById("myActivityCombo").value; hope this helps
  10. hmmm... check out mb_internal_encoding or similar. You'll probably also need to make sure you're .txt file was created with the same encoding. UTF-8 is a good way to go for such a thing.
  11. interesting, I used the same code here, and the only blank line I get is the first line of the file. (but I'm on a Mac, so newlines are \r and not \n here)
  12. yes. On login you would store the accountType in a session variable and redirect based on that account type. That code I gave you basically unsets all session variables if a user tries to access a page he's not allowed to... it's just a very basic example. Like I said, the best way would be to set up a 'proper' permissions system. This is the first think I analyze/do at the beginning of every project, and for me, The most important aspects of any project are: Access Control, Activity Logging (so you know exactly what was changed/accessed, when and by who), and History Tables (so you can rollback on unwanted changes if needed)... If you're working on a project that has the need for 4 different account types, I'm guessing it's pretty big, so you should consider all of the above, plus a proper backup/replication system in case of hardware failure, hacking, etc...
  13. The list of files will be the same (in this particular example), except it won't move you into the directory... still, since it's a simple php script that's always running from the same directory, always including the path to execute the commands could help. Anyway, a simple google search for 'php shell terminal' returned this: http://sourceforge.net/projects/phpterm/. hope this helps
  14. you should have just one login page, and have the users flagged as 'user', 'admin', etc... in a database... so you're login table would look something like: id,userName,passWord,accountType it's not good to have 4 different login pages, you can simply redirect them to the appropriate page after login, based on their accounType setting. This will make things easier to maintain. The username WILL NOT help you restrict access unless you want to query the database every time a page is loaded or refreshed... Like I said before, I would use just ONE login page, and control all accesses and redirects based on accountType that can easily be stored in $_SESSION. (to do things properly, you should have a table that defines specific permissions for each user... what If you wish to have a read-only manager? or an admin that can user all the admin pages except one of them? what if you want a specific basic user to be able to see just one of the manager pages ? etc...)
  15. try forcing a new line character... instead of this: fwrite($handle,"$countries,$accriss,$price,$number"); try this: fwrite($handle,"\n$countries,$accriss,$price,$number");
  16. also, many commands can be done on one line... this: cd ..; ls is the same as: ls ../
  17. since you'll probably be using ajax to update the chat window, also use javascript to update the timer.
  18. or die ("whatever I want to write");
  19. why? you should use just one login page, this will ensure that the session variables are overwritten when you login as a different type of user... I'm saying this because I'm guessing (I may be wrong) you have something like $_SESSION['admin'] = 'yes' when you login as an admin... and another one like $_SESSION['basicUser'] = 'yes' for your other login page... And I bet what happened there was you tested your login as admin, and it worked... then you tested logging in as another user, and since the first variable ($_SESSION['admin']) was not replaced, you still have access to your admin pages.... this is wrong. You should use $_SESSION['accountType'] = 'admin' (or 'basic' or 'moderator' or whatever)... this way when you login with another account, it will get replaced. Then all you need to do is check each page against that variable, so on admin pages you will have something like this at the top: session_start(); if($_SESSION['accountType'] != 'admin'){ foreach($_SESSION as $k=>$v){ unset($_SESSION[$k]); } echo 'Permission denied. You have been logged out'; exit(); } Just guessing.... put this on every page to check your session variables and find out what's wrong: echo '<pre>'; print_r($_SESSION);
  20. I confess I didn't look at your code (I'm at work and don't have much time right now, so I'm only guessing, maybe you're already doing this, in which case I apologize.) but if you have a field with 'one two three' and you search for 'one three', you're gonna need to use LIKE and the wildcard % so you could basically replace all spaces in the keyword with % (and also add it to beginning and end for other situations to work too)... so: $keywords = "%".str_replace(" ","%",trim($_POST['keywords']))."%"; then use something like mysql_query("select filed1,field2 from table where keywords like '$keywords'"); hope this helps
  21. c'mon, just try what I suggested first, and then worry about wrapping it into a function. <?php $initialArray = array(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15); $chunks = array_chunk($initialArray, 4); $final = array(); $key = 0; foreach($chunks as $k=>$chunk){ for($i=0;$i<4;$i++){ $final[$i][$key] = $chunk[$i]; } $key++; } echo '<br>'; print_r($final); ?>
  22. well, yes, it *did* matter. If it were always a sequence of numbers I would suggest a different approach. In this case, try my first suggestion.
  23. you're missing a single quote on line 14 before mmmm.
  24. hmmm... array_chunk will allow you to split into groups of 4 elements, but will maintain the same order as the original array... You could then re-organize them with a simple for() loop using the keys 0,1,2 and 3. How is the original array built? (what values will it contain? just a sequence of numbers like your example? or can it contain other values or non-sequential values?)
×
×
  • 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.