Jump to content

deved

Members
  • Content Count

    50
  • Joined

  • Last visited

Community Reputation

0 Neutral

About deved

  • Rank
    Newbie

Previous Fields

  • Languages
    html, css, php/mysql

Contact Methods

  • Website URL
    http://
  • ICQ
    0

Profile Information

  • Location
    Australia
  1. I couldn't find the answer to this anywhere, and hope it hasn't already been posted, but can you send data to the same page without the page reloading?I have a swf file that sends variables to the same page it's located in, however when sending the data the page reloads & the swf file starts from the beginning. There's about 40 stages it needs to go through with data having to be sent on each stage, and it's stuck in a loop on the first stage!!!
  2. I didn't know you could pass the information from within brackets to the function, which I assume then gets passed to the window.open command. I always thought this onclick='open_win(some_data)' had to be the same as 'function open_win(some_data)'Thanks again.
  3. This line makes the most sense to me, however I can see how your other examples work.$nr++;if($nr % $per_row == 0)Now the thumbnails are being displayed correctly, I'm trying to open the image in a new window using Javascript instead of the <a href=""></a> tag. I can pass the variable from PHP to Javascript ok, however it only opens the last image regardless of which thumbnail is clicked. Below is the revised code, where I've tried a few things (commented out), however if you prefer this thread be opened under the Javascript forum, please let me know.<?php$cat_name = $_GET['category']; echo "<h3>".$cat_name."</h3>"; echo "<table border='0px'><tr>"; $nr = 0; $per_row = 4;require('config.php'); $result = mysql_query("SELECT * FROM products WHERE prod_category = '$cat_name'"); if($row=mysql_fetch_array($result)) { do { $item = $row['prod_item']; $image = $row['prod_image']; echo "<td align='center'>"; //echo "<a href='prod_images/".$row['prod_image']."' target='_blank'>"; echo "<img class='cats' width='80px' src='prod_images/".$image."' onclick='open_win()' />"; ?> <script type="text/javascript"> //var sStr = "<?php echo $item; ?>"; var thumb = "<?php echo 'prod_images/'.$image; ?>"; //document.write(sStr); //document.write(thumb); //function open_win(){window.open(thumb)} //window.open(thumb);function open_win(){window.open(thumb,"_blank","toolbar=yes, location=yes, directories=yes, status=yes, menubar=yes, scrollbars=yes, resizable=yes, copyhistory=yes, width=300, height=300");} </script> <?php //echo "</a>"; echo "<br />" . $item; if(++$nr % $per_row == 0) echo "</td></tr>"; } while($row=mysql_fetch_array($result)); } else { echo "<p>No Results</p>"; } echo "</table>"; mysql_close(); ?>
  4. This line: if(++$nr % $per_row == 0) did the job, as well as my head in for a while.Correct me if I'm wrong, but I interpret it to work like this. The $nr value is incremented until it reaches the point where the mod says the $per_row (remainder) value is 0?Thanks heapsand thanks jlhaslip. I checked out your links and they look cool, however needed it to work with tables.
  5. Thanks for that. I'll study it and see if the grey matter still works. Cheers.
  6. Totally understand & definitely prefer to know what the code is I'm using. Somethings are a bit confusing until I've used it a few times, such as if results can be returned into an array. My code is below, and I thank you in advance.<?php$cat_name = $_GET['category']; echo "<h3>".$cat_name."</h3>"; echo "<table border='1px'><tr>";require('config.php'); $result = mysql_query("SELECT * FROM products WHERE prod_category = '$cat_name'"); if($row=mysql_fetch_array($result)) { do { $item = $row['prod_item']; echo "<td align='center'>"; echo "<a href='prod_images/".$row['prod_image']."' target='_blank'>"; echo "<img class='cats' width='100px' src='prod_images/".$row['prod_image']."' />"; echo "</a>"; echo "<br />".$item; echo "</td>"; } while($row=mysql_fetch_array($result)); } else { echo "<p>No Results</p>"; } echo "</tr></table>"; mysql_close(); ?>
  7. How do you get the result into the array?
  8. Hi jlhaslp, could you advise how you'd use a control loop?
  9. Is this valid, $item = array($row['image']);If so, I see how your code would work, except this line "if(++$nr % $per_row == 0)" is doing my head in.
  10. I'm pretty sure it's because you have two single parenthesis in the one string ie. '$_POST['updname']' instead of "$_POST['updname']". I'd assign a variable to the posted value such as: $updname = $_POST['updname'] and use the variable instead. Hope that makes sense.
  11. Hi, this is probably something really simple but I've not been able to find a solution. I'm trying to return images from a database & display them on a page in tables, but limit the results to 5 before starting a new row with the next set of 5 results. I'm using MySQL, and have tried count(), limit, etc, but I'm guessing it will be a combination of commands. Any help would be appreciated.
  12. Hard to say without seeing the database, but did you mean for the values in regemail, regid & regpass to be the same?
  13. I was a bit confused why it would return the whole page, as on another forum thread (javascript) it would return the result into an input field. Managed to fumble through and get it working somehow. Was trying to multiply the contents of field 1 (numerical) by the contents in field 2 (percentage) and have the result display in the field 3 as you enter the data in either 1st or 2nd fields.It's based on Australia's GST tax system.The rough code is below if anyone interested.Thanks for your replies, and to the Javascript forum.<html><body><script type="text/javascript">var xmlHttpfunction nettGst(str){if (str.length==0) { document.getElementById("nett").value = z.toFixed(2); return; }xmlHttp=GetXmlHttpObject();if (xmlHttp==null) { alert ("Your browser does not support AJAX!"); return; } x=(document.getElementById("total").value); y=(document.getElementById("gst").value); z=x/((100/100)+(y/100)); document.getElementById("nett").value = z.toFixed(2);xmlHttp.onreadystatechange=stateChanged;xmlHttp.open("GET",url,true);xmlHttp.send(null);} function stateChanged() { if (xmlHttp.readyState==4){ document.getElementById("nett").value=xmlHttp.responseText;}}function GetXmlHttpObject(){var xmlHttp=null;try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); }catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } }return xmlHttp;}</script><form>TOTAL: <input type="text" name="total" id="total" onKeyUp="nettGst(this.value)" />GST: <input type="text" name="gst" id="gst" value="10" onKeyUp="nettGst(this.value)" />NETT: <input readonly="readonly" id="nett" name="nett" /></form>
  14. I did try that, but maybe not correctly. Below is the code, pretty much taken straight from the tutorial but with the javascript placed in the head section as opposed to an external link.I've tried changing the innerHTML to value similar to a script used in another post that did get the value to display in a text field. Unfortunately the script required the user to hit a submit button, instead of 'live' such as AJAX.The commented html elements are the ones that work, and I've modified the php page (not shown), so I know the result is correct.<html><head><script type="text/javascript">var xmlHttp;function showAcct(str){ xmlHttp=GetXmlHttpObject();if (xmlHttp==null) { alert ("Browser does not support HTTP Request"); return; }var url="getacct.php";url=url+"?q="+str;url=url+"&sid="+Math.random();xmlHttp.onreadystatechange=stateChanged;xmlHttp.open("GET",url,true);xmlHttp.send(null);}function stateChanged() { if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { document.getElementById("txtHint").innerHTML=xmlHttp.responseText; } }function GetXmlHttpObject(){var xmlHttp=null;try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); }catch (e) { //Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } }return xmlHttp;}</script></head><body><form><input type="text" name="accounts" onKeyUp="showAcct(this.value)"></form><p><!--<p id="txtHint"></p>--><!--<div id="txtHint"></div>--><!--<span id="txtHint"></span>--><input id="txtHint" /></p></body></html>When the innerHTML is replaced with value, and the input field is given a value called "txtHint", the entire page code is returned in the input field. I'm confused.
  15. I've just started learning AJAX and this is probably a really silly question, but how do you send the response from an AJAX query to an input field? The AJAX/PHP sample scripts are great, but i've only been able to get them to return the result to a <div><span><p> field even tho the id is the same ie. <p id="txtHint"></p> works <input id="txtHint" /> doesn't.
×
×
  • Create New...