Tutorials
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOtherTutorials

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old November 20th, 2003, 09:21 AM
soulskater soulskater is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 13 soulskater User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Error on Tutorial example.

I have tried your tutorial regarding fetching things from a database (http://codewalkers.com/tutorials/15/1.html) and splitting it into multiple rows after a predefined value but i get an strange behavior when i run the code, i do not get the first line in the database to show, i have checked the
php Code:
Original - php Code
  1. $num_rows
and that one returns 21 rows but the output only show the row 2-21.

This is my code:
php Code:
Original - php Code
  1.  
  2.  echo "<TABLE BORDER="0">n";
  3.  //changed this to a for loop so we can use the number of rows
  4.  for($i = 0; $i < $num_rows; $i++) {
  5.     $row = mysql_fetch_array($result);
  6.     if($i % $cols == 0) {
  7.         //if there is no remainder, we want to start a new row
  8.         echo "<TR>n";
  9.     }
  10.     echo "<TD>" . $row['id'] . "</TD>n";
  11.     if(($i % $cols) == ($cols - 1) || ($i + 1) == $num_rows) {
  12.         //if there is a remainder of 1, end the row
  13.         //or if there is nothing left in our result set, end the row
  14.         echo "</TR>n";
  15.     }
  16.  }
  17.  echo "</TABLE>n";


I have set cols to a value of 3

Have i done something in above code that generates this or is there a miss in the turorial?

Reply With Quote
  #2  
Old November 20th, 2003, 03:04 PM
Blindeddie Blindeddie is offline
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: NJ - USA
Posts: 2,152 Blindeddie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
RE: Error on Tutorial example.

the for statement has a closing php tag in it that might be the culprit as well as the if Statement...

for($i = 0; $i < $num_rows ?>; $i++) {

should look like

for($i = 0; $i < $num_rows; $i++) {

and

if(($i % $cols) == ($cols - 1) || ($i + 1) == $num_rows?>) {

should look like

if(($i % $cols) == ($cols - 1) || ($i + 1) == $num_rows) {

If that is in the actual code, fix those errors and try it again.

Reply With Quote
  #3  
Old November 21st, 2003, 12:32 PM
soulskater soulskater is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 13 soulskater User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: Error on Tutorial example.

Hmm, the code i posted here has got some code i didn“t put in when writing this topic.....?

The code below is the one i got and it looks like the one you posted blindeddie.

//changed this to a for loop so we can use the number of rows
for($i = 0; $i < $num_rows; $i++) {
$row = mysql_fetch_array($result);
if($i % $cols == 0) {
//if there is no remainder, we want to start a new row
echo "<TR>n";
}
echo "<TD>" . $row['id'] . "</TD>n";
if(($i % $cols) == ($cols - 1) || ($i + 1) == $num_rows) {
//if there is a remainder of 1, end the row
//or if there is nothing left in our result set, end the row
echo "</TR>n";
}

So what could be the problem???

Reply With Quote
  #4  
Old November 27th, 2003, 10:27 AM
soulskater soulskater is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 13 soulskater User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: Error on Tutorial example.

Does anyone have a solution on this, because i don't it's very strange.

Reply With Quote
Reply

Viewing: Codewalkers ForumsOtherTutorials > Error on Tutorial example.


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




 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

Request Your Free Technology Downloads!
 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

Request Your Free Technology Downloads!
 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

Request Your Free Technology Downloads!
 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

Request Your Free Technology Downloads!
 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

Request Your Free Technology Downloads!
 

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




© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek