Jump to content

unistake

Members
  • Posts

    445
  • Joined

  • Last visited

Everything posted by unistake

  1. also the getuser.php script is <?php $q=$_GET["q"]; include("login.inc"); mysql_select_db("$database", $con); $sql="SELECT * FROM bookmakers WHERE bookmaker = '".$q."'"; $result = mysql_query($sql); while($row = mysql_fetch_array($result)) { echo $row['bookmaker']; echo $row['bonus']; } ?>
  2. This is the full PHP code that is included in another PHP page that contains <script type="text/javascript" src="selectuser.js"></script> the above javascript works as it should when using it with just a HTML version of the select box below. The full PHP code is here // included PHP code //// <?php $con = mysql_connect('localhost', 'user', 'password'); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("db", $con); $sql="SELECT * FROM bookmakers"; $result = mysql_query($sql); echo " <select name='users' style='margin-left:-10px; padding:7px; width:270px; height:40px; background-color:#C0DB5A; border:2px solid #888888; font-size:16px;'> <option>1. select...</option>"; while ($row = mysql_fetch_assoc($result)) { extract($row); echo "<option value='$bookmaker' onClick=\"showUser(this.value)\">$bookmaker</option>"; } echo "</select>"; ?> /// main.php // <?php include("selectoption.php"); ?> <div id="txtHint"><p>select an option from above</div> // JavaScript Document var xmlhttp; function showUser(str) { xmlhttp=GetXmlHttpObject(); if (xmlhttp==null) { alert ("Browser does not support HTTP Request"); return; } var url="getuser.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) { document.getElementById("txtHint").innerHTML=xmlhttp.responseText; } } function GetXmlHttpObject() { if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari return new XMLHttpRequest(); } if (window.ActiveXObject) { // code for IE6, IE5 return new ActiveXObject("Microsoft.XMLHTTP"); } return null; }
  3. Hi all, I have a select box that works fine in normal html if i list the mysql values by hand, however when I try to get the values from a mysql database using the code below, the script DOES NOT work in IE and some other browsers, however it DOES work in Mozilla. Do you know where I have gone wrong? Thanks <?php echo " <select name='users' style='margin-left:-10px; padding:7px; width:270px; height:40px; background-color:#C0DB5A; border:2px solid #888888; font-size:16px;'> <option>1. select...</option>"; while ($row = mysql_fetch_assoc($result)) { extract($row); echo "<option value='$bookmaker' onClick=\"showUser(this.value)\">$bookmaker</option>"; } echo "</select>"; ?> p.s - when testing any website script, what browser is best to use? I use mozilla, however I am not sure if this is right because of problems like above!
  4. Hi all, I was wondering whether a pop-up window could include a code where the pop-up would always remain on top of any other open internet window. I have an application with information giving instructions on what to do on other websites - I thought instead of switching back and forth between the instructions and the website, why not just have it on top of the page so they can move it about. Any help would be greatly appreciated!
  5. thanks, but that has not solved it!
  6. i was trying to edit the above! - just to say that the rest of the code works in PHP just not the above.
  7. Hi all, I have a bit of a problem getting a code to work. The code I have is part of a calculator which works great in a .html page however when I put it in to echo "the calculator"; the outcome never happens. I suspect I have gone wrong by replacing all the " with ' instead of using \" somewhere along the way. The code I am trying to get working is: <?php echo " <form name='calcform'> <label> <input name='box1' type='text' id='num' value='4'> </label> <label> <input type='radio' name='radio' id='radio' onClick='calculator('qualifier', 'result');'> qualifer </label>"; ?> Thanks
  8. hi Keith, thanks for the help. I think you were right, that code you gave me did not correct it. I also checked the page source and it is showing the � symbol instead of the £ sign. Is that what you were talking about? Thanks
  9. the issue with using htmlspecialchars, and mysql database data. Please dont try to be smart! If you dont know the answer then leave it!
  10. It seems to work fine! Howcome though?!
  11. Thanks MadTechie, sorry about the problem, I didnt realise that I posted an old script for that last one, I have solved the problem using, <?php $q=$_GET["q"]; include("login.inc"); $con = mysql_connect('localhost', 'user', 'password'); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("database", $con); $sql="SELECT * FROM table WHERE column = '".$q."'"; $result = mysql_query($sql); while($row = mysql_fetch_array($result)) { echo $row['details']; } ?> Thanks for all your help
  12. I have also changed the script of getoptions.php to <?php $q= $_GET["q"]; include("goatlogin.inc"); $sql="SELECT * FROM bookmakers WHERE bookmaker = $q" or die ("cant do \$sql"); $result = mysqli_query($cxn,$sql) or die ("Can't execute \$result!"); //// THIS IS WHAT IS SHOWN AS THE OUTPUT //// while($row = mysqli_fetch_array($result)) { echo $row['details']; } ?> The login.inc and the mysql table and fields are correct also, as I have double and triple checked them!
  13. I have replaced the echo $details with echo $row['FieldNames']; and also took out the extract($row) however the script is still showing a blank output.
  14. Whoops sorry! Topic re-opened! The $q was showing the correct output from the database, however i also want to echo more information from the database using this code in the getoption.php <?php $q= $_GET["q"]; echo $q; // <-------------- this output is shown //////////////////////////////////////// include("login.inc"); $sql="SELECT * FROM database WHERE column = '".$q."'"; $result = mysqli_query($sql); while($row = mysqli_fetch_array($result)) extract($row); { echo $details; } ?> any more suggestions? Thanks
  15. Hey MadTechie you are a legend! Thanks for the quick response and the eye for detail! Took me two goes to find the change you made in the code above! The time 01:14 is no excuse! Cheers Tim
  16. Hi Vineld, In the form.php i changed the $value in this code <option value='$value' name='$value' onClick='showUser(this.name)'>$value</option>"; to a fixed field value in the mysql database and the output was again 'undefined'. I also removed the quotes as you said.
  17. Hi Corbin, thanks for the reply. I have changed the JS as you said, and have tried going to the getoption.php directly, but there is no output at all, i am not sure what I was to expect when I went to it. Is a blank screen the output I was meant to see!? Thanks
  18. Hi all, I have a problem with the linking of some scripts. Basically I have a drop down list in a form on page form.php, when an option is clicked there is a onClick='showUser(this.name)'. This is sent to the function on the page selectoption.js. The javascript then takes the name value from the option and SHOULD send it to another PHP page called, getoption.php, then this option value is used to get data from a mysql DB and echo an output, that is incuded within a div tag in the initial form.php page! The whole script works, except the passing of the option name value 'showUser(this.name)' as as I try to echo the value it says "unverified". The scripts I have are... form.php <head> <script type="text/javascript" src="selectoption.js"></script> </head> <body> <?php include("login.inc"); $query = "SELECT * FROM database"; $result = mysqli_query($cxn,$query) or die ("Can't execute query!"); echo "<label> <select name='books' id='books'>"; while ($row = mysqli_fetch_assoc($result)) { extract($row); echo "<option value='$value' name='$value' onClick='showUser(this.name)'>$value</option>"; } echo "</select> </label>"; ?> <div id="txtHint"></div> selectoption.js var xmlhttp; function showUser(str) { xmlhttp=GetXmlHttpObject(); if (xmlhttp==null) { alert ("Browser does not support HTTP Request"); return; } var url="getoption.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) { document.getElementById("txtHint").innerHTML=xmlhttp.responseText; } } function GetXmlHttpObject() { if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari return new XMLHttpRequest(); } if (window.ActiveXObject) { // code for IE6, IE5 return new ActiveXObject("Microsoft.XMLHTTP"); } return null; } getoption.php <?php $q=$_GET["q"]; echo "$q"; ?> Thanks for you help and time. Tim
  19. ok thanks for that, i will bear it in mind . What is the alternative to pop-ups, new windows?
  20. <head> <script> function DoNav(theUrl) { document.location.href = theUrl; window.open(theUrl, 'newwindow'); } </script> </head> <body> <? $cxn = mysqli_connect($host, $user, $password, $database) or die ("cant connect to the database"); $query = "SELECT * FROM database"; $result = mysqli_query($cxn,$query) or die ("Can't execute query!"); echo "<table width='900' cellspacing='0' cellpadding='10'>"; while ($row = mysqli_fetch_assoc($result)) { extract($row); $details = htmlspecialchars($details); echo "<tr onclick=\"DoNav('$link');\"> <td><img src='images/bmks/$name.jpg' width='100' height='30' /></td> <td class='display'>$name</td> <td class='display'>£$price</td> <td class='display'>$minodds</td> <td class='display'>$sr</td> <td class='display'>$pf</td> [size=4] <td class='display'>$details</td>[/size] </tr>"; } echo "</table>"; ?> </body> Thanks
  21. Thanks haku, so if anyones has a popup blocker, the link will not open at all? If this is the case, they get a message dont they if a popup is trying to execute?
  22. I am still having trouble to get this to work. The field in mysql is accessed with php and the variable being $details. It is a VARCHAR (100 length) and can include text along with a price with the sterling symbol. When i come to echo the $details it comes up with a � symbol. I have tried $details = htmlspecialchars($details); and then echoing $details in php, but i am not sure that is how to use the htmlspecialchars in this particular case??? Can anyone show me how to use it ? Thanks Tim
  23. Hi all, cant seem to find such a tutorial for this. I have a simple script: <script> function DoNav(theUrl) { document.location.href = theUrl; } </script> and this inside a html table <tr onclick=\"DoNav('$link');\" title='Click here'> The $link is an external website link. All I want is to open the link in a blank window - preferably a new tab. Please show me where to put target='_blank'. Thanks Tim
  24. thanks mjdamato, really appreciate it. I agree with your learning comment, and I thought of that when I was asking for the IF/ELSE statement! but this particular script I have been trying to figure out for over a week this script so i resorted back to what I know! Thanks
×
×
  • 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.