Jump to content

bravo14

Members
  • Posts

    296
  • Joined

  • Last visited

Everything posted by bravo14

  1. Thanks, I've changed it to that, but now when changing the value in the select field I get the following error TypeError: document.getElementsByName(...).style is undefined The javascript function says <script> function test() { if (document.getElementsByName('points[]').value == 'F2') { document.getElementsByName('subpts[]').style.display = ''; } else { document.getElementsByName('subpts[]').style.display = 'none'; } }</script> and the php says <tr><td><img src="images/gate_<?php echo $rider_row['colour'];?>.png"/> <input name="id[]" type="hidden" value="<?php echo $rider_row['id'];?>"/></td><td><input readonly="readonly" name="rider[]" value="<?php echo $rider_row['rider_name'];?>" class="txtfield"/><br /> <select name="substitute[]" class="txtfield" style="display:none"> <option value="">-----------------</option> <?php foreach($reserves as $key=> $value): echo '<option value="'.$value.'">'.$value.'</option>'; //close your tags!! endforeach; ?> </select></td><td><select name="points[]" class="txtfield" onchange="test();"> <option value="">-----------------</option> <?php foreach($scoring as $key=> $value): echo '<option value="'.$key.'">'.$value.'</option>'; //close your tags!! endforeach; ?> </select><br/> <select name="subpts[]" class="txtfield" style="display:none"> <option value="">-----------------</option> <?php foreach($scoring as $key=> $value): echo '<option value="'.$key.'">'.$value.'</option>'; //close your tags!! endforeach; ?> </select> </td></tr> the style is set in the php as display:none
  2. Hi I am using the following PHP code to create a table for a form <tr><td><img src="images/gate_<?php echo $rider_row['colour'];?>.png"/> <input name="id[]" type="hidden" value="<?php echo $rider_row['id'];?>"/></td><td><input readonly="readonly" name="rider[]" value="<?php echo $rider_row['rider_name'];?>" class="txtfield"/><br /> <select name="substitute[]" class="txtfield" style="display:none"> <option value="">-----------------</option> <?php foreach($reserves as $key=> $value): echo '<option value="'.$value.'">'.$value.'</option>'; //close your tags!! endforeach; ?> </select></td><td><select name="points[]" class="txtfield" onchange="test();"> <option value="">-----------------</option> <?php foreach($scoring as $key=> $value): echo '<option value="'.$key.'">'.$value.'</option>'; //close your tags!! endforeach; ?> </select><br/> <select name="subpts[]" class="txtfield" style="display:none"> <option value="">-----------------</option> <?php foreach($scoring as $key=> $value): echo '<option value="'.$key.'">'.$value.'</option>'; //close your tags!! endforeach; ?> </select> </td></tr> On changing the value in the field called points[], if certain values are selected then two other fields are to be displayed, I am using the following function <script> function test() { if (document.getElementByName('points[]').value == 'F2 || E || N') { document.getElementByName('substitute[]').style.display = ''; document.getElementByName('subpts[]').style.display = ''; } else { document.getElementByName('substitute[]').style.display = 'none'; document.getElementByName('subpts[]').style.display = 'none'; } }</script> I am getting an error saying getElementByName is not a function, I know I can do this by getElementById, but the fields do not have ID and not sure how I can give them a unique ID when echoing them from the database. If someone could just give me some pointers I would be very grateful
  3. I have changed the submit code to <?php if(isset($_POST['submit-scores'])){ $heat=$_POST['heat']; $next_heat=$_POST['nextheat']; $card=$_POST['card']; for($i=0;$i<4;$i++){ //set rider variables $id=$_POST['id']; $points=$_POST['points']; echo $points; if($points=='3'){ $pts = 3; $DNF = NULL; } elseif($points=='2'){ $pts = 2; $DNF = NULL; } elseif($points == '1'){ $pts = 1; $DNF = NULL; } elseif($points == '0'){ $pts = 0; $DNF = NULL; } else{ $pts = 0; $DNF = $points; } $rider=$_POST['rider']; if(isset($_POST['substitute'])){ $sub=$_POST['sub']; $subpts=$_POST['subpts']; } else{ $sub=NULL; $subpts=NULL; } //update database $sql1="UPDATE tbl_heat SET rider_name='$rider[$i]', points='$pts[$i]', DNF= '$DNF[$i]', substitute='$sub[$i]', sub_points='$subpts[$i]' WHERE id='$id[$i]'"; echo $sql1.'<br/>'; //$result1=mysql_query($sql1)or die(mysql_error()); } //update card info $sql="Update tbl_card SET next_heat = $next_heat where `card_id` = $card"; //$result=mysql_query($sql)or die(mysql_error()); //header ('Location: score-card.php?card='.$card.'#'.$nextheat); } ?> but I am now getting ArrayUPDATE tbl_heat SET rider_name='Chris Harris', points='', DNF= '3', substitute='', sub_points='' WHERE id='853' ArrayUPDATE tbl_heat SET rider_name='Kenneth Bjerre', points='', DNF= '2', substitute='', sub_points='' WHERE id='854' ArrayUPDATE tbl_heat SET rider_name='Martin Smolinski', points='', DNF= '1', substitute='', sub_points='' WHERE id='855' ArrayUPDATE tbl_heat SET rider_name='Chris Holder', points='', DNF= 'F', substitute='', sub_points='' WHERE id='856' I still cant get it to update the points with a value
  4. I have corrected that, however the problem is occurring before the query line, because if the value is numeric then the posted value should be the value of the $pts variable and not the $DNF variable
  5. I understand I need to look at other sources e.g. mysqli or PDO, I suppose old habits die hard :-)
  6. Hi Using the array below I am populating a select field $scoring=array( '3' => 'First', '2' => 'Second', '1' => 'Third', '0' => 'Fourth', 'R' => 'Retired or mechanical failure', 'F' => 'Fell', 'FN'=> 'Fell and non-starter in re-run of race', 'N2'=> 'Exclusion for exceeding two minute time allowance', 'E' => 'Exclusion for starting infringement', 'FX'=> 'Fell and excluded from re-run of race', 'X' => 'Other exclusion', 'N' => 'Replaced by a reserve, or non-starter', '-'=> 'No ride'); <select name="points[]" class="txtfield"> <option value="">-----------------</option> <?php foreach($scoring as $key=> $value): echo '<option value="'.$key.'">'.$value.'</option>'; //close your tags!! endforeach; ?> </select> on submit I then use the following code, checking if the value of `points` is numeric, and if not set pts to be 0 and add the posted value to a different field. <?php if(isset($_POST['submit-scores'])){ $heat=$_POST['heat']; $next_heat=$_POST['nextheat']; $card=$_POST['card']; for($i=0;$i<4;$i++){ //set rider variables $id=$_POST['id']; $points=$_POST['points']; if(is_numeric($points)){ $DNF = NULL; $pts=$points;} else{ $pts=0; $DNF = $points; } $rider=$_POST['rider']; if(isset($_POST['substitute'])){ $sub=$_POST['sub']; $subpts=$_POST['subpts']; } else{ $sub=NULL; $subpts=NULL; } //update database $sql1="UPDATE tbl_heat SET rider_name='$rider[$i]', points='$pts[$i]', DNF= '$DNF[$i] ', substitute='$sub[$i]', sub_points='$subpts[$i]' WHERE id='$id[$i]'"; echo $sql1.'<br/>'; //$result1=mysql_query($sql1)or die(mysql_error()); } //update card info $sql="Update tbl_card SET next_heat = $next_heat where `card_id` = $card"; //$result=mysql_query($sql)or die(mysql_error()); //header ('Location: score-card.php?card='.$card.'#'.$nextheat); } ?> when I echo the query I get the following result UPDATE tbl_heat SET rider_name='Chris Harris', points='', DNF= '3 ', substitute='', sub_points='' WHERE id='853' UPDATE tbl_heat SET rider_name='Kenneth Bjerre', points='', DNF= '2 ', substitute='', sub_points='' WHERE id='854' UPDATE tbl_heat SET rider_name='Martin Smolinski', points='', DNF= '1 ', substitute='', sub_points='' WHERE id='855' UPDATE tbl_heat SET rider_name='Chris Holder', points='', DNF= 'F ', substitute='', sub_points='' WHERE id='856' it appears to be adding a space to the end of each of the array keys, therefore saying that 3 is not numeric etc, so a cople of things, why is the space being added, secondly is this the best way to achieve the result?
  7. Hi I am using the code below to generate an array $sql="SELECT * FROM `tbl_heat` WHERE `heat` =21 AND `points` >= 2 OR `heat` = 22 AND `points` >=2 AND `card_id` = 2"; //echo $sql; $result=mysql_query($sql) or die(mysql_error()); while($row=mysql_fetch_assoc($result)){ $riders[] = $row['rider_name']; print_r ($riders); However the array comes out like this when printed Array ( [0] => Chris Harris ) Array ( [0] => Chris Harris [1] => Kenneth Bjerre ) Array ( [0] => Chris Harris [1] => Kenneth Bjerre [2] => Martin Smolinski ) Array ( [0] => Chris Harris [1] => Kenneth Bjerre [2] => Martin Smolinski [3] => Chris Holder ) I want it to come out like this Array ( [0] => Chris Harris [1] => Kenneth Bjerre [2] => Martin Smolinski [3] => Chris Holder ) What am I doing wrong?
  8. Hi I am trying to a query that has countif in the query is to find the top 8 riders based on ponts scored then number of wins (where points = 3), number of 2nd places (points = 2 etc) SELECT COUNT( `points` ) AS `rides`, SUM( `points` ) AS `pts`, COUNT (IF(`points`=3,1,0)) AS `wins`, COUNT (IF(`points`=2,1,0)) AS `2`, COUNT (IF(`points`=1,1,0)) AS `1`, COUNT (IF(`points`=0,1,0)) AS `0`, rider_name FROM tbl_heat WHERE card_id = $card GROUP BY `rider_name` ORDER BY pts DESC LIMIT 8
  9. Hi I am using the HTML editor elrte from elrte.org, it is simple in its setup and use, the only issue I have is at any special characters like £ are not being converted to the HTML so when I echo them from the database, the characters are shown as squares with question marks in. Is there a way I can do this with PHP. I have tried using htmlentities() and htmlspecialchars() but they convert every item including the <> around the tags
  10. Hi Guys I have a script that I have used before without any issues based on a tutorial. However when I do Update Cart get the following error Array Warning: addslashes() expects parameter 1 to be string, array given in /home/sites/starkeracing.co.uk/public_html/library/config.php on line 5 The form is made up of the following code <form action="/cart.php?action=update" method="post" name="frmCart" id="frmCart"> <table width="780" border="0" align="center" cellpadding="5" cellspacing="1" class="entryTable"> <tr class="entryTableHeader"> <td colspan="2" align="center">Item</td> <td align="center">Unit Price</td> <td width="75" align="center">Quantity</td> <td align="center">Total</td> <td width="75" align="center"> </td> </tr> <tr class="content"> <td width="80" align="center"><a href="main.php?c=2&p=1"><img src="img/product/f9bf45f907835051aa131dde0ec00ef8.jpg" border="0"></a></td> <td><a href="main.php?c=2&p=1">Soft Shell Jacket</a></td> <td align="right">£40.00</td> <td width="75"><input name="txtQty[]" type="text" id="txtQty[]" size="5" value="1" class="box" onKeyUp="checkNumber(this);"> <input name="hidCartId[]" type="hidden" value="15"> <input name="hidProductId[]" type="hidden" value="1"> </td> <td align="right">£40.00</td> <td width="75" align="center"> <input name="btnDelete" type="button" id="btnDelete" value="Delete" onClick="window.location.href='/cart.php?action=delete&cid=15';" class="box"> </td> </tr> <tr class="content"> <td colspan="4" align="right">Sub-total</td> <td align="right">£40.00</td> <td width="75" align="center"> </td> </tr> <tr class="content"> <td colspan="4" align="right">Shipping </td> <td align="right">£5.00</td> <td width="75" align="center"> </td> </tr> <tr class="content"> <td colspan="4" align="right">Total </td> <td align="right">£45.00</td> <td width="75" align="center"> </td> </tr> <tr class="content"> <td colspan="5" align="right"> </td> <td width="75" align="center"> <input name="btnUpdate" type="submit" id="btnUpdate" value="Update Cart" class="box"></td> </tr> </table> </form> The following function is called if (!get_magic_quotes_gpc()) { if (isset($_POST)) { foreach ($_POST as $key => $value) { echo $value; $_POST[$key] = trim(addslashes($value)); } } if (isset($_GET)) { foreach ($_GET as $key => $value) { $_GET[$key] = trim(addslashes($value)); } } } It appears as I have echoed the $value from the get_magic_quotes function that no values are being posted. The following notice is also displayed 1 Notice: Uninitialized string offset: 0 in /home/sites/starkeracing.co.uk/public_html/library/cart-functions.php on line 133 Notice: Uninitialized string offset: 0 in /home/sites/starkeracing.co.uk/public_html/library/cart-functions.php on line 136 Below is the updateCart function that is generating the error above. function updateCart() { $cartId = $_POST['hidCartId']; $productId = $_POST['hidProductId']; $itemQty = $_POST['txtQty']; $numItem = count($itemQty); $numDeleted = 0; $notice = ''; for ($i = 0; $i < $numItem; $i++) { $newQty = (int)$itemQty[$i]; if ($newQty < 1) { // remove this item from shopping cart deleteFromCart($cartId[$i]); $numDeleted += 1; } else { // check current stock $sql = "SELECT pd_name, pd_qty FROM tbl_product WHERE pd_id = {$productId[$i]}"; $result = dbQuery($sql); $row = dbFetchAssoc($result); if ($newQty > $row['pd_qty']) { // we only have this much in stock $newQty = $row['pd_qty']; // if the customer put more than // we have in stock, give a notice if ($row['pd_qty'] > 0) { setError('The quantity you have requested is more than we currently have in stock. The number available is indicated in the "Quantity" box. '); } else { // the product is no longer in stock setError('Sorry, but the product you want (' . $row['pd_name'] . ') is no longer in stock'); // remove this item from shopping cart deleteFromCart($cartId[$i]); $numDeleted += 1; } } // update product quantity $sql = "UPDATE tbl_cart SET ct_qty = $newQty WHERE ct_id = {$cartId[$i]}"; dbQuery($sql); } } if ($numDeleted == $numItem) { // if all item deleted return to the last page that // the customer visited before going to shopping cart header("Location: $returnUrl" . $_SESSION['shop_return_url']); } else { header('Location: cart.php'); } exit; }
  11. Hi I am using the jquery ui tabs, but with the tabs down the right and the text rotated 270 degrees. The problem I then have is the tabs all sit on top of one another but I can't figure out which css property to amend. Below is the initialisation of the tabs and the vertical tabs css <script> $(function() { $( "#tabs" ).tabs().addClass( "ui-tabs-vertical ui-helper-clearfix" ); $( "#tabs li" ).removeClass( "ui-corner-top" ).addClass( "ui-corner-right" ); }); </script> <style> .ui-tabs-vertical { width: auto; } .ui-tabs-vertical .ui-tabs-nav { padding: .2em .1em .2em .2em; float: right; width: 12em; } .ui-tabs-vertical .ui-tabs-nav li { clear: right; width: auto; border-bottom-width: 1px !important; border-right-width: 0 !important; margin: 0 -1px .2em 0; /* Safari */ -webkit-transform: rotate(-90deg); /* Firefox */ -moz-transform: rotate(-90deg); /* IE */ -ms-transform: rotate(-90deg); /* Opera */ -o-transform: rotate(-90deg); /* Internet Explorer */ filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3); } .ui-tabs-vertical .ui-tabs-nav li a { display:block; } .ui-tabs-vertical .ui-tabs-nav li.ui-tabs-active { padding-bottom: 0; padding-right: .1em; border-right-width: 1px; border-right-width: 1px; } .ui-tabs-vertical .ui-tabs-panel { padding: 1em; float: left; width: 40em;} </style> The URL it is on is http://79.170.44.132/emmagrayphotography.co.uk/wedding.html Any help would be fantastic.
  12. Hi Guys I am in the world of trying to prevent copyrighted images being downloaded and have entered the following line into my .htaccess file RewriteRule \.(gif|jpg|js|txt|png)$ /messageforcurious [L] It works in the fact that I cannot enter the image name into the address bar, but it also prevents pages from downloading the images, is it possible to prevent the user downloading the images using .htaccess?
  13. The query now works, althoughn not displaying the results I was expecting, results below. I wanted the photo number to to display the incrementing number 1-20 as I am limiting it to 20, is there anyway I can have the photo_number generated after the sort? photo_number photo_filename 124 124.jpg 46 46.jpg 55 55.jpg 87 87.jpg 6 6.jpg 21 21.jpg 42 42.jpg 112 112.jpg 18 18.jpg 86 86.jpg 69 69.jpg 108 108.jpg 4 4.jpg 107 107.jpg 93 93.jpg 41 41.jpg 65 65.jpg 11 11.jpg 13 13.jpg 24 24.jpg
  14. The PHP code with the query is: $bg_sql=("SET @serial=0; SELECT @serial := @serial+1 AS `photo_number`, `photo_filename` FROM `gallery_photos` ORDER BY RAND() LIMIT 20"); $bg_result=mysql_query($bg_sql) or die (mysql_error());
  15. Hi Guys I am using the following query SET @serial=0; SELECT @serial := @serial+1 AS `photo_number`, `photo_filename` FROM `gallery_photos` ORDER BY RAND() LIMIT 20 When I run the query in MySQL Workbench, I have a set of results, when I run it on a PHP page the query does not run I get the following error displayed You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT @serial := @serial+1 AS `photo_number`, `photo_filename` FROM ' at line 3 Any ideas why this would happen?
  16. I have a couple of functions as shown below function displayTrackingNumber() { if (document.getElementById('cboOrderStatus').value == 'Shipped') { document.getElementById('txtTrackingNumber').style.display = ''; document.getElementById('txtTrackingNumber').focus(); } else { document.getElementById('txtTrackingNumber').style.display = 'none'; } } function blankTrackingNumber() { if(this.value =='Tracking Number') { this.value =''; } } function checkTrackingNumber() { if(this.value =='Tracking Number') { alert("Please enter a Tracking Number!"); } if(this.value =='') { alert("Please enter a Tracking Number!"); } } They are implemented on the page as shown here <input name="txtTrackingNumber" id="txtTrackingNumber" value="Tracking Number" style="display:none" onkeydown='blankTrackingNumber()' onblur='checkTrackingNumber()' /> But when I leave the field nothing is happening and there is nothing appearing in the console and when I press a key on the keyboard the value 'Tracking Number is staying in the field.
  17. Hi Guys Hope someone can help me. I have some code that runs a query and finds 3 rows for example, however only 2 are displayed on the page, however many records are found on the query it will always show 1 less. I have attached the page productList.php
  18. Can I do this in the css file or does it have to be done outside of the css in the head tag of the HTML?
  19. Hi I have a font that I need to download via CSS it works fine in Safari, but in the Console in Firefox I get the following error downloadable font: download failed (font-family: "Dancing" style:normal weight:normal stretch:normal src index:0): bad URI or cross-site access not allowed source: http://www.remyweavesandbraids.com/files/fonts/DancingScript-Regular.ttf The css used is as follows @font-face { font-family: Dancing; src: url(../files/fonts/DancingScript-Regular.eot); /* EOT file for IE */ } @font-face { font-family: Dancing; src: url(../files/fonts/DancingScript-Regular.ttf); /* TTF file for CSS3 browsers */ } What do I need to do in order for Firefox to display it properly
  20. I have a .js file that is referenced in the page, but when I try and run the functions from it the debugger says that the function is undefined. the HTML to load the js file is <script language="JavaScript" type="text/javascript" src="http://www.starkeracing.co.uk/fullthrottle/library/club.js"></script> the call to the function in the HTML <a href="javascript:modifyClub(5);">Modify</a> and the JavaScript file is function modifyClub(clubId) { function code here } I don't understand why it is saying the function is undefined.
  21. I have trued to use NULLIF() in the following way. $points=NULLIF($_POST['points'], ''); I get the following error Fatal error: Call to undefined function NULLIF() in /home/sites/starkeracing.co.uk/public_html/admin/edit-fixture.php on line 19 Any ideas?
  22. I have a site that records a riders score, and occasionally I will need to record 0. If I update with 0, the database shows NULL instead. The snippets of code below show the declaration of the variable and then the adding to an array for an update query if(empty($_POST['points'])){$points=NULL;} else {$points=$_POST['points'];} $columns[] = "points = " . ($points === null ? "NULL" : "'$points'"); My question is how do I update 0 and not NULL
  23. I am working on a site that has a background that changes, on top of that I have put a background image that has a means I can still see the background images but can also see the text on top. The problem I have is that the black background image doesn't fill the entire screen. The URL of the site is http://http://217.199.187.69/starkeracing.co.uk/ The CSS file in use is attached I can't see why the image bg_black.png isn't filling the entire screen. paulstarke.css
  24. I am trying to create a flickr url using the XML file from the site the code I am using is as follows <?php $file="http://api.flickr.com/services/rest/?method=flickr.photosets.getList&api_key=7952c4f1e6dfd2ae1420aec860616f6e&user_id=93306691%40N08&format=rest&auth_token=72157636755071086-2072507680111a83&api_sig=8032afd164bff4d17c4574ae246ce92b"; $sets=simplexml_load_file($file); foreach($sets->xpath('//photoset') as $set){ echo '<a><li><img src="http://farm'.$set{farm-id}.'.staticflickr.com/'.$set{server-id}.'/'.$set{id}.'_'.$set{secret}.'.jpg"/><h3>'.$set->title.'</h3></li></a>'; } //print_r($sets); ?> The XML is laid out as below <photosets cancreate="1" page="1" pages="1" perpage="13" total="13"> <photoset id="72157634817057978" primary="9378217918" secret="66a440b8e3" server="3753" farm="4" photos="28" videos="0" needs_interstitial="0" visibility_can_see_set="1" count_views="34" count_comments="0" can_comment="1" date_create="1374935118" date_update="1374954932"> <title>Coventry v Birmingham - 26-07-13</title> <description>Photos of the occasion when the Birmingham Brummies ascended to the top of the Elite League table.</description> </photoset> </photosets> But I am getting the following error displayed Notice: Use of undefined constant farm - assumed 'farm' in /home/sites/birminghambrummies.co/public_html/library/flickr_sets.php on line 6 Notice: Use of undefined constant id - assumed 'id' in /home/sites/birminghambrummies.co/public_html/library/flickr_sets.php on line 6 Notice: Use of undefined constant server - assumed 'server' in /home/sites/birminghambrummies.co/public_html/library/flickr_sets.php on line 6 Notice: Use of undefined constant id - assumed 'id' in /home/sites/birminghambrummies.co/public_html/library/flickr_sets.php on line 6 Notice: Use of undefined constant id - assumed 'id' in /home/sites/birminghambrummies.co/public_html/library/flickr_sets.php on line 6 Notice: Use of undefined constant secret - assumed 'secret' in /home/sites/birminghambrummies.co/public_html/library/flickr_sets.php on line 6The parameters I need are within the photoset tag and not tags on their own. Any help would be great
×
×
  • 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.