PHP - Display All Records
I am trying to make automated scoresheets for a soccer league. The problem i am having is it is only displaying the first record and repeating.
Could someone please help me out with this? Thanks in advance. Code: [Select] <?php /* connection and protection */ include 'dbc.php'; // MATCH DATA $details = mysql_query("SELECT * FROM thirdsched_south WHERE id = '1'") or die(mysql_error()); // matchs data $match = mysql_fetch_array( $details ); // HOME TEAM $hometeam = mysql_query("SELECT * FROM players WHERE teamid = 'cloverda' AND approved ='1'") or die(mysql_error()); // store home data $home = mysql_fetch_array( $hometeam ); // AWAY TEAM $awayteam = mysql_query("SELECT * FROM players WHERE teamid = 'lefcb' AND approved ='1'") or die(mysql_error()); // Store AWAY DATA $away = mysql_fetch_array( $awayteam ); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <script type="text/javascript" src="public_smo_scripts.js"></script> <link href="styles.css" rel="stylesheet" type="text/css"> <style type="text/css"> <!-- .style1 { font-family: Geneva, Arial, Helvetica, sans-serif; font-size: 13px; } .style2 {font-size: 14px} .style3 {font-family: Geneva, Arial, Helvetica, sans-serif; font-size: 14px; } --> </style> </head> <body onload="window.print()"> <table width="930" border="1"> <tr> <td colspan="2" class="style1 style1"><div align="center"><img src="bccsl-gmsh-hd.jpg"/></div></td> </tr> </table> <table width="930" border="1"> <tr> <td width="455" class="style1 style1"><div align="center" class="style2">Division: Third- South</div></td> <td width="459" height="32" class="style1 style1"><div align="center" class="style2">Date: <? echo $match['date']; ?> </div></td> </tr> <tr> <td class="style1 style1"><div align="center" class="style2">Time: <? echo $match['time']; ?> </div></td> <td height="36" class="style1 style1"><div align="center" class="style2">Field: <? echo $match['field']; ?> </div></td> </tr> <tr> <td class="style1 style1"><div align="center" class="style2">Home Team: <? echo $match['hometeam']; ?> </div></td> <td class="style1 style1"><div align="center" class="style2">Away Team: <? echo $match['awayteam']; ?></div></td> </tr> </table> <table width="930" border="1" cellspacing="0" cellpadding="0"> <tr> <th width="230" class="style1 style1" scope="col"><div align="center">Name</div></th> <th width="41" class="style1 style1" scope="col">#</th> <th width="41" class="style1 style1" scope="col">G</th> <th width="41" class="style1 style1" scope="col">A</th> <th width="71" class="style1 style1" scope="col">Cards</th> <th width="47" rowspan="38" class="style1 style1" scope="col"><img src="bccsl-gmsh-MD.jpg" width="47" height="657" /></th> <th width="227" class="style1 style1" scope="col"><div align="center">Name</div></th> <th width="46" class="style1 style1" scope="col">#</th> <th width="46" class="style1 style1" scope="col">G</th> <th width="43" class="style1 style1" scope="col">A</th> <th width="73" class="style1 style1" scope="col">C</th> </tr> <tr> <td class="style1 style1"><div align="center"><? echo $home['first']; ?> <? echo $home['last'];?></div></td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"><div align="center"><? echo $away['first'];?> <? echo $away['last'];?></div></td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> </tr> <tr> <td class="style1 style1"><div align="center"><? echo $home['first']; ?> <? echo $home['last'];?></div></td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"><div align="center"><? echo $away['first'];?> <? echo $away['last'];?></div></td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> </tr> <tr> <td class="style1 style1"><div align="center"><? echo $home['first']; ?> <? echo $home['last'];?></div></td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"><div align="center"><? echo $away['first'];?> <? echo $away['last'];?></div></td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> </tr> <tr> <td class="style1 style1"><div align="center"><? echo $home['first']; ?> <? echo $home['last'];?></div></td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"><div align="center"><? echo $away['first'];?> <? echo $away['last'];?></div></td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> </tr> <tr> <td class="style1 style1"><div align="center"><? echo $home['first']; ?> <? echo $home['last'];?></div></td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"><div align="center"><? echo $away['first'];?> <? echo $away['last'];?></div></td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> </tr> <tr> <td class="style1 style1"><div align="center"><? echo $home['first']; ?> <? echo $home['last'];?></div></td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"><div align="center"><? echo $away['first'];?> <? echo $away['last'];?></div></td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> </tr> <tr> <td class="style1 style1"><div align="center"><? echo $home['first']; ?> <? echo $home['last'];?></div></td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"><div align="center"><? echo $away['first'];?> <? echo $away['last'];?></div></td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> </tr> <tr> <td class="style1 style1"><div align="center"><? echo $home['first']; ?> <? echo $home['last'];?></div></td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"><div align="center"><? echo $away['first'];?> <? echo $away['last'];?></div></td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> </tr> <tr> <td class="style1 style1"><div align="center"><? echo $home['first']; ?> <? echo $home['last'];?></div></td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"><div align="center"><? echo $away['first'];?> <? echo $away['last'];?></div></td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> </tr> <tr> <td class="style1 style1"><div align="center"><? echo $home['first']; ?> <? echo $home['last'];?></div></td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"><div align="center"><? echo $away['first'];?> <? echo $away['last'];?></div></td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> </tr> <tr> <td class="style1 style1"><div align="center"><? echo $home['first']; ?> <? echo $home['last'];?></div></td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"><div align="center"><? echo $away['first'];?> <? echo $away['last'];?></div></td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> </tr> <tr> <td class="style1 style1"><div align="center"><? echo $home['first']; ?> <? echo $home['last'];?></div></td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"><div align="center"><? echo $away['first'];?> <? echo $away['last'];?></div></td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> </tr> <tr> <td class="style1 style1"><div align="center"><? echo $home['first']; ?> <? echo $home['last'];?></div></td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"><div align="center"><? echo $away['first'];?> <? echo $away['last'];?></div></td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> </tr> <tr> <td class="style1 style1"><div align="center"><? echo $home['first']; ?> <? echo $home['last'];?></div></td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"><div align="center"><? echo $away['first'];?> <? echo $away['last'];?></div></td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> </tr> <tr> <td class="style1 style1"><div align="center"><? echo $home['first']; ?> <? echo $home['last'];?></div></td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"><div align="center"><? echo $away['first'];?> <? echo $away['last'];?></div></td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> </tr> <tr> <td class="style1 style1"><div align="center"><? echo $home['first'];?> <? echo $home['last'];?></div></td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"><div align="center"><? echo $away['first'];?> <? echo $away['last'];?></div></td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> </tr> <tr> <td class="style1 style1"><div align="center"><? echo $home['first']; ?> <? echo $home['last'];?></div></td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"><div align="center"><? echo $away['first'];?> <? echo $away['last'];?></div></td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> </tr> <tr> <td class="style1 style1"><div align="center"><? echo $home['first']; ?> <? echo $home['last'];?></div></td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"><div align="center"><? echo $away['first'];?> <? echo $away['last'];?></div></td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> </tr> <tr> <td class="style1 style1"><div align="center"><? echo $home['first']; ?> <? echo $home['last'];?></div></td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"><div align="center"><? echo $away['first'];?> <? echo $away['last'];?></div></td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> </tr> <tr> <td class="style1 style1"><div align="center"><? echo $home['first']; ?> <? echo $home['last'];?></div></td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"><div align="center"><? echo $away['first'];?> <? echo $away['last'];?></div></td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> </tr> <tr> <td class="style1 style1"><div align="center"><? echo $home['first']; ?> <? echo $home['last'];?></div></td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"><div align="center"><? echo $away['first'];?> <? echo $away['last'];?></div></td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> </tr> <tr> <td class="style1 style1"><div align="center"><? echo $home['first']; ?> <? echo $home['last'];?></div></td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"><div align="center"><? echo $away['first'];?> <? echo $away['last'];?></div></td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> </tr> <tr> <td class="style1 style1"><div align="center"><? echo $home['first']; ?> <? echo $home['last'];?></div></td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"><div align="center"><? echo $away['first'];?> <? echo $away['last'];?></div></td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> </tr> <tr> <td class="style1 style1"><div align="center"><? echo $home['first']; ?> <? echo $home['last'];?></div></td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"><div align="center"><? echo $away['first'];?> <? echo $away['last'];?></div></td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> </tr> <tr> <td class="style1 style1"><div align="center"><? echo $home['first']; ?> <? echo $home['last'];?></div></td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"><div align="center"><? echo $away['first'];?> <? echo $away['last'];?></div></td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> </tr> <tr> <td class="style1 style1"><div align="center"><? echo $home['first']; ?> <? echo $home['last'];?></div></td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"><div align="center"><? echo $away['first'];?> <? echo $away['last'];?></div></td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> </tr> <tr> <td class="style1 style1"><div align="center"><? echo $home['first']; ?> <? echo $home['last'];?></div></td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"><div align="center"><? echo $away['first'];?> <? echo $away['last'];?></div></td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> </tr> <tr> <td class="style1 style1"><div align="center"><? echo $home['first']; ?> <? echo $home['last'];?></div></td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"><div align="center"><? echo $away['first'];?> <? echo $away['last'];?></div></td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> </tr> <tr> <td class="style1 style1"><div align="center"><? echo $home['first']; ?> <? echo $home['last'];?></div></td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"><div align="center"><? echo $away['first'];?> <? echo $away['last'];?></div></td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> </tr> <tr> <td class="style1 style1"><div align="center"><? echo $home['first']; ?> <? echo $home['last'];?></div></td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"><div align="center"><? echo $away['first'];?> <? echo $away['last'];?></div></td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> </tr> <tr> <td bgcolor="#666666" class="style1 style1"><div align="center"></div></td> <td bgcolor="#666666" class="style1 style1"> </td> <td bgcolor="#666666" class="style1 style1"> </td> <td bgcolor="#666666" class="style1 style1"> </td> <td bgcolor="#666666" class="style1 style1"> </td> <td bgcolor="#666666" class="style1 style1"><div align="center"></div></td> <td bgcolor="#666666" class="style1 style1"> </td> <td bgcolor="#666666" class="style1 style1"> </td> <td bgcolor="#666666" class="style1 style1"> </td> <td bgcolor="#666666" class="style1 style1"> </td> </tr> <tr> <td height="43" class="style1 style1"><div align="center" class="style2">TOTALS</div></td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"><div align="center" class="style2">TOTALS</div></td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> <td class="style1 style1"> </td> </tr> </table> <table width="930" border="1"> <tr> <td width="447" class="style3">MANAGERS<br /> SIGNATU _______________________________</td> <td width="467" class="style1"><p class="style2">MANAGERS<br /> SIGNATU ________________________________</p></td> </tr> <tr> <td height="48" class="style1"><p class="style2">REFEREE<br /> SIGNATU _______________________________</p> </td> <td class="style1 style2">REFFEREE<br /> COMMENTS:</td> </tr> <tr> <td colspan="3" class="style1 style1"><div align="center" class="style2">Game Report is due within 24hrs. Email Report to scores@bccsl.org or fax to 604-677-5846</div></td> </tr> </table> </body> </html> Similar TutorialsI am having trouble showing reports for a given date range. Currently if I specify something like 11/03/2010 to 11/05/2010 I get results for all years within that month and day such as I may get results for 11/03/2008 11/03/2009 11/03/2010 11/04/2008 11/04/2009 11/04/2010 11/05/2008 11/05/2009 11/05/2010. I am using the following code $result = mysql_query("SELECT * FROM report WHERE date>='$date_begin' and date<='$date_end' ORDER BY 'date'",$db); I use the following format in my date feild mm/dd/yyyy My script is finally working as intended, but I want to add some additional data results. I am trying to resolve how I can display a count of ONLY the records updated by my query: // START :: Query to replace matches mysql_query("UPDATE orig_codes_1a AS a JOIN old_and_new_codes_1a AS b ON concat(a.orig_code_1, a.orig_code_2) = concat(b.old_code_1, b.old_code_2) SET a.orig_code_1 = b.new_code_1, a.orig_code_2 = b.new_code_2") or die(mysql_error()); // END :: Query to replace matches In this query I count ALL records selection: // START :: Create query to be displayed as final results of original codes table. $result = mysql_query("SELECT * FROM orig_codes_1a") or die(mysql_error()); I want to display a count on this part of the query: ....concat(a.orig_code_1, a.orig_code_2) = concat(b.old_code_1, b.old_code_2).... enter code hereI am New to PHP but i did pull off (with help of a friend) this piece of code. i am stuck at the part to display Image (it is Blank) and move through records (nothing happens). This is the whole PHP code. Any positive response will be highly appreciated. Thanx in advance. Hello Everyone, I wanted to know how to Display records from a Table one by one at difference time intervals. Kindly suggest Hello: I am trying to select all the records from a table, and display them. Having an issue... This is the code: Code: [Select] <ul> <?php $query = mysql_query("SELECT id,mySectionTitle FROM myWebSiteData"); while($menuData = mysql_fetch_array($query)) { <li><a href="a_websiteData.php?id=" .echo $menuData['id'] ."">echo $menuData['mySectionTitle']</a></li> } ?> </ul> This is the error: Code: [Select] Parse error: syntax error, unexpected '<' in /html/admin/a_websiteData.php on line 91 line 91 is the one that starts with "<li>" What am I missing, or what would be the best way to do this? I have several forms which will request the user to select one of several options where the most common choices will be pronounced, and might look something like: Select Option A Select Option B Select Option C Select Option D Click here for more choicesThe client is responsible to determine which ones to display (opposed to hiding within "more choices") and the server is responsible to provide the list of options along with some means to determine which ones are most common. For a new user, the order will be based on my "best guess", however, whenever a user selects a given option its ranking for that user only should go up, and in addition more recent activities should have more bearing on the returned order. In addition, there will be more than one of these lists and each of these lists will expose a public identifier (most will use a string but some might use an incrementing integer series) instead of the primary key. I have some fragmented ideas how to best implement but would like other people's thoughts on how to best do so. Starting with the list schema, undecided on which approach below. Any preferences or something else altogether? Solution 1: abstract_list - id (INT PK) - discriminator (string) - name (string unique with discriminator) - ranking (TBD whether float or integer. This represents my initial "best guess") list1 (list2, etc) - id (FK to abstract_list.id) - discriminator (FK to abstract_list.discriminator) - public_id (string or integer based on specific list. unique with discriminator) Solution 2: abstract_list - id (INT PK) - discriminator (string) - name (string unique with discriminator) - ranking (TBD whether float or integer. This represents my initial "best guess") - public_id (Application responsible to cast as string or integer. unique with discriminator) list1 (list2, etc. This class has no properties and only a method to cast the public ID as required. Seems like a waste...) - id (FK to abstract_list.id)
user_list_ranking - abstract_list_id - user_id - ranking (TBD) To retrieve the list options, will query abstract_list and LEFT JOIN user_list_ranking and then sort on some mathematical formula acting on abstract_list.ranking and COALESCE(user_list_ranking.ranking, 0). To promote recent activity, maybe increment user_list_ranking.ranking every time the user selects a given option and also decrement all other options of the associated list. To prevent excessive windup, cap the the value to some max value (i.e. If list1 has a total of 10 records, cap it three times that value resulting in 30), and cap the minimum at zero. Uncharted territory here and am very open to other approaches. I am undecided whether I should just return an ordered array of the options, or also include either an order integer or some normalized value from 0 to 1. If there is a common way to do this, please let me know what it is so I may mimic it. If not, please provide any critique or recommended changes to my intended approach. Thanks Hello, I am trying to display rainfall totals for the year so far in a table with months going across and days going down. Like so: -- Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec 1 2 3 4 5 6 7 8 etc And then have the rainfall totals for each day in the table, I am quite experienced with PHP however I cant work out how I would do this The data is stored in a mysql table called "wx_daily", and the rainfall column is called" RainTotal". The dates are stored in the "Date" column in mysql Date format. Im using the following mysql query: SELECT * FROM wx_daily WHERE YEAR(Date) = '2011' ORDER BY Date Asc Thanks, Mark I am have a query with a limit of 3 i want it to echo the first two in one li class and the 3 in another li class. This is what i have, but i know the logic is not right, but i cant figure it out Code: [Select] </div> <?php echo "<ul class='services-list'>"; //echo "<li class='bubble'>"; $i = 1; foreach ($rows_class as $record_class ){ ?> <li class="bubble"><a href="viewclass.php?class_id=<?php echo base64_encode($record_class[class_id]) ?>" /><h6 class="title"><img src="./images/services/picture-services.png" class="picture" alt="logo" /><? echo $record_class[class_title]; ?></h6></a><p><?php $string = $record_class['description']; echo substr(strip_tags($string), 0, 200); ?></p> <?php if( $i % 2 === 0 && $record_class !== end($rows_class) ) { echo "</li>\n<li class='bubble last'>\n";?> <?php } elseif ( $record_class === end($rows_class) ) { echo "</li>\n "; } $i++; } ?> </ul> Hi, I was thinking of creating a table for this current code and place only 3 options in a row, however I do not know how to execute a command which will allow me to do so, I have attached 2 pictures to describe what I will like to achieve. Below is my code as well. Any advice? Thanks $query = ("SELECT * FROM tutor_preferred_district ORDER BY district_id ASC"); $sql = mysqli_query($dbc, $query) or die(mysql_error()); while($data = mysqli_fetch_array($sql)) { echo'<table>'; echo '<input name="district" type="checkbox" id="'.$data['district_id'].'" value="'.$data['district_id'].'">'; echo '<label for="'.$data['district_id'].'">'.$data['district_name'].'</label>'; echo'<table>'; } Hi, can someone help me understand why it 's only printing the first record in the database ? Code: [Select] <?php require_once("functions.php"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <?php DatabaseConnection(); mysql_select_db("auntievics"); $query= "SELECT product_id FROM treats"; $result_set= mysql_query($query); if ($result_set){ $products= mysql_fetch_row($result_set); foreach ($products as $value){ print $value; } print "<br />"; } //print_r(mysql_fetch_row($result_set)); ?> </body> </html> I am really not sure if this is a problem with me (probably is), php or mysql. I have a calendar that I am adding events to. If I want to edit only the date I can but only once after I make this update I am out. If I attempt to update the time or event title the database is never updated and I am no longer able to update the date. here is the controller for the save. Code: [Select] <?php function eventsave() { $details = $_POST; $this->load->model('eventsmodel'); $this->eventsmodel->eventsave($details,'', TRUE); redirect('/admin/events', 'location'); } ?> I have turned off the redirect to see if I was getting any errors and they seem to be non existent. Here is the model that is used to create a new entry and update a record. Code: [Select] <?php function eventsave($event) { $startdate = explode('-', $event['startdate']); $start = mktime($event['starthour'], $event['startmin'], 0, $startdate['0'], $startdate['1'], $startdate['2']); $end = mktime($event['endhour'], $event['endmin'], 0, $startdate['0'], $startdate['1'], $startdate['2']); $name = $event['name']; if (isset($event['id'])) { // if is true then this is an update not a new event $data = array( 'name' => $name, 'start' => $start, 'end' => $end ); $this->db->where('id', $id); $this->db->update('events', $data); }else{ $this->db->set('name', $name); $this->db->set('start', $start); $this->db->set('end', $end); $this->db->insert('events'); } } ?> I am using code igniter if that helps and the information being submitted by the form looks good. This is the submitted update array and the new event array is just missing the "id" Code: [Select] Array ( [name] => test [startdate] => 05-14-2011 [starthour] => 1 [startmin] => 0 [endhour] => 1 [endmin] => 0 [id] => 54 [saveevent] => save ) Any suggestions would be appreciated. Thank you. I've got query. Hi there im trying to add up the number of different values i have in a table and echo the results: Ships ------ ShipID INT: auto count ShipName VARCHAR: Something Class INT: (either 1 to 4) The class row is the one i want to count, so if i have say 5 ships; first class 1, second class 2, third class 3, fourth class 4 and fith another class 1. It would total how many of each classes i have: two class 1, one class 2, one class 3 and one class 4. Ultimately i am going to do a similar count on another table and compare the results, but thats for later as im really not sure where to start. Ive created a query selecting all the appropriate ships to be tallied up: Code: [Select] } mysql_select_db($database_swb, $swb); $query_Ships = sprintf("SELECT * FROM ships WHERE PlayerName = %s", GetSQLValueString($colname_Ships, "text")); $Ships = mysql_query($query_Ships, $swb) or die(mysql_error()); $row_Ships = mysql_fetch_assoc($Ships); $totalRows_Ships = mysql_num_rows($Ships); If you could please help me that would be ace! Thank You Hi there i have 4 fields in a record and 3 records in a table that i need to add up. Heres what they look like when outputted: 0024 0103 1126 Each of the fields that need to be added are called: Class1, Class2, Class3, Class4 So i want to add each number in those fields with the result of the records so above would look like: 1, 2, 4, 13 Would i need to put them in an array of somekind?? Code: [Select] $colname_resultp = "-1"; if (isset($_SESSION['MM_Username'])) { $colname_resultp = (get_magic_quotes_gpc()) ? $_SESSION['MM_Username'] : addslashes($_SESSION['MM_Username']); } mysql_select_db($database_swb, $swb); $query_resultp = sprintf("SELECT Class1, Class2, Class3, Class4 FROM planet WHERE PlayerName = %s", GetSQLValueString($colname_resultp, "text")); $resultp = mysql_query($query_resultp, $swb) or die(mysql_error()); $row_resultp = mysql_fetch_assoc($resultp); $totalRows_resultp = mysql_num_rows($resultp); <?php do { ?> <?php echo $row_resultp['Class1']; echo $row_resultp['Class2']; echo $row_resultp['Class3']; echo $row_resultp['Class4']; ?> <?php } while ($row_resultp = mysql_fetch_assoc($resultp)); mysql_free_result($resultp); ?> If you could please, please help that would be great as im finding this a real headache at the moment :( Thank you Tom Is there a php method/function that can count how many records in a table have the same id. For example you have two tables relating to one another there for there is reason for a coloum to have the same id as another. Hello there, I have made a ban form on my website. It is all going good until I open phpmyadmin. There is two records from one submission. Usually the second record has some missing information. There should not be a duplicate and I do not understand why it is happening. If anybody could explain what is causing this would be great. Here is the page. <?php session_start(); require_once 'database.php'; if(isset($_SESSION['mod'])) { $userid = $_SESSION['user']; if(isset($_GET['action']) && strcasecmp($_GET['action'], "file") == 0) // checks to see if form is submitted { $username = $_POST['user']; $time = $_POST['time']; $reason = $_POST['reason']; $u_time = date("U"); $r_time = date("m-j-Y g:i A"); if($time == "00") { // if the time is a permaban $sql=mysql_query("SELECT * FROM user WHERE username='$username'") or die("Error 1"); $data=mysql_query($sql); $user_ip = $data['last_ip']; if ($user_ip != 127.0.01) { // admin stuff ;) $p_ban=mysql_query("INSERT INTO ip_ban (ip,real_time,unix_time,days_left,reason) VALUES ('$user_ip','$r_time','$u_time','99999999999','$reason')") or die("Error 2"); echo 'The user '.$username.' has been banned.'; }else{ // if it is an admin echo 'You cannot ban that user.'; } }else{ // not a perma ban if($username != "admin") // admin stuff { $temp_ban=mysql_query("INSERT INTO blacklist (email,reason,end_date,appeal,unixtime) VALUES ('$username','$reason','$time','No','$u_time')") or die("Error 3"); echo 'The user '.$username.' has been banned.'; }else{ echo 'You cannot ban that user.'; } } }else{ $user_ban = $_GET['user']; if(isset($user_ban)) { ?> <form name="file_ban" method="post" action="?action=file"> Username: <input type="text" name="user" value="<?php echo $user_ban; ?>"><br /> Length of Ban: <select name="time"> <option value="1">1 Day</option> <option value="3">3 Days</option> <option value="5">5 Day</option> <option value="7">1 Week</option> <option value="15">15 Days</option> <option value="30">1 Month</option> <option value="90">3 Months</option> <option value="99999999999">∞ Infinity (Permaban)</option> <option value="00">IP Ban (Does not expire)</option> </select><br /> Reason: <br /> <textarea name="reason" cols="50" row="4"></textarea><br /> <input type="submit" value="Ban"> <?php }else{ } } }else{ // If session is not set header("Location: index.php"); } ?> If you need any explanation of what anything does, just please ask. Thank you! I have a DB with 10 fields Records are entered under a date There can be 1 to 30 records for a given date I need to copy all records of a given date with the 10 fields of each... Into the same DB only changing the original date to a new date Sounds easy, but so far I haven't been able to make it work. Any nudge in the right directiion would be much appreciated. Howdy, The following code wil geenrate a dynamic pull-down list based on column values. Can someone help me tweak it so that is will NOT display a duplicate record value. That is, if the sponsors values in the table were Hart, Michaels, Michaels, Morella ...it would only display Hart, Michaels, Morella in the pull-down menu. <form name="form0"> <? $result = @mysql_query("select distinct sponsor from table ORDER BY sponsor ASC"); if (mysql_num_rows($result) > 0) { print "<select name=\"link\">"; ?> <option <?php if(empty($_GET['sponsor'])){ echo "selected=\"selected\""; } ?> value="<? echo "$page_name" ?>">SELECT A SPONSOR</option> <? while ($row = mysql_fetch_array($result)) { print "<option "; if($_GET['sponsor'] == $row['sponsor'] ){ echo "selected=\"selected\""; } print " value=\"index?sponsor=" . $row['sponsor'] . "\">" . $row['sponsor'] . "</option>\n"; } print "</select>"; } ?> </form> Thank you. ~Wayne |