Birdmansplace Posted December 23, 2009 Share Posted December 23, 2009 For some reason i cant figure out why its not getting info from mysql table. <br /> <div align="center"> <table style="width 87%" border="1" cellspacing="2" cellpadding="2"> <tr> <th><font face="Arial, Helvetica, sans-serif">• Entrys •</th> <th><font face="Arial, Helvetica, sans-serif">• User Name •</th> <th><font face="Arial, Helvetica, sans-serif">• Amount •</th> <th><font face="Arial, Helvetica, sans-serif">• Date •</th> <th><font face="Arial, Helvetica, sans-serif">• Trans Type •</th> <th><font face="Arial, Helvetica, sans-serif">• Trans Type •</th> <th><font face="Arial, Helvetica, sans-serif">• Trans Type •</th> <th><font face="Arial, Helvetica, sans-serif">• Trans Type •</th> </tr> <? ini_set("display_errors", "1"); error_reporting(E_ALL); include("dbinfo.php"); mysql_connect('localhost',$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM schedule"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); $i=0; while ($i < $num) { $day1=mysql_result($result,$i,'day1'); $day2=mysql_result($result,$i,'day2'); $day3=mysql_result($result,$i,'day3'); $day4=mysql_result($result,$i,'day4'); $day5=mysql_result($result,$i,'day5'); $day6=mysql_result($result,$i,'day6'); $day7=mysql_result($result,$i,'day7'); $day8=mysql_result($result,$i,'day8'); ?> <tr> <td><font face="Arial, Helvetica, sans-serif"><? echo $day1; ?></td> <td><font face="Arial, Helvetica, sans-serif"><? echo $day2; ?></td> <td><font face="Arial, Helvetica, sans-serif"><? echo $day3; ?></td> <td><font face="Arial, Helvetica, sans-serif"><? echo $day4; ?></td> <td><font face="Arial, Helvetica, sans-serif"><? echo $day5; ?></td> <td><font face="Arial, Helvetica, sans-serif"><? echo $day6; ?></td> <td><font face="Arial, Helvetica, sans-serif"><? echo $day7; ?></td> <td><font face="Arial, Helvetica, sans-serif"><? echo $day8; ?></td> </tr> <? $i++;} echo "</table>"; ?> </div> nothing from database loads on page. What did i do wrong? Using old code from another project and it works using the old fields, db, and table. just coped and pasted in to a new file and changed to fit new database and table. Quote Link to comment Share on other sites More sharing options...
ChemicalBliss Posted December 23, 2009 Share Posted December 23, 2009 Debug your code; 1. add "or die()" function: mysql_query("...") or die(mysql_error()); 2. Echo Specific Variables to check their values. // Before the loop echo($num); // Inside the loop echo($i); 3. Try the query using phpmyadmin. You may find that there is a typo (Case-sensitive, o doesnt equal O). -CB- Quote Link to comment Share on other sites More sharing options...
Birdmansplace Posted December 23, 2009 Author Share Posted December 23, 2009 Thanks for the help, Turns out helps to have data in the database to display. Well then for users that need the code there you go. Quote Link to comment Share on other sites More sharing options...
Buddski Posted December 23, 2009 Share Posted December 23, 2009 You have misspelled mysql_num_rows also Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.