17

I started programming for some small school projects and I am learning for myself, I am still a beginner and I have a lot to learn, so sometimes my code is absolutely bad or I made some stupid mistakes, but I just don't see them.

I tried to make a new question today and I tried to be specific and check my spelling, I tried to describe the problem as good as possible and I searched for solutions, can anyone give me some advice what I should ask and how?

I don't know if a beginner like me is welcome on Stack Overflow or if I should check for another site (if so please tell me a good side for a beginner)

This is the question I am talking about: Post a specific counter inside a while loop to another page

9
  • 3
    This doesn't really improve the quality of your question, but at a glance, I see that you've used the code fence (```) and your code is indented more than four characters. Typically the fence is used for code without any indentation; code indented by four or more spaces is automatically put into a formatted code block. If I were at a computer I'd edit your question to remove the fence, and remove four characters of indentation from the code - resulting in the redundant eight characters of space on the left going. In short, get rid of this.
    – Wai Ha Lee
    Commented Apr 9, 2019 at 8:13
  • Everyone is welcome on stackoverflow as long as the question is on topic. Other than the advice given by Wai Ha Lee, formatting the HTML, I've done it for you now; you can use a HTML formatter or most good IDE's as it makes reading it easier. That and I see you are using some of your variable names in the question, I personally prefer them wrapped in these (``) so they appear like this, although some people don't like too many of them.
    – George
    Commented Apr 9, 2019 at 8:35
  • Okay thanks, I will keep it in mind and pay attention to my formatting, but sometimes it feels like the questions are to "stupid" for some people so they just dislike them, even if I try to make it as readable as possible
    – Xxy
    Commented Apr 9, 2019 at 8:46
  • 2
    This question, although is still answerable, don't have an MCVE.
    – user202729
    Commented Apr 9, 2019 at 8:49
  • 2
    Also: You should not include 'thank' in posts. See this meta post: Should 'Hi', 'thanks', taglines, and salutations be removed from posts?
    – user202729
    Commented Apr 9, 2019 at 8:49
  • If the only problems of a question of yours are about formatting and grammar, don't worry. Someone else will fix it for your. The important bit is that your question is well formed, clear and complete.
    – yivi
    Commented Apr 9, 2019 at 9:12
  • @yivi well sometimes I don't know that the problem with my question is that is why I always try to make the question clear but it still gets downvoted very fast sometimes.
    – Xxy
    Commented Apr 9, 2019 at 9:14
  • 1
    Since it hasn't been said yet, @Xxy props to you for reaching out and asking how you can improve your question. Don't let the downvotes get to you -- it is just the community's way of expressing a question can be improved. The unfortunate reality is, a lot of people don't go back to remove their downvote after it has been fixed more. I hope the answer and the duplicates that were flagged helped you!
    – aug
    Commented Apr 9, 2019 at 23:11
  • 1
    @aug Yes it helped a lot and I got some good advice here in the comments and also 2 great answers, I will try to improve my questions in the future and make my question more clear.
    – Xxy
    Commented Apr 12, 2019 at 10:53

2 Answers 2

14

As I said in a comment, this question does not have a MCVE.

To fix the problem: (note that being minimal is not absolutely required, but you're more likely to get an answer in this case because less code = more people willing to read it; also, it makes you more likely to solve the problem yourself. The parts below that only contribute to minimality is marked with (*) )

  1. Include everything related to the question. For example people would have to make up a database such that not all lines are the same to reproduce the problem. Just include the database.
  2. Even better, in this case the problem is not related to DB, so just hardcode it directly into the PHP code. (*)
  3. Is it necessary to have like 25 table rows and 6 table columns? Would 2 rows x 1 column be sufficient? (*)
  4. How do you know that it posts the information from row 25? You probably used some PHP code in edit.php to receive and further process the result. Post that edit.php too, because it might be the case that the HTML is correct but the code in that file is wrong. Of course this file also need to be stripped down to a MCVE - for example, it just prints whatever data it receives.

    Alternatively you can say something like this

    According to the networking tab of the inspector in the browser, the sent data has the header [...]

    or (in this case you use POST method so this is not possible, but you get the idea. If you use that you don't need the edit.php)

    I get redirected to the URL localhost.com/edit.php?row=25&data=line25

Applying the 4 points above you'd get a question somewhat like this (note that I don't know PHP, and the code examples below are obviously wrong)

I have some table rows on the index.php page, each row have a submit button.

File index.php:

print '<form method="POST" action="edit.php">'
print '<tr> <td><input type="submit" name="edit_1"></td> </tr>'
print '<tr> <td><input type="submit" name="edit_2"></td> </tr>'
print '</form>'

I want to post specific data to another page edit.php

File edit.php:

when (receive POST request x) {
  print x.data.button
}

For example: if I press the first button, then I want to post all data of row 1 to edit.php, which should print edit_1 to the console. However it prints edit_2 instead.

What do I have to include that the edit.php file receives the data of the row on which the button was pressed?

7

Others have already mentioned having a minimal, compete, verifiable example (MVCE), but I wanted to expand on the general philosophy behind it in a way that hopefully helps the non-code portions of your questions as well. There are really two guiding principles here:

Ain't nobody got time for that.

You're busy, we're busy, everybody is busy. The quicker the question can be read and the problem understood, the more likely it will get answers. In my case, I’m answering questions while I’m at work trying to find an answer to something related on a problem that’s taken up too damn much of my time already. I’m happy to apply the knowledge I’m gaining to help out someone in the same boat, but if I can’t figure out what’s going on in 5 seconds or so, I pass.

Similarly, most people answer questions that are easy (for them, at the time,) because our lives are already full of hard programming problems. Use what you’ve learned so far to make it an easy problem for someone. This also serves two more purposes:

  1. It forces you to exercise your reasoning skills, which will actually make you a better developer. I’ve often answered my own question before I finished typing it simply by reducing the problem further as I go.

  2. It’s an opportunity to showcase that you’ve done your homework. Clearly explaining what happens and what hasn’t worked shows you’re not just punting. There’s “I’m still learning” dumb (which we have all been at some point), and there’s lazy dumb. People really do ask questions that are answered by the first sentence of the entry in the docs, which makes SO users get a little downvote happy.

Aim for the highest value and greatest good.

It’s hard to get across for some reason, but treat this more like Wikipedia than a forum. A high-value question is arguably more important than the answer. Your question has a high value when others with the same problem find it first, and people can quickly assess if it’s what they’re looking for. Imagine you’re googling the problem for the first time, what would the perfect question look like?

Keep on doing your best and trying to improve (great job asking!) Remember, the bar seems high because you’re writing the anchor to an entry in the biggest, most important FAQ in the programming world. You’re officially a contributor, and your role is important!

1
  • The google example is really good, thanks for the answer I will try to improve my questions in the future and keeping all your advices in my mind.
    – Xxy
    Commented Apr 12, 2019 at 10:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .