Jump to content

markduce

Members
  • Posts

    22
  • Joined

  • Last visited

    Never

Everything posted by markduce

  1. Hello, I'm a PHP coder, but my client is getting me out of my comfort zone by doing a bit of javascript. I've got basic functionality set up, but I'm just coming across one issue. The thing they want is a simple percentage calculator, where someone enters a value, a percentage and the site then performs calculations based on these values. It's all working fine, except when you actually physically write a percentage sign. I'm looking for some way of stripping out percentage signs. I tried the replace() function, but that just stopped the calculator working. Any advice appreciated, here's my code: function calculate() { a=Number(document.getElementById("edit-gpcalculatorcost").value); b=Number(document.getElementById("edit-gpcalculatorpercentage").value); b3=b; b2=b3/100; c=a/(1-b2); c2=Math.round(c*100)/100; c3=c2*1.2; c4=Math.round(c3*100)/100; document.getElementById("edit-gpcalculatortotal").value=c4; }
  2. Ah fair enough, I will save it to a file then just pop the file in the source for the img tags then. Thanks again for all your help, much appreciated.
  3. Thanks for your very prompt reply, fantastic knowledge about the amp thing. It's almost there now, just one last slight problem. My page is built up of a string which is then added to throughout the script and then returned at the end. So when this is outputted straight to the browser, I think it's causing the following to happen, all sorts of horrible characters at : http://www.menuanalyser.co.uk/nutritional-report/11247 My string is simply called $markup, so I tried the following: $markup.=imagejpeg($im); Any ideas how to add it on to my markup string?
  4. Fantastic, that sorted it, thank you both.
  5. Hello, I have the following image on my site, using the Google QR Code api. For reasons that I won't bore you with, I need to get this image in to a JPG format, so need to do this through PHP. The HTML output to the broswer is below <img src="http://chart.apis.google.com/chart?chs=150x150&cht=qr&chl=http://www.menuanalyser.co.uk/nutritional-report/11599" alt="QR Code" width="150" height="150"/> The actual source of the image doesn't lead to anywhere though, it only works when it's in the code on the site, you can see it working at: http://www.menuanalyser.co.uk/nutritional-report/11599 I'm at my wits end trying to find how to do this and would really appreciate any help you can offer. I thought it would be something like the following: <?php $image = imagecreatefrompng("http://chart.apis.google.com/chart?chs=150x150&cht=qr&chl=".$pathhold2."); $qrcode2=imagejpeg($image); imagedestroy($image); ?> However, this throws out an error message because it can't find a PNG at that address. Any advice much appreciated
  6. Hello, This one's causing me to tear my hair out, so I'd be very grateful of any help/ So the img align attribute is deprecated nowadays right? Well I have a load of images in a table, where everything but the images is aligned to the center using css text-align. I want the images to be centrally aligned too. Well, I don't really mind, but the client thinks it's really important.... I've tried adding float:none style to the images but that had no effect, anyone got any ideas? To see the images in place, they are in the table in the link below with all the ticks and crosses. http://www.menuanalyser.co.uk/chef-recipe-costing Any advice much appreciated Regards Mark
  7. PS. Is there a way that I can mark this as solved or do moderators do that?
  8. Hello, I need to be able to find what is inbetween 2 values in a string of text. For example, <?php $string="Hello and welcome to the site. Click [link]welcome.php[/link] here to continue to the site"; ?> So I need some method of searching the string to see what values are in between the [link] and [/link] which I will then deal with in my own way. I have a feeling that I could do this with explode, but I'm not really sure. Any advice? Thanks in advance
  9. Sorry yes it was line 232, just a typo on my part... Am trying that solution offered, thanks, will let you know how it goes..
  10. You would certainly have to use javascript for that I would think Here's a little tutorial that you might find useful... http://support.internetconnection.net/CODE_LIBRARY/Javascript_Show_Hide.shtml
  11. Hi, I haven't asked for help on here in a long time since I was a wee little noob but am in need at moment! I have a lot of scripts using $_GET variables. However, I have recently moved to a new server with PHP5 on, and this seems to be causing problems, for whenever I use the line to retrieve my get variables I get the following error message : Notice: Undefined index: page in /home/blah/blah/forum.php on line 232 Now on line 32 I have $page=$_GET['page']; I thought this was just a standard use of PHP to get the page that I needed, does anyone have any advice how I can counter these error messages? And I can't turn register globals on by the way, my damn hosts won't let me!
  12. OK, I have all the details about a point in time, I am just unsure how to turn it all into a Unix timestamp. Can anyone help me out? <? $day="02"; $month="04"; $year="2006"; $hours="09"; $mins="50"; ?> Thanks in advance
  13. OK, just use the str_replace function (string replace) as follows: <? $message=$_POST['message']; // OR WHATEVER YOUR MESSAGE VARIABLE IS $message=str_replace(';sad;', '<image src="sad.gif" alt=sad>', $message); ?> Hope that helps Mark
  14. $firstname="Mark"; $middlename="David"; $lastname="Duce"; $times=100; $x=1; echo "<table><tr><th>Age</th><th>First Name</th><th>Surname</th></tr>"; while ($x<$times) { $countfirst=mysql_num_rows(mysql_query("SELECT * FROM members WHERE firstname='$firstname'")); $countmiddle=mysql_num_rows(mysql_query("SELECT * FROM members WHERE middlename='$middlename'")); $countsecond=mysql_num_rows(mysql_query("SELECT * FROM members WHERE lastname='$lastname'")); echo "<tr><td>".$x."</td><td>"; echo "".$countfirst."</td><td>".$countmiddle."</td><td>".$countsecond."</td></tr>"; $x++; } echo "</table>";
  15. Hi, I am quite experienced in PHP now, so I dont need help actually doing this, more just deciding what method to use. I want a basket system similar to most e-commerce sites. However, would I be best storing the contents of the basket in a MySQL database and then pulling them out for use? Or would you reccomend using sessions/cookies to remember the data? Or does anyone have any other suggestions? I am open minded at the moment. Thanks for your advice in advance. Mark
  16. Hi, Yes, you can create a list of master variables. Say you set up a file called mastervariables.php and put it in the same folder as me.php. Then list your variables in there eg <?php $variable1="hello"; $variable2="hello2"; ?> Then on me.php, simply include the file with the following code: <?php include ("mastervariables.php"); ?> Hope that helps Mark
  17. Hi guys, Heres the situation, my client wants a search facility on the site. I can do this OK, but the problem that I am finding is that as I am searching a database, I have to type every single field in. eg "SELECT * FROM table WHERE name LIKE '%$search%' OR comment LIKE '%$search%'"; However, there are 25 fields on this table, and many more thousands on the other tables, so is it possible to search a row rather than a specific column? Thanks in advance Mark
  18. Hi, I think I see what you mean, but post back if I am incorrect. You could use the mysql_num_rows function to count how many votes you have. $result=mysql_query("SELECT * FROM poll_answers WHERE question_id='$qid"); $number1=mysql_num_rows($result); $result2=mysql_query("SELECT * FROM members_poll_answers WHERE question_id='$qid"); $number2=mysql_num_rows($result2); $total=$number1+$number2; Is that what you mean?
  19. I have been away for a bit, but I would suggest that you use smarter language when replying, because those people that replied to you were certainly not wrong.
×
×
  • 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.