Jump to content

How to display all records by echo in PHP


aldrin151

Recommended Posts

Hi, sound kind of stupid but how do you display all records, instead of just one...my code displays the next_record only

 

$db = new clsDBConnection1;

 

    $SQL = "SELECT sub_title FROM sub_cats where main_id='1'";

   

$db->query($SQL);

   

 

$Results = $db->next_record();

 

 

   

    echo $db->f("sub_title");

 

    $db->close();

Link to comment
Share on other sites

Why the hell would you answer back to this post and mock someone to learn PHP & Mysql first when you don't know the answer or help...? Instead of stating next_record()  to display the next record in the row, I wanted to see if I could leave it out and write something else to replace  mysql_fetch_array($Results)...I'm using a new PHP code generator for your info DUDE!

Link to comment
Share on other sites

Why the hell would you answer back to this post and mock someone to learn PHP & Mysql first when you don't know the answer or help...? Instead of stating next_record()  to display the next record in the row, I wanted to see if I could leave it out and write something else to replace  mysql_fetch_array($Results)...I'm using a new PHP code generator for your info DUDE!

 

 

I don't know the answer?

 

 

AHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHA

 

What are you, like 7?  What the hell kind of response was that?  I'm not surprised you're using a code generator.  If you're using a code generator, why would me telling you to learn PHP/MySQL offend you?

 

 

And by the way, I had assumed you were getting one result because of the ID thing.

 

 

 

Try changing

 

 

$Results = $db->next_record();

 

 

to

 

while($Results = $db->next_record()) {

  //do something with Results.

}

 

 

 

I won't be coming back to this thread.

Link to comment
Share on other sites

You obviously don't know PHP though if you asked that question.

 

 

It's easy to misread something.

 

 

I assumed you were only getting one result from the DB query since anyone advanced enough to use an OOP interface to a DB knows how to use a while loop.  I didn't even read the code after the SELECT statement.

 

 

 

 

You should learn not to be arrogant when messaging back people on this forum...

 

 

Yeah, I will never help you again.

 

 

 

How is it arrogant to tell someone to learn something?  I'm not a teacher.  I'm not here to hold your hand.  I'm not here to go "ok this line does this, and this line does this because blah."  I'm here to help with thought provoking questions.  I'm here for free, on my own spare time, answering the questions I choose to answer.  I'll respond how ever the hell I want (until a mod/admin tells me to shut my mouth ;p).  I have been wrong before.  I have crossed the line before (in hind sight).  I've stuck my foot in my mouth tons of times on here, but I stand by my "you should learn PHP/MySQL" question.  You didn't even try to answer your own question.  You were using a code generator for God's sake.  If that doesn't warrant telling you to learn the language, what does?  Would I Google translate things into Spanish and then ask someone how to say something?  That doesn't make sense if I'm trying to learn the language.

 

 

Also, you said the code generator thing like it validated your hostility towards my suggestion to learn the basics.  No it doesn't.  If I didn't do my homework correctly, and I asked a teacher how to do a problem without even trying, wouldn't he tell me to try to learn it?  "But a program did my homework for me!!!!"

 

 

 

What makes you think you can come in here with your code generator knowledge and think that you know everything?  That you can declare me arrogant because I told you to learn?  What makes you think you're special?  What makes you think you're worth my time?

 

 

 

People like you are what make me want to leave PHPFreaks.  God.

 

 

 

 

 

Edit:  I don't plan on leaving anytime soon, to anyone who reads this and would actually care if I left.

Link to comment
Share on other sites

Listen Corbin...I got you wrong and I guess you misunderstood me also...I really appreciate the help...seriously...I was having a bad day and got all screwed up. I apologize ... I really like learning from people who know more...also we're on this forum I guess to get support and help one another, "two heads are better than one" especially in stuff like this where you can get so involved in things and have a hard time solving simplest of  problems. After all this going back and forth non sense, due to my fault...I learned something...that solution you gave me worked...Thanks very much...your a cool guy.  :)

Link to comment
Share on other sites

the thing you have to understand with php is so many things can cause 1 problem,  so you may have to do a bit of trial and error to figure things out corbin's first response was one of the more obvious things that may be wrong. but hes not guaranteeing that is the only problem...

 

PHP takes a lot of Patience and perseverance

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.