Jump to content

php_b34st

Members
  • Posts

    168
  • Joined

  • Last visited

Posts posted by php_b34st

  1. Hi,

    I am trying to loop through all of the users on my site and grab their game stats from another site to do this i am using fopen within a foreach loop, this works nicely for about 30 members but when it gets to 31 i get a time out error. Is there any way to get around this?

     

    Thanks

  2. 1. Yes I am trying to update the database the code and name will never change so i decided to update using code as the key however if there is a new name i need to insert a new row.

    So, you want it to add a new row if it has the same code but a different name?

     

    No I want to update the row if it has the same code, I want to insert a new row if there is a new code

     

    Thanks for the help I will try to use mysql_affected_rows as you suggested

  3. Sorry if I was not clear.

     

    1. Yes I am trying to update the database the code and name will never change so i decided to update using code as the key however if there is a new name i need to insert a new row.

     

    2. The problem is when i add the id auto increment column it does not update anymore it just adds new rows even if there is already a similar entry

     

    just to clarify I am adding a new column called id rather than updating the coce column so the new table will look like this:

     

    id | code | name | club | price | points

     

    and id is now the primary key rather than code (the code is a pre defined code, id will auto increment and be there for reference to other tables)

  4. I have a table in my db:

     

    code | name | club | price | points

     

    At the moment code is set as primary key so when I use the following script the table gets updated correctly:

     

    $query = "INSERT INTO playerlist (code, name, club, price, points, position) 
    		  VALUES ('$listitem[0]', '$listitem[1]', '$listitem[2]', '$listitem[3]', '$listitem[4]', '$position')
    		  ON DUPLICATE KEY UPDATE points=$listitem[4]";
    	mysql_query($query) or die('Error, insert query failed');
    

     

    however now I am trying to add an id auto increment primary key column but the above script stops working correctly as its now referencing from id rather than code. Instead of updating a previous entry it adds another. Is there a way around this?

     

    thanks

  5. I think you need something like this:

    <?php
    $con = mysql_connect("localhost","apnimusk","password");
    if (!$con)
      {
      die('Could not connect: ' . mysql_error());
      }
    
    mysql_select_db("apnimusk_naat", $con);
    
    // check to see if id is set
    if(isset($_GET['id']) && is_numeric($_GET['id']))
    {
    $id = $GET['id'];
    echo 'Your have requested ID #'.$id.'';
    echo '<a href="sadasdas.php">Back[/url]';
    $result = mysql_query("SELECT * FROM table2
        		       WHERE id=$id");
    while($row = mysql_fetch_array($result))
    {
    	echo $row['row1'];
    	echo $row['row2'];
    }
    
    }
    // no id requested, display results
    else
    {
    
    $result = mysql_query("SELECT * FROM album
    WHERE name='Timmy Mellowman'");
    
    while($row = mysql_fetch_array($result))
      {
      echo $row['name'] . " " . "<a href='?id=".$row['id']."'>".$row['age']."[/url]";
      echo "
    ";
      }
    }
    mysql_close($con);
    ?>
    

     

    but without knowing the structure of your second table I cannot help any further

  6. Yes this is possible with php. you will need to create a database like

     

    id | system | status

     

    you will need a page which will show the data, this page will simply pull all the data from the database and display it (replacing your current html file)

     

    then you will need a page with a form on it which will allow users to update the database when the status of each system changes

  7. I curently have a database with over 1000 entries in it the databse is structured as follows:

     

    code | name | club | points | price

     

    every saturday I update the database because the points for each entry changes. at the moment the points field is for total points but now i need to show weekly and monthly values.

     

    there will be 41 weeks which is 10 months in the season. The months are not necessaryily calandar months as it works on a system of every 4th week is 1 month. for example:

     

    the season started on the 16th august so

    16th august, 23rd august, 30th august and 6th september = month 1

    13th sep, 20th sep, 27th sep and 4th oct = month 2

    etc...

     

    how can I structure my database to hold the relevant data? I originally thought of just adding another column which would be week but that would mean at the end of the season the database will have over 41000 entries. Also how would I get the script to recognise which week and month it currently is to show the relevant data?

  8. Hi, after reading up on the functions you suggested I came up with the following:

     

    javascript file:

    var xmlHttp
    
    function showUser(str)
    { 
    xmlHttp=GetXmlHttpObject()
    if (xmlHttp==null)
    {
    alert ("Browser does not support HTTP Request")
    return
    }
    var url="includes/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")
    {
    var myArray = xmlHttp.responseText.split(",");
    document.getElementById("p1code").innerHTML=myArray[0]   
    document.getElementById("p1name").innerHTML=myArray[1]
    document.getElementById("p1club").innerHTML=myArray[2]
    document.getElementById("p1price").innerHTML=myArray[3]
    }
    }
    
    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;
    }

     

    php file:

    <table border="1" cellpadding="0" cellspacing="0" width="400px">
    <tr><td id="p1code"></td><td id="p1name"></td><td id="p1club"></td><td id="p1price"></td></tr>
    <tr><td id="p2code"></td><td id="p2name"></td><td id="p2club"></td><td id="p2price"></td></tr>
    <tr><td id="p3code"></td><td id="p3name"></td><td id="p3club"></td><td id="p3price"></td></tr>
    <tr><td id="p4code"></td><td id="p4name"></td><td id="p4club"></td><td id="p4price"></td></tr>
    <tr><td id="p5code"></td><td id="p5name"></td><td id="p5club"></td><td id="p5price"></td></tr>
    <tr><td id="p6code"></td><td id="p6name"></td><td id="p6club"></td><td id="p6price"></td></tr>
    <tr><td id="p7code"></td><td id="p7name"></td><td id="p7club"></td><td id="p7price"></td></tr>
    <tr><td id="p8code"></td><td id="p8name"></td><td id="p8club"></td><td id="p8price"></td></tr>
    <tr><td id="p9code"></td><td id="p9name"></td><td id="p9club"></td><td id="p9price"></td></tr>
    <tr><td id="p10code"></td><td id="p10name"></td><td id="p10club"></td><td id="p10price"></td></tr>
    <tr><td id="p11code"></td><td id="p11name"></td><td id="p11club"></td><td id="p11price"></td></tr>
    </table>
    

    original form:

    <input type="text" id="player1" name="player1" size=6 maxlength=3 class="playername" onchange="showUser(this.value)" onclick="this.select()" value="000"/>
    <input type="text" id="player2" name="player2'" size=6 maxlength=3 class="playername" onchange="showUser(this.value)" onclick="this.select()" value="000"/>
    etc for 11 input fields

     

    but the problem is all input fields output to p1 how do i get it to recognise each different id and then output to the correct place ie player1 = p1code,p1name,p1club,p1price and player2 = p2code,p2name,p2club,p2price?

  9. I do not need to add a line break I just showed that as an example, I need to be able to use each element seperately so that I can use the data in other functions which is why i thought an array would be suitable?

     

    There will be 11 different elements for code name club price I need to display these and add all the price elements to make a total price also i need to make sure the same club has not been used more than twice and the same name has not been used more than once. I have made the php script which handles this I just need javascript to pass it onto the php side.

     

    thanks again for any help

×
×
  • 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.