Jump to content

WebStyles

Members
  • Posts

    1,216
  • Joined

  • Last visited

Everything posted by WebStyles

  1. I'm not really sure if I know what you mean, but it sounds like you're looking for a way to use a variable's value as another variable's name... So you can dinamically create the variables names... check out http://php.net/manual/en/language.variables.variable.php. here's an example: <?php // create the name you wish to use as a variable $VariableName = "rank"."1"; // Assign a value (team name) to the new variable $$VariableName = "teamName"; // echo results echo $rank1; ?> Hope this helps
  2. you'll want to put that in a $_SESSION variable so it's available on every page.
  3. $_POST variables will only exist when the form is actually submitted, not before. Unless you arrived at that page from another page that submitted an element called 'number' (or submitted the page to itself) that will not work.
  4. where does $final come from?
  5. ok, back to your first post, since this new code you psted does not even contain the variable $alpha, so it's not relevant right now... this is were the problem is: array_key_exists($i, $alpha) and this is the error you're getting: Since the error says 'the second argument', we know the problem is with $alpha. the rest of the error tells us everything: 'should be either an array or an object'. Since you expect it to be an array, we can rule out the object part. The only thing that is left it to figure out why $alpha is NOT an array... and here is were my first answer comes in. In my first answer, you'll find some code that belonged to you and some code I wrote to try and solve the problem. Replace your code (just the line I mentioned) with my code, and test again, see what happens, and get back to me please. good luck and I hope it helps.
  6. I sincerely have no idea what you mean... The code you have would work, in the sense that if ?link is present in the url, then it would make the variable $frame equal 1, otherwise 0 (as long as you remove the first line and close the block off with the missing } after your last line) What exactly are you trying to achieve? Having a config file that gets modified based on your url kind of beats the point of having a config file, in the sense that you're doing the configuration through the url and not through the config file...
  7. ok, and is there a limited number of words that can be correlated? like it the main word is 'color', how far are you willing to go in your search results, since you can add literally hundreds of colors (consider rgb codes, cmyk codes, pantone codes, html codes, etc...) I ask this because I can imagine it being done differently if there was a limit than if there is no limit of words that can relate to the first. (And how would 'relevance' come into play in this situation? don't they ALL have the same relevance to the keyword 'color' ? How are you planning or categorizing the relevance? in this case would you just pick 30 random results to show?)
  8. ... and why would you even consider asp ?
  9. you can simply order by that field, and while retrieving, check if the first character equals the previous, so you know when to change lines of add a slash. Basically you need to keep track of the first character... since the field is a string, you can grab the first character with $varname[0].
  10. well, you're incrementing $alpha on this line: $alpha[$records['letter']] += 1; but before that, where is it initialized? How are you even incrementing something that does not exist? It's bound to throw a warning. You need to check for existence first. try something like this: (mind you, I only read the first 3 lines of your code, but this seems to be the way to go) if(isset($alpha[$records['letter']])){ $alpha[$records['letter']] += 1; }else{ $alpha[$records['letter']] = 1; }
  11. That could work, but to expand the system, you would need a field with the question `category` too. (imagine you want only questions about animals, or computers) and the field `gender` if you're planning on having specific questions for males and others for females. Also, you do not need the field `questionid`, since the id will be created automatically for you in your primary key. Missing a few options here too, you'll need to add points to each question, or at the very least, flag the question that is the correct answer (I'm guessing this is a multiple choice questionaire, and this is where you store the possible answers from each user) TABLE: `userAnswers`:: `id`,`questionid`,`answerid`, `username`,`date`,`time` (Always include date and time when the data stored is based on user input, you might not need it now, but I guarantee it will be useful in the future/*real world*, and before you know it you'll be adding this to almost all your tables) Think simple to start with, then you can add/change features. You basically want a text field to input a question, and another text field for each possible answer, along with a little checkbox so you can flag the correct answer (again, I'm presuming it's a multiple choice system). Basically, if you're adding stuff to the main tables in an administrator environment, you'll need to account for ALL the fields you have in your database (Except the primary key which is automatic) so you'll also need a category dropdown (in case you follow my example above to add categories) and a GENDER radio button, checkbox, or dropdown (any one will work, depends how you want to code/style it) you post your form with all the fields filled in, and then you add it to the database in two steps: STEP 1: add the question, category and gender. STEP 2: use mysql_insert_id to grab the last inserted id and use that as your `questionid` in your `Answerslist` table when adding each answer. hope this helps
  12. then you can use something like: EXTRACT (MONTH from `date`) in your mysql query. check out other options, depending on the type of field you're using (INT with unix timestamp, or mysql timestamp) here: http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_extract hope this helps
  13. and by 'archiving' do you want to simple display them grouped by month, or actually move them to another table?
  14. actually, you're calling 'adminDeleteGoodie.php' to process the request, so that's the only other thing you have to change.
  15. not that simple, you can add a text area there, but then you'll need to change the javascript function to grab the text, send it to php, and change the php function to include that text into a database and send it to the user (by email ?)
  16. here's a simplified version that should work: (not the best way to do it though...) <html> <head> <title> Log-in </title> </head> <body> <?php if($_SERVER['REQUEST_METHOD']=="POST"){ $db = mysql_connect("127.0.0.1:3306", "root" , "password")or die("Error connecting to database: " . mysql_error()); $db_used = mysql_select_db("login", $db)or die("Could not select database: " . mysql_error()); $user_name = mysql_real_escape_string($_POST['username'],$db); $password = mysql_real_escape_string($_POST['password'],$db); $query = mysql_query("SELECT * FROM `details` WHERE `un` = '$user_name' AND `pwd` = '$password'",$db) or die(mysql_error()); if(mysql_num_rows($query) == 1){ echo "Login successful, welcome back " . $user_name . ""; }else{ echo "Login unsuccessful, please ensure you are using the correct details"; } }else{ ?> <form action="login.php" method="POST"> Username: <input type="text" name=username"> Password: <input type="password" name="password"> <input type="submit" name="login" value="Login"> </form> <?php } ?> </body> </html>
  17. lol.. I actually forgot to put the space between the ''. this one will work. Just replace ' ' with whatever you want in case you need smaller or bigger spaces. $content = str_split("abc"); foreach($content as $letter){ echo $letter == ' ' ? ' ' : '<img src="images/'.$letter.'.jpg" >'; }
  18. $content = str_split("abc"); foreach($content as $letter){ echo $letter == '' ? ' ' : '<img src="images/'.$letter.'.jpg" >'; }
  19. what you're looking for are permutations. Do you have any code to show us, so we can try and help, or do you just want someone to do the whole thing for you?
  20. maybe something like this: $content = str_split("abc"); foreach($content as $letter){ echo '<img src="images/'.$letter.'.jpg" >'; }
  21. hmmm... you planning on creating a list of relevant correlations based on what the users input?... Imagine this scenario: a user interested in animals, types in 'Dogs', then types in 'Cats', then 'Horses'... And you store these as being related to each other. The next day, another user ONLY interested in dogs, types in 'dogs' and also gets cats & horses in their search result... I don't see how that can work without you manually filtering and deciding what's related or not, or checking against hundreds of similar entries before creating the relationship between words.
  22. There's nothing wrong with editing information based on a primary key, it's actually a good way to do it, since the keys are unique. You just should not be able to input the primary key manually in your edit form. The client ID should be passed from page to page through POST or even better, in a $_SESSION variable. If you're planning on posting it though the URL instead (GET method) then make sure you take all the necessary security steps and checks.
  23. so basically, you set your credit to 17,50 and tried to purchase an item priced at 25,00. but you did this: (which is not part of the code I gave you) $total_credit = $customer_credit - $TOTAL; so your $total_credit just became -7,50 (17,50 - 25,00). Since your item was 25,00 and you owed 7,50 (from having a negative credit), of course your invoice is going to be 32,50. 1. remove that line of code, and replace all instances of $total_credit with $customer_credit in the code I gave you. or (just to make it simpler for now) 2. change that line to $total_credit = $customer_credit; for testing purposes and fix variable names later. BTW: $total_credit -= $TOTAL; is shorthand for $total_credit = ($total_credit - $TOTAL);
  24. you're grabbing the category with: $category = $_POST['cat']; but then you're trying to set the target directory with: $target = $cat."/"; it should be $target = $category."/"; (since $cat doesn't even exist.) If you turn on your error reporting, all these things will be obvious and easy to find out.
  25. That is a bad idea... If you just get one number wrong, you'll mess up one of your customer details... Why exactly would you want to do this? it's better to select the customer from a list, and edit without ever messing around with the id's.
×
×
  • 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.