[CS-FSLUG] sql queries

Timothy Butler tbutler at ofb.biz
Sat Dec 20 16:25:40 CST 2008


Do you have a column that has a numerical id in it, perhaps an index  
column so we can tell for sure which row is row 1 and which is row 2?

	-Tim

On Dec 20, 2008, at 4:11 PM, David McGlone wrote:

> Hi all,
>
> I've been brushing up on my PHP and MySQL and I'm trying to create  
> something.
> :-)
>
> That something is, a database full of text with each ID of the  
> database
> appearing on certain pages. I have accomplished this, but I am  
> having problems
> restricting what appears on each page.  for instance: I have a table  
> named
> site_text and in that table I have 3 fields ID sub_heading and
> sub_heading_text. Let's say I just want the first 2 sub_heading's and
> sub_heading_text id's 1 and 2 to appear on the index page and  
> sub_heading and
> sub_heading_text id 3 to appear on a different page. How could I  
> accomplish
> this? currently what I have come up with is showing all 3 id's on  
> the index
> page.
>
> Here's the query I'm using:
>
> $query = "SELECT * FROM all_text";
> $result = @mysql_query($query);
>
> while ($row = @mysql_fetch_array($result))
> {
>    echo "<h1><span> $row[sub_heading]</span></h1>";
>
>    echo "$row[sub_heading_text]";
>  }
>
> This is displaying as I expected, but it is adding the 3rd row that  
> I do not
> want.
>
> I changed the while loop to an if statement, but got no results. I was
> probably doing it wrong. Also if I take out the while loop, then all  
> the ID's
> that I want to appear on 1 page will not display past the first ID.
>
> Any Ideas?
>
>
> Thanks,
> -- 
> David M.
> http://www.dmcentral.net
>
> _______________________________________________
> ChristianSource FSLUG mailing list
> Christiansource at ofb.biz
> http://cs.uninetsolutions.com

---
Timothy R. Butler | "Do  not forget that  the value and interest of
Editor, OfB.biz   | life is not so much to do conspicuous things...
tbutler at ofb.biz   | as to do ordinary things with the perception of
timothybutler.us  | their enormous value."
                                       -- Pierre Teilhard de Chardin





More information about the Christiansource mailing list