Jump to content

SergeiSS

Members
  • Posts

    239
  • Joined

  • Last visited

Everything posted by SergeiSS

  1. dzelenika - you are right, of course. But I like the form that you show as "$name", because it's obvious in many situations. Mainly when there are many parameters are variables. Concerning topic starter's question: // this string '<td width="230px"><li class="directory-store-name"><a href="directory/name.php?id=$id" title="$name" />' // could be changed to this - also variable $id will be used in correct way "<td width=\"230px\"><li class=\"directory-store-name\"><a href=\"directory/name.php?id=$id\" title=\"$name\" />"
  2. Winstons's solution is correct, of course. But in order to you know - you don't have to use this function nl2br() in 2 cases: //if you show this text again in textarea, maybe in any form, for editing echo '<textares>'.$results['post'].'</textarea>'; // or as I said earlier - you just send it to browser with PRE tags and browser show it correctly echo '<pre>'.$results['post'].'</pre>';
  3. Well... Let's start again. "Am adding text with paragraphs into my database" - what is the source of you code? Somebody add info at your page? If "yes" - what do you use for it: textarea or any other object? You didn't show it in your code.
  4. Instead of this code echo $results['post']; // the main body of the article Try this echo '<pre>'.$results['post'].'</pre>'; // the main body of the article
  5. First of all show you code Otherwise it's difficult to say something.
  6. asurfaceinbetween - you may also change a way to store your values and then use JSON funcions. // initial data: store in array $a=array( 12=> 'abc', 'cfd' ); // encode info $b=json_encode( $a ); // echo or save into DB as a single string echo $b.'<br>'; // restore from DB and then decode $c=json_decode( $b, true ); // you have you initial data! print_r($c); This way is more convenient because you may store a complex object. For example, you may store 2 or 3 dimentional arrays. If you use explode you would make a lot of code.
  7. Idea is good Realize it and enjoy your job. For step 2 it would be nice to create a special function. It would take an id (name etc) of article and add 1 to column viewed.
  8. It seems that nobody will load your files... You would better show your code in the forum. Just select and show here the important part of the code.
  9. First of all - show you code (query). Otherwise it's impossible to say anything.
  10. If you go to the manual and read about GROUP BY and aggregate functions... Then you will find that count() counts the number of records in the group. BTW, what is the meaning of your nick-name? I know this word only as a former name of one town in Russia.
  11. It seems that you have to read this http://en.wikipedia.org/wiki/Database_normalization
  12. You wrote a lot of words... But the solution is easy. You have to change you request, something like this, if the name of the table is 'items' (that table with structure id-name-image): SELECT *, count(id) as c FROM items GROUP BY by name you may also add any WHERE conditions. Read more about GROUP BY in the manual.
  13. I agree And you see, it's funny... At russian PHP forums the same question is discussed very often. Some people say that they like frameworks and they like to use frameworks only. Other people say (and me also) that frameworks are not bad things. But if you like to be "PHP programmer" and not "framework user" you would better learn PHP first of all. I'm programmer That's why I say that it's better to learn PHP. I'd recommend to split any task into small tasks, like any program is splitted into functions and procedures. Then you are learning how to solve one task, from the beginning to the end. Then you take other task and so on. Once upon a time.... You would be surprised that you solve a very complex task
  14. You would better look for this info in Google, just ask for "SQL injection PHP". There are some functions, some restrictions: a lot of articles discribe it. I don't like to repeat it here. You are welcome Be careful with quoutes: sometimes you have to put this quote ` around column names and table names when using MySQL.
  15. PS. You update is opened for SQL injection! You'd never use data from POST directly. Use special functions for conversion.
  16. "'p_bannerads' = '".$_POST['p_bannerads']."'" and all others are incorrect! You have to use other type of quotes for column names (sorry, I don't know exact name) "`p_bannerads` = '".$_POST['p_bannerads']."'"
  17. I think you would better forget your code and try to understand how to do it. Then you will create new tables and write new code. Here you need 2 tables. One (1) is for relation between users and a set of questions and other (2) for answers. And, maybe, 3-d table for questions and correct answers. And or course you'll need a separate table (4) for users. In the table 1 you have to create a unique id for a set of questions. Here you'll write userID, create a unique id for this set of questions (it will be used in the second table). In the table 2 you have to write every answer in a separate row, just 2 columns are enough (id of a set of questions from table 1 and answer). Or you may add 3-d column here in order to show the correct answer... It's up to you. I've described it in short. And I hope you understand main idea.
  18. It was said that you need AJAX. It's true, but there is another possibility. You may load all your data into JS arrays (I think 2-dimentional array for models), in a time, when you create a page. Then you will select and show a part of this array (model), related to one exact type of the vehicle. The benefit of this method is that you load all information just at once and don't warry about it later. In the same time, this is also a defect of this method - the total traffic will be higher for every user (in comparison with AJAX).
  19. It's better to change it: $username=isset( $_POST['user_box']) ? strip_tags($_POST['user_box']) : null; And later you can check as you did it before: if($username != NULL) ... // or just if( $username ) ... offtopic: how can I highlight the PHP code here?
  20. You would better use foreach loop to iterate through the array $arr. You will automatically get array elements and (if you need) array indexes.
  21. You would get different results in different cases You may call main page in different ways: http://your-site.com/ http://your-site.com http://your-site.com/index.php These are 3 cases that you test: '/', empty or 'index.php'. It's up to you: what page name would you enter at the end of URI is what you would expect to get in the script.
  22. Why? It's not difficult. Let him try it
  23. Another possibility is to create INSERT trigger and set a new value for adid in this trigger. But then I don't know how to get it back from MySQL into PHP... In Postgre it's easy. The benefit is that you do it just in one place but not in many different scripts.
  24. You would better show a new code. It could happen that you change your code in a wrong way.
  25. It seems that it's better for you to read more about iframes and other tags. Go to this page http://www.w3schools.com/tags/tag_iframe.asp - here you'll find a lot of information about iframe and other tags. Maybe you'll find a better solution than I suggest?
×
×
  • 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.