
SergeiSS
Members-
Posts
239 -
Joined
-
Last visited
Everything posted by SergeiSS
-
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\" />"
-
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>';
-
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.
-
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.
-
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.
-
First of all - show you code (query). Otherwise it's impossible to say anything.
-
PHP MySQL How to grab one of each row and not duplicates?
SergeiSS replied to Stalingrad's topic in PHP Coding Help
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. -
It seems that you have to read this http://en.wikipedia.org/wiki/Database_normalization
-
PHP MySQL How to grab one of each row and not duplicates?
SergeiSS replied to Stalingrad's topic in PHP Coding Help
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. -
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
-
SQL Update is not working, can you check my syntax?
SergeiSS replied to hasif5's topic in PHP Coding Help
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. -
SQL Update is not working, can you check my syntax?
SergeiSS replied to hasif5's topic in PHP Coding Help
PS. You update is opened for SQL injection! You'd never use data from POST directly. Use special functions for conversion. -
SQL Update is not working, can you check my syntax?
SergeiSS replied to hasif5's topic in PHP Coding Help
"'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']."'" -
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.
-
Selection in one drop down box, makes another drop down box appear
SergeiSS replied to INTJTech's topic in PHP Coding Help
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). -
Form Validation : Showing errors without passing inputs
SergeiSS replied to ankur0101's topic in PHP Coding Help
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? -
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.
-
drawing lines, by getting coordinates from mysql database
SergeiSS replied to jay83r's topic in PHP Coding Help
Why? It's not difficult. Let him try it -
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.
-
PHP MYSQL Putting users into database using HTML form??
SergeiSS replied to huggies12345's topic in PHP Coding Help
You would better show a new code. It could happen that you change your code in a wrong way. -
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?