PHP - Count And Display Specifically Updated Records Not All Records
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).... 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 Hi guys, I need your help. I am checking on a database as I want to see if the records have been updated or not. Code: [Select] <?php session_start(); define('DB_HOST', 'localhost'); define('DB_USER', 'mydbuser'); define('DB_PASSWORD', 'mydbpass'); define('DB_DATABASE', 'mydbtable'); $errmsg_arr = array(); $errflag = false; $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } $db = mysql_select_db(DB_DATABASE); if(!$db) { die("Unable to select database"); } function clean($var){ return mysql_real_escape_string(strip_tags($var)); } $username = clean($_GET['user']); $password = clean($_GET['pass']); $test = clean($_GET['test']); $public = clean($_GET['public']); if (isset($_GET['user']) && (isset($_GET['pass']))) { if($username == '' || $password == '') { $errmsg_arr[] = 'username or password are missing'; $errflag = true; } } elseif (isset($_GET['user']) || (isset($_GET['test'])) || (isset($_GET['public']))) { if($username == '' || $test == '' || $public == '') { $errmsg_arr[] = 'user or others are missing'; $errflag = true; } } if($errflag) { $_SESSION['ERRMSG_ARR'] = $errmsg_arr; echo implode('<br />',$errmsg_arr); } else { $qry="SELECT * FROM members WHERE username='$username' AND passwd='$password'"; $result=mysql_query($qry) or die('Error:<br />' . $qry . '<br />' . mysql_error()); if ($username && $password) { if(mysql_num_rows($result) > 0) { $qrytable1="SELECT images, id, test, links, Public FROM user_channel_list WHERE username='$username'"; $result1=mysql_query($qrytable1) or die('Error:<br />' . $qry . '<br />' . mysql_error()); while ($row = mysql_fetch_array($result1)) { echo "<p id='test'>"; echo $row['test'] . "</p>"; echo '<p id="images"> <a href="images.php?test=test&id='.$row['id'].'">Images</a></td> | <a href="http://' . $row["links"] . '">Link</a> </td> | <a href="delete.php?test=test&id='.$row['id'].'">Delete</a> </td> | <span id="test">'.$row['Public'].'</td>'; } } else { echo "user not found"; } } elseif($username && $test && $public) { $qry="SELECT * FROM members WHERE username='$username'"; $result1=mysql_query($qry) or die('Error:<br />' . $qry . '<br />' . mysql_error()); if(mysql_num_rows($result1) > 0) { $qrytable1="SELECT Public FROM user_channel_list WHERE username='$username' && test='$test'"; $result2=mysql_query($qrytable1) or die('Error:<br />' . $qry . '<br />' . mysql_error()); if(mysql_num_rows($result2) > 0) { $row = mysql_fetch_row($result2); mysql_query("UPDATE user_list SET Public=('$_GET[public]') WHERE username='$username' AND test='$test'"); echo "update!"; } else { echo "already updated!"; } } else { echo "user not found"; } } } ?> When I run debug the code on my php, if i input the data in a url bar while the records are the same as the data that I enter in the url, i should get the print out on my php "already updated", but I keep getting "update!". Do you know how i can check on mysql database to see if the records have been updated or not?? I need help with a count query and displaying it. Right now have the following query $query = "SELECT COUNT(*) as num1 FROM spoiler WHERE id='$id"; $total_trophies = mysql_fetch_array(mysql_query($query)); $total_trophies = $total_trophies[num1]; So I have another query that pulls how many trophies there are. That way I can do the following ? echo $total_trophies; echo 'of'; echo $row[trophy_count]; ?> But the problem is sometimes in my database I could have mulitple entrys per trophy. For Trophy 1 I might have only one record so It counts it correctly for trophy 2 I could have 3 records so It counts each one of those records when I only one to count it once for that trophy Hi all, I am trying to use the Mysql COUNT function to count the number of records in a database where the manufacturer is the same and then generate a list of all manufacturers along with a number of associated records next to their name. I have got the script below to show the manufacturer in a fetch array but I can not get the number next to the manufacturer to work. A push in the right direction would be appreciated thanks. <?php include("cxn.php"); $query = "SELECT manufacturer FROM sales"; $result = mysqli_query($cxn,$query) or die(mysqli_error()); ?> <select name="manufacturer" id="manufacturer"> <option value="" selected="selected">Select a Manufacturer..</option>"; <?php while($row = mysqli_fetch_array($result)){ $query1 = "SELECT manufacturer COUNT(*) FROM sales WHERE manufacturer='$row[manufacturer]'"; // TRYING TO COUNT THE ROWS HERE $result1 = mysqli_query($cxn,$query1) or die (mysqli_error()); while($row1 = mysqli_fetch_array($result1)){ echo "<option value=\"202\">".$row['manufacturer'] ."[". $row1['COUNT(manufacturer)']."]</option>"; // SHOW NUMBER HERE } } ?> How to COUNT the number of records (pulled from a db)which contains the word "APPROVED". This code doesn't work though. $result1; $result2; $result3; $approvedApplicants = COUNT($result1=='Approved', $result2=='Approved', $result3=='Approved') echo ($approvedApplicants) 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: 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? Hello Everyone, I wanted to know how to Display records from a Table one by one at difference time intervals. Kindly suggest 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, 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 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, 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> 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 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. 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 all Complete noob here..... What I have to do is create a new database every year, but I can't just import last years data completely, only records when needed. I can do it myself in PHPMyAdmin, but I don't want my employees touching mysql directly. What I am trying to do is write a php script that will serach for a reocrd in last years database and if it exists insert it into the new database if it doesn't exists bring up a form so it can be entered. Any help would be greatly appreciated. Thanx ZZ 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>'; } |