hi guys,
i want to express the data which is extracted from database in a table
in the following fashion
item1 item2 item3
item4 item5 item6
item7...........
............itemn dynamically

but i can express either row wise or column wise but not as shown above

please help me with the code how can i do so..:?:

$resultArray = mysql_fetch_array(mysql_query("SELECT * FROM table"));

or don't I understand your question?

Hi Rohit,
Advice is free. It's your job to develop the code.

You have defined the output that you want. If you aren't sure of the logic needed to get that result, then I suggest that you develop some pseudo-code to work out the logic before trying to make it PHP code. It may take a while and you may have to revise it a number of times before it seems to do what you need it to do but that is what programming is all about. The only way that you get better at it is to do it. If someone hands you the answer, then you will hit the same situation again and you will be no better at it than you were the first time. In order to give you an answer, I would have to go through the same process and what is the point of that for me or for you?

If you get to some pseudo-code that seems to be what you need, then you turn it into PHP and test it. It may not work exactly as you had hoped and then you dig at it again and figure out why. Again, that is what programming is all about. Once you have gone through the whole process and if it is still not working, then you could bring back some code or even pseudo-code, outline what you have already tried, what isn't working and ask a specific question. That is how one programmer should address a question such as this to other programmers. If you are new at this, it doesn't excuse you, it just means that you may have to spend more time before you are ready to ask a proper question.

This isn't meant to be harsh, just realistic. In the past, I spend many many hours working out logic puzzles like this and that is how I learned. Now I can do it faster but only because I've done similar things before. In order to be a competent programmer you need to be able to develop the logical flow of the program (without help) and you need to be able to debug it if it isn't working properly. Some people seem to use Daniweb as a short-cut because they are missing the natural ability or haven't spent the time to develop these skills. In the end, there aren't any short-cuts other than hiring someone else to do it or finding an open-source program that already does it.

commented: Absolutely agree +3

I really like chrishea's answer. Try out the problem yourself. I know the answer to this question as soon as I saw the problem since I have seen this problem before and solved it myself.

That is how you develop a good head for logic and programming skills, not by taking out a short-cut. However, if you are still not able to solve it, give us where you get stuck and we'll for sure help you out.

To start here's a hint. Use a counter and move on, the code is pretty simple.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.