PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old August 4th, 2004, 09:06 PM
eddynazrul eddynazrul is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Location: 192.168.1.4
Posts: 21 eddynazrul User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Exclamation looping problem

can anybody help me?? i got problem with my looping codes.. please help me..!! i want to show table that represent prize of my contest.

for($thisprize=1; $thisprize<=$RANK; $thisprize++) // $thisprize represents the ranking.
{
$trial = "SELECT ContestID, Prize FROM Prizes WHERE ContestID=$c_id and Rank=$thisprize";
$query_trial = mysql_query($trial);
while($data = mysql_fetch_array($query_trial))
{
$hadiahku = $data["Prize"];
}
echo " <tr>\n";
echo " <td width=\"10%\" align=\"center\" nowrap>$thisprize</td>\n";
if(!empty($hadiahku))
{
echo " <td width=\"30%\" align=\"center\" nowrap>$hadiahku</td>\n";
echo " <td width=\"30%\" align=\"center\"><a href=\"editthisprize.php?c_id=$c_id&RANK=$thisprize\">Edit</a>&nbsp&nbsp";
echo "<a href=\"deletethisprize.php?c_id=$c_id&RANK=$thisprize\" name=\"delete\">Delete</a></td>\n";
}
else
{
echo " <td width=\"30%\" align=\"center\">&nbsp</td>\n";
echo " <td width=\"30%\" align=\"center\"><a href=\"fillPrize.php?contestid=$c_id&rank=$thisprize\">Add</a></td>\n";
}
}

Reply With Quote
  #2  
Old August 5th, 2004, 05:19 AM
Itsacon's Avatar
Itsacon Itsacon is offline
Command Line Warrior
Click here for more information
 
Join Date: Aug 2004
Location: Sector ZZ9 Plural Z Alpha
Posts: 956 Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)  Folding Points: 672951 Folding Title: Super Ultimate Folder - Level 2Folding Points: 672951 Folding Title: Super Ultimate Folder - Level 2Folding Points: 672951 Folding Title: Super Ultimate Folder - Level 2Folding Points: 672951 Folding Title: Super Ultimate Folder - Level 2Folding Points: 672951 Folding Title: Super Ultimate Folder - Level 2Folding Points: 672951 Folding Title: Super Ultimate Folder - Level 2Folding Points: 672951 Folding Title: Super Ultimate Folder - Level 2
Time spent in forums: 6 Days 8 h 23 m 32 sec
Reputation Power: 4
Send a message via ICQ to Itsacon
You didn't say what goes wrong, but I can point out at least one problem you may encounter.

It's in this part:
PHP Code:
 $trial "SELECT ContestID, Prize FROM Prizes WHERE ContestID=$c_id and Rank=$thisprize";
$query_trial mysql_query($trial);
while(
$data mysql_fetch_array($query_trial))
{
     
$hadiahku $data["Prize"];


this way, if the MySQL query returns more than one result, you'll only display the last one, as the while loop won't terminate till the query-result is empty.

You con fix this by moving the closing bracket of the while loop to the end of your code, just before the closing bracket of the for loop.
That way, every entry will get it's own row in the table.

Reply With Quote
  #3  
Old August 6th, 2004, 02:07 AM
eddynazrul eddynazrul is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Location: 192.168.1.4
Posts: 21 eddynazrul User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question

sorry,because i didn't point my problem.the situation is i had create one table 'Contest' hold the detail of contest.
It's hold ranking available but it's just int.Like a dummy data. So i,create another table 'Prizes' that hold detail of prize of each rank.
So in my page it's auto generate one table so I can enter prize detail for each rank. The rank which are generated in my page, i get from the Contest table. So i create the looping codes like above. That page i put some function to edit or delete.
But it's go wrong when I delete the prize detail for certain rank. The prize which i delete...eg: I delete prize of rank 3.. then in the row of rank 3, it carried the prize detail of rank 2. I check it in my database..There is no problem..

can u please help me... Itsacon or whoever know how to solve my problem..

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > looping problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Iron Speed




© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway