Jump to content

wright67uk

Members
  • Posts

    454
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

wright67uk's Achievements

Advanced Member

Advanced Member (4/5)

0

Reputation

  1. Thank you Christian, I will do some more reading on the ANSI syntax.
  2. "Im guessing its a jquery issue, but thought it would be best to double check my php first" ..... I know that this is a php forum, its just that I thought I might of made a mistake with the php section of the file. I can't understand why jQuery would work for the first file and not the second, whilst jQuery is seeing the same output.
  3. One piece of code loads a sortable table, but the other one doesnt. The two links above display the files. The two files are similar, and I can't understand why jQuery processes one and not the other. Why is this? And is my code above written correctly?
  4. Ok, I was unaware of this. Although it does still output from two tables? Eg. www.treequoter.co.uk/tabledisplay.php But not working; www.treequoter.co.uk/tabledisplay2.php I tested the sql in phpadmin and it seemed ok. How do I do this query correctly?
  5. I have two similar bits of code. One works and one doesn't. Can you spot any errors? The first piece works well in the jquery app and the second outputs but doesn't load the app. Im guessing its a jquery issue, but thought it would be best to double check my php first. <!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> <script type="text/javascript" charset="utf-8" src="jquery.js"></script> <script type="text/javascript" charset="utf-8" src="jquery.dataTables.js"></script> <link rel="stylesheet" type="text/css" href="demo_table.css"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <style type=”text/css”> .sort{font-size:9px;} table.tablesorter .header { background-image: url(“/path/to/bg.png”); background-repeat: no-repeat; padding-left: 30px; padding-top: 8px; width:auto; } table.tablesorter th.no_sort { background-image: url(“/path/to/header.PNG”); } table.tablesorter .headerSortUp { background-image: url(“/path/to/asc.png”); background-repeat: no-repeat; } table.tablesorter .headerSortDown { background-image: url(“/path/to/desc.png”); background-repeat: no-repeat; } table.tablesorter .even { background-color: #9999CC; } table.tablesorter .odd { background-color: #FFFFFF; } </style> <script type="text/javascript"> <!--jQuery.noConflict();-> var $j = jQuery.noConflict(); $j (document).ready(function() { //$j (“#table_id”).tablesorter({widgets: ['zebra']}); $j ("#table_id").tablesorter(); } ); </script> </head> <body> <?php #connection# $connect_solning = mysql_connect($hostname_connect, $username_connect, $password_connect) or trigger_error(mysql_error(),E_USER_ERROR); @mysql_select_db($database_connect) or die (mysql_error()); $tbl_name = "snag_score"; $result = mysql_query("SELECT * FROM $tbl_name"); //change the next line to this echo('<table id="table_id" class="display"> <thead><tr> <th>id</th> <th>user_id</th> <th>year</th> <th>total_score</th> <th>date</th> </tr></thead><tbody>' ); while($row=mysql_fetch_array($result)) { $id=$row["id"]; $user_id=$row["user_id"]; $year=$row["year"]; $total_score=$row["total_score"]; $r_date=$row["r_date"]; echo "<tr> <td>$id</td> <td>$user_id</td> <td>$year</td> <td>$total_score</td> <td>$r_date</td> </tr>"; } echo('</tbody></table>'); ?> and the piece that isnt working in jquery; <!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> <script type="text/javascript" charset="utf-8" src="jquery.js"></script> <script type="text/javascript" charset="utf-8" src="jquery.dataTables.js"></script> <link rel="stylesheet" type="text/css" href="demo_table.css"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <style type=”text/css”> .sort{font-size:9px;} table.tablesorter .header { background-image: url(“/path/to/bg.png”); background-repeat: no-repeat; padding-left: 30px; padding-top: 8px; width:auto; } table.tablesorter th.no_sort { background-image: url(“/path/to/header.PNG”); } table.tablesorter .headerSortUp { background-image: url(“/path/to/asc.png”); background-repeat: no-repeat; } table.tablesorter .headerSortDown { background-image: url(“/path/to/desc.png”); background-repeat: no-repeat; } table.tablesorter .even { background-color: #9999CC; } table.tablesorter .odd { background-color: #FFFFFF; } </style> <script type="text/javascript"> <!--jQuery.noConflict();-> var $j = jQuery.noConflict(); $j (document).ready(function() { //$j (“#table_id”).tablesorter({widgets: ['zebra']}); $j ("#table_id").tablesorter(); } ); </script> </head> <body> <?php #connection $connect_solning = mysql_connect($hostname_connect, $username_connect, $password_connect) or trigger_error(mysql_error(),E_USER_ERROR); @mysql_select_db($database_connect) or die (mysql_error()); $result = mysql_query ("SELECT registration.fname, registration.lname, snag.club, snag.sdate, snag.yard, snag.year FROM registration, snag WHERE registration.user_id = snag.user_id"); echo ('<table id="table_id" class="display"><thead><tr> <th>fname</th> <th>lname</th> <th>Club</th> <th>sdate</th> <th>yard</th> <th>year</th> </tr></thead><tbody>' ); while($row=mysql_fetch_array($result)) { $fname=$row["fname"]; $lname=$row["lname"]; $club=$row["club"]; $sdate=$row["sdate"]; $yard=$row["yard"]; $year=$row["year"]; echo "<tr> <td>$fname</td> <td>$lname</td> <td>$club</td> <td>$sdate</td> <td>$yard</td> <td>$year</td> </tr>"; } echo('</tbody></table>'); ?>
  6. I'm sure i'm doing things the wrong way here, but I don't seem to be able to get my head around it. How can i ensure that $who has the value of the selected option from my form after it has been submitted? at the moment it just has the value of the last $fname and $lname in my db. and doesnt change. <?php $sql="SELECT user_id, fname, lname FROM registration"; $result=mysql_query($sql); $options=""; while ($row=mysql_fetch_array($result)) { $user_id=$row["user_id"]; $fname=$row["fname"]; $lname=$row["lname"]; $options.="<OPTION VALUE=\"$user_id\">".$fname." ".$lname; } $who = $fname." ".$lname; ?> and then in my code... text: '<?php echo $year ?> Ranges by Club for <?php echo $who ?>', and then at the bottom of my page... <form method="post" action="<?php echo $PHP_SELF;?>"> <select name="user_id"> <option>Select User</option> <?php echo $options ?> </select> <input type="submit" value="Submit"> </form> everything together... <?php $connect_solning = mysql_connect($hostname_connect, $username_connect, $password_connect) or trigger_error(mysql_error(),E_USER_ERROR); @mysql_select_db($database_connect) or die (mysql_error()); $tbl_name = "snag"; $user_id = $_POST["user_id"]; $year = (isset($_GET['year'])) ? (int)$_GET['year'] : date('Y'); $year_links = ''; $_GET['year'] = $year-1; $year_links .= "<a href='?" . http_build_query($_GET, '', '&') . "'>-</a> "; $year_links .= " $year "; $_GET['year'] = $year+1; $year_links .= " <a href='?" . http_build_query($_GET, '', '&') . "'>+</a>"; $sql="SELECT user_id, fname, lname FROM registration"; $result=mysql_query($sql); $options=""; while ($row=mysql_fetch_array($result)) { $user_id=$row["user_id"]; $fname=$row["fname"]; $lname=$row["lname"]; $options.="<OPTION VALUE=\"$user_id\">".$fname." ".$lname; } $who = $fname." ".$lname; ?> <style type="text/css"> a:link {text-decoration:none;} </style> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script> <script type="text/javascript"> $(function () { var chart; $(document).ready(function() { chart = new Highcharts.Chart({ chart: { renderTo: 'container', type: 'line', marginRight: 130, marginBottom: 25 }, title: { text: '<?php echo $year ?> Ranges by Club for <?php echo $who ?>', x: -20 //center }, subtitle: { text: 'Averages for month', x: -20 }, xAxis: { categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] }, yAxis: { title: { text: 'Score' }, plotLines: [{ value: 0, width: 1, color: '#808080' }] }, tooltip: { formatter: function() { return '<b>'+ this.series.name +'</b><br/>'+ this.x +': '+ this.y +''; } }, legend: { layout: 'vertical', align: 'right', verticalAlign: 'top', x: -10, y: 100, borderWidth: 0 }, series: [{ name: 'Driver', data: [<?php $sql= "SELECT month_table.month , IFNULL(AVG( yard ), 0) AS avscore FROM month_table LEFT JOIN `snag` ON month_table.month = MONTH( STR_TO_DATE( sdate, '%d/%m/%y' ) ) AND club = 'Driver' AND user_id = $user_id AND YEAR = $year GROUP BY `month`"; $result=mysql_query($sql); while($row = mysql_fetch_array($result) ){ echo $row['avscore'].',';} ?>] }, { name: '3 Wood', data: [<?php $sql= "SELECT month_table.month , IFNULL(AVG( yard ), 0) AS avscore FROM month_table LEFT JOIN `snag` ON month_table.month = MONTH( STR_TO_DATE( sdate, '%d/%m/%y' ) ) AND club = '3 wood' AND user_id = $user_id AND YEAR = $year GROUP BY `month`"; $result=mysql_query($sql); while($row = mysql_fetch_array($result) ){ echo $row['avscore'].',';} ?>] }, { name: '5 Wood', data: [<?php $sql= "SELECT month_table.month , IFNULL(AVG( yard ), 0) AS avscore FROM month_table LEFT JOIN `snag` ON month_table.month = MONTH( STR_TO_DATE( sdate, '%d/%m/%y' ) ) AND club = '5 wood' AND user_id = $user_id AND YEAR = $year GROUP BY `month`"; $result=mysql_query($sql); while($row = mysql_fetch_array($result) ){ echo $row['avscore'].',';} ?>] /* SELECT yard FROM `snag` WHERE club = '5 wood' AND user_id = 1 */ }, { name: 'Hybrid', data: [<?php $sql= "SELECT month_table.month , IFNULL(AVG( yard ), 0) AS avscore FROM month_table LEFT JOIN `snag` ON month_table.month = MONTH( STR_TO_DATE( sdate, '%d/%m/%y' ) ) AND club = 'Hybrid' AND user_id = $user_id AND YEAR = $year GROUP BY `month`"; $result=mysql_query($sql); while($row = mysql_fetch_array($result) ){ echo $row['avscore'].',';} ?>] }, { name: '3 iron', data:[<?php $sql= "SELECT month_table.month , IFNULL(AVG( yard ), 0) AS avscore FROM month_table LEFT JOIN `snag` ON month_table.month = MONTH( STR_TO_DATE( sdate, '%d/%m/%y' ) ) AND club = '3 iron' AND user_id = $user_id AND YEAR = $year GROUP BY `month`"; $result=mysql_query($sql); while($row = mysql_fetch_array($result) ){ echo $row['avscore'].',';} ?>] }, { name: '4 iron', data: [<?php $sql= "SELECT month_table.month , IFNULL(AVG( yard ), 0) AS avscore FROM month_table LEFT JOIN `snag` ON month_table.month = MONTH( STR_TO_DATE( sdate, '%d/%m/%y' ) ) AND club = '4 iron' AND user_id = $user_id AND YEAR = $year GROUP BY `month`"; $result=mysql_query($sql); while($row = mysql_fetch_array($result) ){ echo $row['avscore'].',';} ?>] }, { name: '5 iron', data: [<?php $sql= "SELECT month_table.month , IFNULL(AVG( yard ), 0) AS avscore FROM month_table LEFT JOIN `snag` ON month_table.month = MONTH( STR_TO_DATE( sdate, '%d/%m/%y' ) ) AND club = '5 iron' AND user_id = $user_id AND YEAR = $year GROUP BY `month`"; $result=mysql_query($sql); while($row = mysql_fetch_array($result) ){ echo $row['avscore'].',';} ?>] }, { name: '6 iron', data: [<?php $sql= "SELECT month_table.month , IFNULL(AVG( yard ), 0) AS avscore FROM month_table LEFT JOIN `snag` ON month_table.month = MONTH( STR_TO_DATE( sdate, '%d/%m/%y' ) ) AND club = '6 iron' AND user_id = $user_id AND YEAR = $year GROUP BY `month`"; $result=mysql_query($sql); while($row = mysql_fetch_array($result) ){ echo $row['avscore'].',';} ?>] }, { name: '7 iron', data: [<?php $sql= "SELECT month_table.month , IFNULL(AVG( yard ), 0) AS avscore FROM month_table LEFT JOIN `snag` ON month_table.month = MONTH( STR_TO_DATE( sdate, '%d/%m/%y' ) ) AND club = '7 iron' AND user_id = $user_id AND YEAR = $year GROUP BY `month`"; $result=mysql_query($sql); while($row = mysql_fetch_array($result) ){ echo $row['avscore'].',';} ?>] }, { name: '8 iron', data: [<?php $sql= "SELECT month_table.month , IFNULL(AVG( yard ), 0) AS avscore FROM month_table LEFT JOIN `snag` ON month_table.month = MONTH( STR_TO_DATE( sdate, '%d/%m/%y' ) ) AND club = '8 iron' AND user_id = $user_id AND YEAR = $year GROUP BY `month`"; $result=mysql_query($sql); while($row = mysql_fetch_array($result) ){ echo $row['avscore'].',';} ?>] }, { name: '9 iron', data: [<?php $sql= "SELECT month_table.month , IFNULL(AVG( yard ), 0) AS avscore FROM month_table LEFT JOIN `snag` ON month_table.month = MONTH( STR_TO_DATE( sdate, '%d/%m/%y' ) ) AND club = '9 iron' AND user_id = $user_id AND YEAR = $year GROUP BY `month`"; $result=mysql_query($sql); while($row = mysql_fetch_array($result) ){ echo $row['avscore'].',';} ?>] }, { name: 'P Wedge', data: [<?php $sql= "SELECT month_table.month , IFNULL(AVG( yard ), 0) AS avscore FROM month_table LEFT JOIN `snag` ON month_table.month = MONTH( STR_TO_DATE( sdate, '%d/%m/%y' ) ) AND club = 'P wedge' AND user_id = $user_id AND YEAR = $year GROUP BY `month`"; $result=mysql_query($sql); while($row = mysql_fetch_array($result) ){ echo $row['avscore'].',';} ?>] }, { name: 'S Wedge', data: [<?php $sql= "SELECT month_table.month , IFNULL(AVG( yard ), 0) AS avscore FROM month_table LEFT JOIN `snag` ON month_table.month = MONTH( STR_TO_DATE( sdate, '%d/%m/%y' ) ) AND club = 'S wedge' AND user_id = $user_id AND YEAR = $year GROUP BY `month`"; $result=mysql_query($sql); while($row = mysql_fetch_array($result) ){ echo $row['avscore'].',';} ?>] }] }); }); }); </script> </head> <body> <script src="../../js/highcharts.js"></script> <script src="../../js/modules/exporting.js"></script> <form method="post" action="<?php echo $PHP_SELF;?>"> <select name="user_id"> <option>Select User</option> <?php echo $options ?> </select> <input type="submit" value="Submit"> </form> <?php echo $year_links;?> <div id="container" style="min-width: 400px; height: 400px; margin: 0 auto"> </div> </body> </html>
  7. I have a variable; $year = date("Y"); Which I echo on my page; echo $year; which gives the output 2012. Either with text or images, I would like to put a plus symbol and a minus symbol either side of the 2012. If the - symbol is pressed, $year will have the value of 2011 and if the + symbol is press it will have the value of 2013. How would i go about this in the correct manner, and can you provide a basic example?
  8. How can i change my form below, so that the chosen option populates the $user_id variable. I would like to use he variable in an sql query. eg. user selects option value 5, then $user_id = 5, name: 'S Wedge', data: [<?php $sql= "SELECT month_table.month , IFNULL(AVG( yard ), 0) AS avscore FROM month_table LEFT JOIN `snag` ON month_table.month = MONTH( STR_TO_DATE( sdate, '%d/%m/%y' ) ) AND club = 'S wedge' AND user_id = $user_id AND YEAR = $year GROUP BY `month`"; $result=mysql_query($sql); while($row = mysql_fetch_array($result) ){ echo $row['avscore'].',';} ?>] }] }); }); }); </script> </head> <body> <script src="../../js/highcharts.js"></script> <script src="../../js/modules/exporting.js"></script> <form action="action=<?php echo htmlentities($_SERVER['PHP_SELF']); ?> method="post">" <label for='user_id[]'>Select the user you would like to display:</label><br> <select multiple="multiple" name="user_id[]"> <option>Select User</option> <option value="1">1</option> <option value="3">3</option> <option value="5">5</option> <option value="7">7</option> </select> <input type="submit" value="Submit"> </form> <?php echo $user_id ?> <div id="container" style="min-width: 400px; height: 400px; margin: 0 auto"> </div> </body> </html>
  9. Im exploring the world of classes, methods and objects and im after some explanation to my code below; 1) what does echo $oTime->sTime; do in this code. 2) why do i NOT need to add "$sTime =" before "$oTime->ShowFutureDate(20); " for the code to execute properly (as i did in line time.php <?php include('class_time.php'); //include file where class is stored $oTime = new Time; // VARIABLE = new CLASSNAME $oTime is now the object variable $sTime = $oTime->GenerateCurrentTime(); // use GenerateCurrentTime within the $oTime class // -> means 'is the parent of' $oTime is the parent of ' GenerateCurrentTime()' print 'The time is: ' . $sTime; // print value of GenerateCurrentTime echo $oTime->sTime; echo "<br/>"; // new line $oTime->ShowFutureDate(20); print 'The future time is: ' . $sTime; echo $oTime->sTime; ?> class_time.php <?php class Time { var $stime; function GenerateCurrentTime() { $this->sTime = gmdate("d-m-Y H:i:s"); //assign the current date to the sTime variable } function ShowFutureDate($iAddDays=0) { $this->sTime = gmdate("d-m-Y H:i:s", strtotime("+" . $iAddDays . " days")); } } ?>
  10. IVe also tried this page with different colors and fonts; www.hertfordlogs.co.uk/brown No metas, alts, or titles as of yet. Any feedback would be great.
  11. fair point - title added! what does "the old o.0" mean? yes just 1 page done for now. thankyou for the current feedback
  12. Hello Im looking for initial opinions on the page www.hertfordlogs.co.uk . Its only basic and ive only been given basic content for each page (a paragraph of text and a photo), so not a lot to go on really. Would love to hear from you, Ed.
  13. That's what i was thinking and then play around with .hr css
  14. Well they don't teach that in my text books! Brilliant none the less. What's best a freak or an addict.?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.