
AMcHarg
Members-
Posts
84 -
Joined
-
Last visited
Never
Everything posted by AMcHarg
-
Automatically Putting a Noindex to Pages With No Content
AMcHarg replied to zehrila's topic in PHP Coding Help
Well it depends how much control you actually have over the pages. Can you open them and edit the code in them? :-\ -
What errors are you receiving?
-
PHP is server-side, you can't achieve what you want with it. Note as well that Java and Javascript are completely different things. To do this you want to use Javascript, not Java. Good luck.
-
Incidentally, this should be moved to a forum area where Javascript is the designated topic.
-
It can be done with Javascript. You could alternate a value that the button reads and changes each time it is pressed. If the value is 0 then it can insert [ b ] into the text area (and then change the value to 1), and if it's 1 then it can insert [ /b ] into the text area (and then change the value back to 0 again).
-
I think some clarification is in order. Your original post implies that there will be more than two levels of information, like this (using groceries as an example to ease its explanation, and have marked numbers to show the $level) ... (1) Groceries (2) Dairy (3) Milk (3) Butter (4) Low Fat Butter (4) Full Fat Butter (3) Eggs (2) Fruit (3) Apples (3) Bananas (3) Oranges (4) Large Oranges (4) Small Oranges If the above is what you are looking for then your code will not do it. Coding a loop into a loop will only work if you have two levels. If you have three levels then using your method you would need to do a loop in a loop in a loop, and so on. This method still works, but it means you are limited to the number of levels you can have. As a sidenote: when I mentioned pseudocode it's a pretty major part of planning a complicated piece of code. Most on here will just write code because the pieces of code are small and they are experts at it, but if you can't get your head around how to program something you should first try to get your head around the logic of what needs to happen (in plain English). Your example isn't pseudocode. An example would be: - Loop through the level 1 items - For each item, output it and call a function to get it's children - The function should output the first child and then call itself, increasing the level by 1 to get the grandchildren. - The process is repeated recursively, but the function continuing to call itself until it has exhausted all the rows. If only two levels then your way works, as follows: - Loop through level 1 items - For each item loop through it's children Using your method, for three levels, your way works as follows: - Loop through level 1 items - For each item loop through it's children - For each item loop through it's children But, as stated previously, this method will limit the number of levels.
-
He still needs the AND statements, otherwise the SQL only requires one of the criteria to be satisfied before it pulls something out, and I don't think that's what he wants.
-
Sorting headers has solved this kind of problem for me in the past. Slightly off topic from the actual coding side of the above, but is it true that having 'flown' for a virtual airline during training, a qualified pilot has an advantage when applying for a real airline flight crew position over others?
-
Why don't you just create another two fields and separate the data?
-
With a carefully positioned IF statement and counter in a WHILE loop you can establish the student name and follow it with the comments to that student... $query = mysql_query("SELECT * FROM table WHERE teacher_name = 'Mrs Smith' ORDER by Student_name ASC, comment_date ASC"); $x=0; $previous_student = ''; while ($row = mysql_fetch_array($query)) { $current_student = $row['Student_name']; $comment = $row['comment']; $comment_date = $row['comment_date']; if (($x == 0) OR ($current_student != $previous_student)) { echo"Comments for $current_student<br>"; } echo"$comment_date $comment<br>"; $previous_student = $current_student; $x++; } I haven't tested the above so please forgive any syntax errors.
-
Can you give an example of the output you want? After re-reading I think you mean that you want... Comments by TeacherX Comments to Student1 Comment 1 Comment 2 Comment 3 Comment 4 Comments to Student2 Comment 1 Comment 2 etc... is that correct?
-
This is fairly simple to achieve. Just add the appropriate filtering into your queries to extract where teacher = x and/or student = y.
-
mysql_query($sql = "INSERT INTO kb_services (serv_text,serv_freq,serv_cost,serv_desc,serv_type) VALUES ('$a','$b','$c','$d','D')"); Why $sql = ? It's not needed.
-
I don't see anything wrong with your LIKE syntax, or the rest of the query for that matter. Perhaps it's actually pulling out the correct thing and it's the database records which are incorrect. Have you double checked the posterID of each record to make sure they aren't actually all equal to 1?
-
Don't see why you need an array. Why not just have another variable in the while loop that totals up $var each time it loops? Like... $sum_of_var = $sum_of_var+$var; Or am I misunderstanding?
-
You also need to make sure the empty cells in your database are actually NULL and not just simply empty, otherwise they are neither full of text that you want, nor NULL.
-
You need to use brackets around your "OR" statements, like this: AND (something='$something' OR something='$something') AND ... etc Also: be consistant with where you use quotes
-
Have you written some pseudocode, or any php code? If you have then you should post. If I were you I would add another field into your database, entitled "level". In your case id1 would be level 1, id2&3 would be level 2 and id4 would be level 3, and so on. Loop through the top levels and each time you do so, call a function. The function will then loop through the first of the next level and output it, see if it has any children and output them, and it will keep repeating the process by calling itself. It basically keeps calling itself until it has output the whole tree structure. You might find some examples on Google if you search for "php tree structure", or the like.
-
Yea, this would be kind of like the landlord of the house you're renting not having a key. They probably won't come in without your permission but you wouldn't leave your magazine collection just lying around.
-
Ah that's what I get for copy+paste too much. Remove the curly bracket.
-
Writing comments to file instead of storing them in a database
AMcHarg replied to billcarson2's topic in PHP Coding Help
Well it would work if very few people were adding comments but it's not a very dynamic way of doing it. -
You need to write a recursive function.
-
Hash the input using the same md5 function and compare the strings.
-
Oh are referring to the time it takes to do the queries causing a timeout problem?