Jump to content

php_b34st

Members
  • Posts

    168
  • Joined

  • Last visited

Everything posted by php_b34st

  1. I have the following code: <script type="text/javascript"> var str="code name club price"; document.write(str.split(" ",1) + "<br />"); document.write(str.split(" ",2) + "<br />"); document.write(str.split(" ",3) + "<br />"); document.write(str.split(" ",4)); </script> Its not quite how i wanted it to output so I was wondering how i would put it into an array instead,at the moment it outputs like this: code code,name code,name,club code,name,club,price when I only wanted: code name club price is there a way to put them in an array so that i can use each element seperately?
  2. Thank you, i will look into these functions and see what outcome I can get.
  3. Thanks for the reply again, how would I get the ajax to re-evaluate the whole form? can ajax do sums? what kind of functions do i need to look intp?
  4. No lamez i know how to update just didnt know about the on duplicate key function thanks revraz I will figure out how to use that
  5. Hi, I have a table with over 1000 entries in it, I am using the following code to update the database on a weekly basis which works for any players that are currently in the database but it does not add any new players that are in the array because of the where clause however if i remove the where clause it just adds the data in again so i have 2 rows with almost identical fields, how can I update my database so that I can add new players aswell as players previously entered? foreach ($data as $listitem) { $listitem[1] = mysql_real_escape_string($listitem[1]); $query = "UPDATE playerlist SET code = '$listitem[0]', name = '$listitem[1]' , club = '$listitem[2]', price = '$listitem[3]', points = '$listitem[4]', position ='$position' WHERE code = $listitem[0]"; mysql_query($query) or die('Error, insert query failed'); echo $listitem[0] . ' ' . $listitem[1] . ' ' . $listitem[2] . ' ' . $listitem[3] . ' ' . $listitem[4].'</br>'; }
  6. why not order them as they come out of the database? SELECT * FROM websites WHERE `title` LIKE '%$keyword%' ORDER BY title;
  7. Hi, I am new to ajax and got a lot of help on this script yesterday the thread was ajax, javascript and mysql I thought a fresh topic would be best as the other one was getting a bit hard to follow. I now have a semi-working version of the script i require which can be found at http://fantasyfootball.sportsontheweb.net/formation.php To test the script use the following codes: 002 226 174 185 295 553 564 577 952 882 972 I am now having the following problems: 1. If a user enters info into all the fields and then decides they entered the wrong info in one of the boxes and changes it, the script does not remove the first player and still adds the new one 2. I would like to output all 11 fields into a mysql database at some point in the future but am having difficulties getting all 11 entries into an array so that this can be done at the same time, as the php page refreshes each time a new text field is used so does the array. Any advice/help/info would be great thanks
  8. Its late now so i will give it another try 2morro again thanks for all the help its much appreciated.
  9. Yea I can do that or I could check the team as they submit it but I was trying to get it all done instantly so if the team is approved the submit button appears if not it doesnt but an error message explaining why it wasnt approved will be displayed.
  10. Yeah thats what I am trying to do but I cant get the php to query it all at the same time unless i submit the form.
  11. I have a players database with over 1000 entries in it a user has to pick 11 of these players to form their team this script checks the db and gets all the info out for the playercode they enter once i have done all the calculations and approved the team I will add the playercodes into the teams database. No sorry I do not have the hosting yet and am just working from localhost
  12. no i dont need to update the fields i need to enter certain values into a different table
  13. yes eventually after they have checked they entered the correct team and I do some calculations in php. However I am having troubles creating an array with the relevant data.
  14. hi again, while testing further I have found a problem with the script, if a user fills in box's 1 - 5 and then releases they made a mistake in box 3 and change it, the original values stay there aswell as the new one being added. is there a way to stop this?
  15. for some reason that didnt work but instead of wrapping the div i replaced it with <table id="txtHint"></table> thanks again for all the help
  16. yes I guess I will have to add the price then send it again etc. back to the original problem when i added fullResponse=fullResponse + "</table>"; it adds </table> to the end of each row rather than only at the end of the table. i tried to add it after the function but it just missed it out completely
  17. Thanks again thats the visual side working now i just gotta do the backend. this may be harder than I originally thought as the variable values do not stay so adding all the prices together cant be done at the end of the php script. again thanks for all your help
  18. Thanks again that worked except i guess js doesnt like whitespace unlike php? also how do i add </table> to the end?
  19. Wish I could help u there but im struggling as it is, just one more question it now displays 11 tables instead of just one with 11 rows ie its showing the following for every result when i only want it showing once: <table border='1'> <tr> <th>Code</th> <th>Name</th> <th>Club</th> <th>Price</th> </tr>
  20. That works now thank you for the help
  21. I can retrieve all of the data without any of it getting cut off, my problem is that it only displays the results from the last text box used replacing what was there for the previous text box instead of listing all 11. The tutorial on w3schools was good for showing me how to do it for a single entry but doesnt go further and show info for multiple entries. thanks for your help so far
  22. It only displays the data for the info in the last input box, and to answer your previous question yes i did get it from w3cschools
  23. neither of those ways work for me. I replaced the whole function but nothing works now
  24. Ok, I am a bit closer to where i need to be: I have an index page with an input box: <html> <head> <script src="selectuser.js"></script> </head> <body> <form> <input type="text" size=6 maxlength=3 class="playername" onchange="showUser(this.value)"/> </form> <p> <div id="txtHint"><b>User info will be listed here.</b></div> </p> </body> </html> the index page calls the following javascript page to select the player: 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 || 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; } that script calls a php script to display the results: <?php $q=$_GET["q"]; $con = mysql_connect('***', '***', '***'); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("***", $con); $sql="SELECT * FROM playerlist WHERE code = '".$q."'"; $result = mysql_query($sql); echo "<table border='1'> <tr> <th>Code</th> <th>Name</th> <th>Club</th> <th>Price</th> </tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['code'] . "</td>"; echo "<td>" . $row['name'] . "</td>"; echo "<td>" . $row['club'] . "</td>"; echo "<td>" . $row['price'] . "</td>"; echo "</tr>"; } echo "</table>"; mysql_close($con); ?> That all works fine for one input box but i need to display 11 players. If i add another input box it replaces the results from the first input box rather than listing all 11 players in a table. How could I display all 11 instead of just one?
  25. Hi i posted this in the javascript section but am now led to believe that i need to use ajax for this aswell? I currently have a javascript form, a user enters codes into the form press's submit then the rest of the info is retrieved from a a mysql db using php the user is then asked if this information is correct before proceding. I would like this to be done instantly using javascript? There is 11 textfields where a user must enter the codes say when they enter the code then click the next box can the info be retrieved from the db and be displayed straight away and so on for all 11 fields? then the user just has to click submit once. thanks in advance
×
×
  • 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.