Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,472
There are 1872 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     PHP and MySQL :

While Loops...

Thread title: While Loops...
Closed Thread  
Page 1 of 2 1 2 >
    Thread tools Search this thread Display Modes  
07-11-2008, 07:01 AM
#1
Jako is offline Jako
Jako's Avatar
Status: Jakowenko.com
Join date: Jun 2005
Location: Michigan
Expertise:
Software:
 
Posts: 2,199
iTrader: 3 / 100%
 

Jako is on a distinguished road

  Old  While Loops...

I'm having trouble w/ something...

I have a while loop
PHP Code:
<? while($row mysql_fetch_assoc($result)) {
require(
'age-calc.php');
?>
that I'm using to create a table.

I have this in the middle of the page. But I want to have info pulled from the table above and below this while loop, and not that that information repeat, like the while loop does.

Kind of understand?

This is my query code
PHP Code:
<? 
$sql 
"SELECT * FROM players,national WHERE players.national='$id' AND national.national='$id'";
$result mysql_query($sql) or die(mysql_error());
?>

07-11-2008, 07:28 PM
#2
Jako is offline Jako
Jako's Avatar
Status: Jakowenko.com
Join date: Jun 2005
Location: Michigan
Expertise:
Software:
 
Posts: 2,199
iTrader: 3 / 100%
 

Jako is on a distinguished road

  Old

Can anybody help me?

07-11-2008, 10:57 PM
#3
Phelms215 is offline Phelms215
Status: Junior Member
Join date: Nov 2006
Location:
Expertise:
Software:
 
Posts: 89
iTrader: 6 / 100%
 

Phelms215 is on a distinguished road

Send a message via AIM to Phelms215 Send a message via MSN to Phelms215

  Old

I don't understand what your doing the while loop for... can you post what is in the 'age-calc.php' page to help me see the mysql query your running...


and does this

PHP Code:
<? 
$sql 
"SELECT * FROM players,national WHERE players.national='$id' AND national.national='$id'";
$result mysql_query($sql) or die(mysql_error());
?>
rely on the information in the age-calc.php ?

07-12-2008, 04:40 AM
#4
Jako is offline Jako
Jako's Avatar
Status: Jakowenko.com
Join date: Jun 2005
Location: Michigan
Expertise:
Software:
 
Posts: 2,199
iTrader: 3 / 100%
 

Jako is on a distinguished road

  Old

dont even pay attention to the age-calc.php i don't really need it.

I want to run a loop in the middle of a page pulling all of the info from the specified database. So I was running the while loop which did this fine.

I also wanted to have PHP info above and below the loop, but this info only is being pulled from a single row in the db, so I don't want it to loop.

07-12-2008, 07:33 AM
#5
creativejen is offline creativejen
Status: Paladin
Join date: Jul 2006
Location: Sheffield, UK
Expertise: design, front-end markup
Software: Photoshop
 
Posts: 2,353
iTrader: 25 / 96%
 

creativejen is an unknown quantity at this point

Send a message via MSN to creativejen

  Old

You forgot to end the while.

07-16-2008, 07:38 AM
#6
Zeggy is offline Zeggy
Status: Junior Member
Join date: Jul 2008
Location:
Expertise:
Software:
 
Posts: 54
iTrader: 4 / 100%
 

Zeggy is on a distinguished road

  Old

Then you just use a separate query which will only get information from one row...

07-16-2008, 02:28 PM
#7
ditch182 is offline ditch182
Status: Junior Member
Join date: Jul 2008
Location: NC
Expertise:
Software:
 
Posts: 70
iTrader: 0 / 0%
 

ditch182 is on a distinguished road

  Old

I don't really understand why you even need the while loop, if you don't rely on age-calc.php for anything. It looks like you could just use a query to pull information from one row. You may need to post more of the surrounding code, so that we can understand what you're trying to achieve.

07-30-2008, 03:10 PM
#8
infinivert is offline infinivert
infinivert's Avatar
Status: Junior Member
Join date: Jul 2008
Location: Abilene TX
Expertise: Design, PHP, JS, HTML5, CSS3
Software:
 
Posts: 37
iTrader: 0 / 0%
 

infinivert is on a distinguished road

Send a message via AIM to infinivert

  Old

Originally Posted by enigma View Post
You forgot to end the while.
Yes, your while loop needs a } on the end.

Beyond that, I don't really understand what you're getting at. Maybe a little more detail?

07-30-2008, 04:02 PM
#9
ThinkMinds is offline ThinkMinds
ThinkMinds's Avatar
Status: I'm new around here
Join date: Jul 2008
Location: Toronto, Canada
Expertise:
Software:
 
Posts: 19
iTrader: 0 / 0%
 

ThinkMinds is on a distinguished road

  Old

Hi Jako,

like Zeggy mentioned above, use two separate queries one after the other - unless the info from one query is used as input for the other query in which case you can do:

-- START --

// Define 1st query here - you can use 'limit 1' in your sql to force it to be only one row if you wish

$query1 = [ queries info from one row only ]

// The 'while' loop below will execute only once

while [ fetching info based on query1 ] {
[ get the data from query1 ]
// Define 2nd query here
$query2 = [ query to loop, populated with data from query1 ]
while [ fetching info based on query2 ] {
[get the data from query2 ]
}
}

-- END --

Hope this helps somewhat - PM me with more details if you need some more help (and I wish the indent would work )

Cheers,

Mike

08-12-2008, 12:19 PM
#10
alisha is offline alisha
Status: Junior Member
Join date: Jun 2008
Location: India
Expertise:
Software:
 
Posts: 43
iTrader: 0 / 0%
 

alisha is on a distinguished road

  Old

please be more specific,i am not getting what exactly u r saying?

Closed Thread  
Page 1 of 2 1 2 >


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed