PHP - Select All Records And Display Error
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? 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).... Hi, I have db field with date. I want to make select statement with where clause when part of the date (month) is true. Example, i have records from 2020-2-1 until 2020-4-3, i want to select records for march only 2020-3-1 to 2020-3-31. how to do that? This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=356136.0 Hi, I have a DB with two tables, customers and orders. One customer may have many orders, What I want to do is do a select on the two tables and get the customer info once, and then all the orders associated with the account. I saw how to do this once before using a join and then having to use a PHP foreach to break it up. I am just not sure of how to put the two together to make it work, or maybe there is an easier way completely. Any help is appreciated. Thanks B Example: Bob Smith Shoes Coat Boots Gloves Sally Jones Hat Purse Boots Umbrella 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> Hello, Please excuse me if this sounds like a bit of a newb question. If I have a link to a users profile and use GET to pull information about that user from various tables using something like this: Code: [Select] <?php { $id = $_GET['id']; $user = mysql_query("SELECT * FROM users,tbl1,tbl2,tbl3,tbl4,tbl5 WHERE $id=tbl1.user_id AND tbl1.user_id=tbl2.user_id AND tbl2.user_id=tbl3.user_id ANDtbl3.user_id=tbl4.user_id AND tbl4.user_id=tbl5.user_id"); $user=mysql_fetch_assoc($user); } ?> <h3>Table 1</H3> <?php echo "<b>".$user['tbl1_title']."<br>"; ?><br /> <h3>Table 2</H3> <?php echo "<b>".$user['tbl2_title']."<br>"; ?><br /> <h3>Table 3</H3> <?php echo "<b>".$user['tbl3_title']."<br>"; ?><br /> <h3>Table 4</H3> <?php echo "<b>".$user['tbl4_title']."<br>"; ?><br /> <h3>Table 5</H3> <?php echo "<b>".$user['tbl5_title']."<br>"; ?><br /> Why does it only show the 1st record for that user from each table? And mostly, how do I change it to show all or a certain number of records from each table? Any help would be greatly appreciated. Thanks in advance This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=308916.0 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 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 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 Hi all, I am a php student and i am doing a project in php. I am doing the project of online attendance register. I am stuck with the part of reports. We need to select three different values from an HTML form and pick the selected rows and wants to display those rows in a table. I have done a code but it is not working. Please help me out of this issue. HTML Form: <!doctype html> <html> <head> <meta charset="utf-8"> <title>Untitled Document</title> </head> <body><form action="reportpro.php" method="get" name="services"> <table width="447" border="0" align="center" > <tr style="text-align: center"> <td width="441"><table width="481" border="1"> <tr> <td width="216"><div align="center"> SECTION </div></td> <td width="102"><div align="center"> MONTH </div></td> <td width="141"><div align="center"> YEAR </div></td> </tr> <tr> <td><select name="section" id="select"> <option>SERVICES-A</option> <option>SERVICES-B</option> <option>SERVICES-C</option> </select></td> <td><select name="month" id="select"> <option>01</option> <option>02</option> <option>03</option> <option>04</option> <option>05</option> <option>06</option> <option>07</option> <option>08</option> <option>09</option> <option>10</option> <option>11</option> <option>12</option> </select></td> <td><select name="year" id="select"> <option>2014</option> <option>2015</option> <option>2016</option> <option>2017</option> <option>2018</option> <option>2019</option> <option>2020</option> </select></td> </tr> <tr> <td colspan="4"> <center><input name="submit" type="submit" id="submit" formaction="reportpro.php" formmethod="get" value="Search"></center></td> </tr> </table> <p> </p> <p> </p> <p> </p></td> </tr> </table> </form> </body> </html> PHP Code: <!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> <form action="" method="get"> <table border="1" align="center" > <tr> <td>BOOK NO</td> <td>Name</td> <td>Desigination</td> <td>Section</td> <td>Day</td> <td>Month</td> <td>Year</td> <td>Attendance</td> </tr> <?php $con=mysql_connect("localhost","root",""); mysql_select_db("niy",$con); $m=$_REQUEST['month']; $y=$_REQUEST['year']; $sec=$_REQUEST['section']; $sql="select month='$m', year='$y', sectn='$sec' from attendance "; echo $sql; $res=mysql_query($sql,$con); while($row=mysql_fetch_array($res)) { ?> <tr> <td><?php echo $row[1];?></td> <td><?php echo $row[2];?></td> <td><?php echo $row[3];?></td> <td><?php echo $row[4];?></td> <td><?php echo $row[5];?></td> <td><?php echo $m;?></td> <td><?php echo $y;?></td> <td><?php echo $row[8];?></td> </tr> <?php } ?> </table> </body> </html> Hey guys, not sure what's gone wrong here, but this displays the select query twice on my page. Code: [Select] <?php $result = mysql_query("SELECT * FROM members WHERE Username='$_SESSION[Username]'") or die(mysql_error()); while($row = mysql_fetch_array( $result )) { echo '<b>Resources</b><br />'; echo 'Wood: ' . $row['res1'] . ' <br />'; echo 'Iron: ' . $row['res2'] . ' <br />'; } ?> Displays as: Resources Wood: 2000 Iron: 1000 Resources Wood: 0 Iron: 0 The first set of numbers are correct, but I'm not sure where the second lot are been called from? Thanks in advance. Okay so, I'm adding a reply feature to my text-board, and I'm wondering how I can select a single result from the DB I've tried this $board = mysql_real_escape_string($_GET['board']); $thread = mysql_real_escape_string($_GET['thread']); $result = mysql_query("SELECT subject, name, id, timestamp, body FROM $board LIMIT $thread,$thread"); while ($row = mysql_fetch_array($result, MYSQL_NUM)) { printf("<div id='html1' style='background-color:#F0E0D6;border:solid 1px #800000;font-family:arial; font-size: 12px; padding:2px; margin:2px;'><font color='#CC1105'>%s </font><font color='#117743'>%s</font> <font color='#800000'>Post # %s - %s<br />%s<br /></div>", $row[0], $row[1], $row[2], $row[3], $row[4], $row[5], $row[6]); mysql_free_result($result); } ?> Kinda works but if I pu ?thread=56 then it would show thread 57, which in this example does not exist. Guys, you are so going to be sick of me. But I really appreciate the help I am receiving here thus far. I have the code below sending the data from the form to the database. That's excellent. However, where I am stuck is doing the following two: 1. Updating currently inserted data 2. Displaying the data on the site. Here is settings.php: <?php include "../settings.php"; include "../lang/english.php"; include "../config/config.php"; $errors = array(); // condition and map inputs $fields = array('site_name'=>'sitename','site_email'=>'email','your_name'=>'name','meta_description'=>'meta-description','meta_keywords'=>'meta-keywords'); foreach($fields as $var => $field){ $$var = isset($_GET[$field]) ? trim($_GET[$field]) : ''; } // check if the form was submitted if(isset($_GET['submit'])){ // connect to/select database mysql_connect("$db_hostname", "$db_username", "$db_password") or die(mysql_error()); mysql_select_db("$db_database") or die(mysql_error()); // basic validation (not empty) and escape data foreach($fields as $var => $field){ if(empty($$var)){ $errors[] = "The form field: $field, is empty!"; } // escape the data $$var = mysql_real_escape_string($$var); } // if no validation errors, insert the data if(empty($errors)){ $insert = sprintf("INSERT INTO settings (site_name, description, keywords, email, name) VALUES ('%s','%s','%s','%s','%s')", $site_name, $meta_description, $meta_keywords, $site_email, $your_name ); if(!mysql_query($insert)){ // a query error occurred // check if due to duplicate data if(mysql_errno() == 1062){ // 1062 = duplicate primary key error (your error number might be different depending on your table definition) $errors[] = "The site name: $site_name, already exists and cannot be inserted!"; } else { // all other query errors - $errors[] = "A database error occurred and your query cannot be processed!"; trigger_error(mysql_error()); // use error_reporting/display_errors/log_errors to display/log the error condition } } else { echo "The data was successfully inserted!"; } } } //database_connect(); $sql = "UPDATE settings SET site_name='$site_name', description='$description', keywords='$keywords', email='$site_email', name='$your_name' WHERE id='$id'"; $query = mysql_query($sql)or die("There's a problem with the query: ". mysql_error()); if($query) echo "<br>The settings have been updated.<br>"; $_SESSION['tekst']=""; ?> <!DOCTYPE html> <html> <head> <title><?php echo $site_name; ?> :: :: Powered by osPHPSite</title> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <link href="css/admin.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="main"> <div id="header"> <h1><?php echo $sitename; ?></h1> <ul id="top-navigation"> <li><a href="index.php"><?php echo $lang_button_index; ?></a></li> <li><a href="settings.php" class="active"><?php echo $lang_button_settings; ?></a></li> <li><a href="pages.php"><?php echo $lang_button_pages; ?></a></li> <li><a href="gallery.php"><?php echo $lang_button_gallery; ?></a></li> <li><a href="/"><?php echo $lang_button_viewsite; ?></a></li> <li><a href="logout.php"><?php echo $lang_button_logout; ?></a></li> </ul> </div> <div id="middle"> <div id="left-column"> <h3><?php echo $eng_navigation; ?></h3> <ul class="nav"> <li><a href="index.php"><?php echo $lang_button_index; ?></a></li> <li><a href="settings.php"><?php echo $lang_button_settings; ?></a></li> <li><a href="pages.php"><?php echo $lang_button_pages; ?></a></li> <li><a href="gallery.php"><?php echo $lang_button_gallery; ?></a></li> <li><a href="/"><?php echo $lang_button_viewsite; ?></a></li> <li><a href="logout.php"><?php echo $lang_button_logout; ?></a></li> </ul> <a href="http://www.osphpsite.com" target="_blank" class="link">osPHPSite</a> <a href="http://www.osphpsite.com/forums/" target="_blank" class="link">Support Forums</a> <a href="http://www.vichost.com" target="_blank" class="link">VicHost.Com</a> </div> <div id="center-column"> <div class="table"> <?php if(!empty($errors)){ echo 'The following errors occurred:<br />'; foreach($errors as $error){ echo "$error<br />"; } } ?> <form action="" id="settings" name="settings"> <table class="listing form" cellpadding="0" cellspacing="0"> <tr> <th class="full" colspan="2">Site Configuration</th> </tr> <tr> <th colspan="2">From the options below, define the default settings for your website.</th> </tr> <tr> <th colspan="2"></th> </tr> <tr> <td>Site name: </td> <td><input type="text" name="sitename" value="<?php echo $site_name; ?>" width="172" /> <em>Site name for logo</em></td> </tr> <tr> <td>Email: </td> <td><input type="text" name="email" value="<?php echo $site_email; ?>" width="172" /> <em>Your email address</em></td> </tr> <tr> <td>Name: </td> <td><input type="text" name="name" value="<?php echo $your_name; ?>" width="172" /> <em>Your own name</em></td> </tr> <tr> <td>Meta Description: </td> <td><input type="text" name="meta-description" value="<?php echo $meta_description; ?>" width="172" /> <em>SEO</em></td> </tr> <tr> <td>Meta Keywords: </td> <td><input type="text" name="meta-keywords" value="<?php echo $meta_keywords; ?>" width="172" /> <em>Separate with Commas</em></td> </tr> <tr> <td><input type="submit" class="button" name="submit" value="Submit"></td> </tr> </table> </form> </div> </div> </div> </div> </body> </html> This will be a huge hurdle if I can get passed this one, I am well and truly on my way. Any help, advice etc that you can give, and what needs to go where, I would really appreciate it and I promise not to annoy you guys unless absolutely necessary. I have the following html code and php code. I would like clients to select which fields in the mysql database they would like to have appear in the resultant table by checking the text box next to the field in the html form. For instance they should be able to select first name and city and have only those columns appear in the resultant table. # <html> # <head> # <title>Search Clients Database</title> # </head> # # <body> # <h1>Clients Database Search Page</h1> # <form action="searchclients.php" method="post"> # <table width="100%" border="1" cellspacing="1" cellpadding="1"> # <tr> # <th width="37" scope="col"> </th> # <th width="114" scope="col">Fields</th> # <th width="169" scope="col">Filter Value</th> # <th width="1157" scope="col"> </th> # </tr> # <tr> # <td><input type="checkbox" name="idc" id="idc"></td> # <td>ID</td> # <td><input type="text" name="ID" id="ID"></td> # <td> </td> # </tr> # <tr> # <td><label> # <input type="checkbox" name="fnc" id="fnc"> # </label></td> # <td>First Name</td> # <td><input type="text" name="FirstName" id="FirstName"></td> # <td> </td> # </tr> # <tr> # <td><label> # <input type="checkbox" name="lnc" id="lnc"> # </label></td> # <td>Last Name</td> # <td><input type="text" name="LastName" id="LastName"></td> # <td> </td> # </tr> # <tr> # <td><label> # <input type="checkbox" name="cc" id="cc"> # </label></td> # <td>City</td> # <td><input type="text" name="City" id="City"></td> # <td> </td> # </tr> # <tr> # <td><label> # <input type="checkbox" name="pc" id="pc"> # </label></td> # <td>Province</td> # <td><select name="Province" id="Province"> # <option selected> </option> # <option>KZN</option> # <option>North West Province</option> # <option>Gauteng</option> # <option>Free State</option> # <option>Mpumalanga</option> # <option>Eastern Cape</option> # <option>Limpopo Province</option> # <option>Northern Cape</option> # <option>Western Cape</option> # </select></td> # <td> </td> # </tr> # </table> # <p> # <input type="submit" name="submit" value="Search" /> # </p> # </form> # # </body> # </html> # <?php # mysql_connect ("localhost", "username","password") or die (mysql_error()); # mysql_select_db ("clients"); # # $fn = $_POST['FirstName']; # $ln = $_POST['LastName']; # $city = $_POST['City']; # $prov = $_POST['Province']; # # $idc = $_POST['idc']; # $fnc = $_POST['fnc']; # $lnc = $_POST['lnc']; # $cc = $_POST['cc']; # $pc = $_POST['pc']; # # ?> # # <html> # <body> # # <table border=1> # <tr> # <th>ID</th> # <th>First Name</th> # <th>Last Name</th> # <th>City</th> # <th>Province</th> # </tr> # # <?php # $sql = mysql_query("select ID, FirstName, LastName, City, Province from clients where FirstName like '%$fn%' and LastName like '%$ln%' and City like '%$city%' and Province like '%$prov%'"); # # while ($row = mysql_fetch_array($sql)){ # # $id = $row['ID']; # $fname = $row['FirstName']; # $lname = $row['LastName']; # $city = $row['City']; # $prov = $row['Province']; # # ?> # # <tr> # <th><?php echo $id;?></th> # <th><?php echo $fname;?></th> # <th><?php echo $lname;?></th> # <th><?php echo $city;?></th> # <th><?php echo $prov;?></th> # </tr> # # <?php } //this ends the if?> # # </table> # </html> Hey guys I'm really confused at the minute, I have products in my database (It's MySQL) I want to display attributes from the products in a filtering form.
I currently have select elements in my template and I want to display all current manufacturers that are listed in the manufacturers column of my database.
How can I display the manufacturers once in the select element without displaying them multiple times and in alphabetical order? For example I might have 4 products that are Sony but I don't want the brand to display 4 times.
Any resources or examples on how to do this?
Thanks
|