Jump to content

paulonline2501

Members
  • Content Count

    70
  • Joined

  • Last visited

Community Reputation

1 Neutral

About paulonline2501

  • Rank
    Newbie

Contact Methods

  • Website URL
    http://www.paulyouthed.com

Profile Information

  • Location
    London, UK
  • Interests
    php, (x)html, cats, music
  1. Hi, this is not my code but its giving me trouble on a site. the code works in IE. but in Crome there is a radio button that is defaulted to not show some text. when the user switches to the other radio button (three are just two) the text is supposed to display. it works in IE but not Crome. is the text below enough or do you want to see the code for the whole page? <script type="text/javascript">$(document).ready(function() { $("input:radio[alt-id='test-hide']").change(function() { if(this.checked && this.value == "Y") {$("div#other-questions").show();}if(this.checked && this.value == "N") {$("div#other-questions").hide();}});$("input:radio[alt-id='test-hide']").change();});
  2. elseif(htmlentities($db_oregion)==htmlentities("North & Islands")){echo("North, Highlands & Islands");} switch ($db_oregion) { case "Central": echo "Central Scotland"; break; case "East": echo "East Anglia"; break; case "Mid": echo "Mid & West Wales"; break; case "North": echo "North Wales"; break; case "North & Islands": echo "North, Highlands & Islands"; break; default: echo "$db_oregion";} thanks for all the replies. I tried using htmlentities [see above], and switch [see above] but neither worked. I wasn't sure how to do a switch with htmlentities. however, its still not working. as I said: the conversion should change entries coming back from the DB from "North & Islands" to "North, Highlands & Islands". this is the only conversion that is not working. the other conversions are all working. the values are correct in the DB. "North & Islands" is displaying incorrectly so I know the values in the DB are what i'm expecting, there just not converting. asd
  3. paulonline2501

    php if else

    hi everyone, I'm having trouble with a PHP if statement. I'm getting a value back from a database. the values stored in the DB aren't exactly what I want to display so im going to do a inline conversion on them. I want to say for example: if the region = 'central' then display 'central Scotland'. ive added my conversion but the value that is stored in the DB is showing rather than the converted value. can anyone spot what is wrong? UPDATE: OK, so it works for all of these apart from the "North & Islands" one. all othere convert, but this one doesn't. it doesn't change to "North, Highlands & Islands" it just stays as "North & Islands". the others change. the code is below: <h3><strong>Region:</strong> <?php if($db_oregion=="Central"){echo("Central Scotland");} elseif($db_oregion=="East"){echo("East Anglia");} elseif($db_oregion=="Mid"){echo("Mid & West Wales");} elseif($db_oregion=="North"){echo("North Wales");} elseif($db_oregion=="North & Islands"){echo("North, Highlands & Islands");} elseif($db_oregion=="South"){echo("South Wales");} else{echo($db_oregion);} ?> </h3>
  4. ....actually, I think ive got it working but i'm sure there is a way to write it in a more elegant way.here's what I wrote: <?php $myString = trim($myString, ","); $myArray = explode(",", $myString); echo("<p>Exploded string in array:</p><ul>"); foreach($myArray as $thisValue) { $i=0; $thisPartsValueID=""; $thisPartsValueQuantity=""; $myArrayParts = explode("-", $thisValue); foreach($myArrayParts as $thisPartsValue) { if($i==0){echo("<li>id=".$thisPartsValue."</li>");$thisPartsValueID=$thisPartsValue;$i++;} else{echo("<li>quantity=".$thisPartsValue."</li>");$thisPartsValueQuantity=$thisPartsValue;} } echo("insert into tableName (quantity) values (currentQuantity - $thisPartsValueQuantity) where id = $thisPartsValueID"); } echo("</ul>");?>
  5. yeah, thanks justsomeguy, but how do you get it into the sub array?
  6. <p><?php$myString = "45-2,34-2,35-1,";echo($myString);?></p><?php$myString = trim($myString, ",");$myArray = explode(",", $myString);echo("<p>Exploded string in array:</p><ul>");foreach($myArray as $thisValue){ echo("<li>".$thisValue."</li>");}echo("</ul>");?> I got the first explode working but struggling with the 2nd explode.
  7. ...thanks justsomeguy. yeah, I found something on exploding and am trying it now. I've got the first explode working, and even managed to trim the trailing comma to stop it from being put in the array.
  8. hi, I've got a variable being passed to me from a third party website. in the following format "45-1," where 45 would be the item id and 1 would be the quantity. the variable could hold a few key pairs. eg: "45-1,46-3,5-3,"the first number is always the item id and the 2nd number is always the quantity. each pair separated by a comma. there is always a trailing comma. I need to deconstruct these pairs and deduct the quantity from the correct item in the products table in my database. My question is, what is the best way to deconstruct these pairs?im guessing I should put these in to an array.not totally sure how to do this. any help or ideas would be great. the variable is initially set like this: $custom = $_POST['custom'];
  9. I got it working with the following code but if you have any improvements let me know. This code will always display the folder as empty. Opps.... foreach (glob('../../_documents/*.*',GLOB_NOCHECK) as $file){ $fileName = basename($file); if ($fileName = '*.*'){echo("<li>There are currently no files in this folder.</li>");break;} if ($fileName != 'index.php') {?> <li><?php echo"$fileName"?></li> <?php }//end if}//end foreach
  10. Hi, Does any one know how to display a message instead of the warning error when there are no files in the folder you are doing a directory list of? I have the following code, which produces a list of files in the folder. The only problem is when the folder is empty. I get a foreach error only when there are no files in the folder. I can forsee that sometimes the folders will be empty so will want to show my own error instead of this server warning. I think the "GLOB_NOCHECK" function may help but this may actually only work with folders rather than files. The code that works when there are files in the folder but gives a PHP warning when there are no files in the folder: foreach (glob('../../_documents/*.*') as $file){ $fileName = basename($file); if ($fileName != 'index.php') {?> <li><?php echo"$fileName"?></li> <?php } //end if}//end foreach The warning error i get if there are no files in the folder: Warning: Invalid argument supplied for foreach() in..... I would like to put the following if there is nothing in the folder: <li>There are currently no files in this folder.</li>
  11. I'm trying to set the quantity of an item in an HTML Paypal button. I'm creating the buttons dynamically using a HTML template and values from my products table in my database [php/mysql]. I know you can set the quantity of an an item in the paypal buttons you can make on the the paypal website, but I want to make the buttons dynamically and avoid this step. I have generated the rest of the button without problem - they currently have name, price, postage etc. The one thing I can't do is set the quantity of the item. So the problem at the moment is, I have a lot of one off items. I want to be able to set the quantity to 1. this way I can control whats being sold. once the item is sold I will use the Paypal IPN to update my databases stock level. At the moment the user can add more than one of the item in the paypal basket. This is a problem where there is only one item. If any one knows ho w to set the quantity of an item in an dynamically made HTML Paypal buy now button please let me know.
  12. hi Foxy, if i put: $x = glob('../../_docs/*.*');var_dump($x); the result is: bool(false)
×
×
  • Create New...