Jump to content

mrt003003

Members
  • Posts

    174
  • Joined

  • Last visited

    Never

Posts posted by mrt003003

  1. Hmm is there no way to do it in php alone? Something like:

     

    $countdown = '300' 
    
    if ($countdown == '0'){
    
    if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
      $updateSQL = sprintf("UPDATE table SET something = '1'");
    
      mysql_select_db($database_swb, $swb);
      $Result1 = mysql_query($updateSQL, $swb) or die(mysql_error());  }?>

     

    Thanks

  2. Hi there i was wondering if its possible to have a count down timer (for say 5 mins) that when it reaches 0 a form is updated..

     

    <?php
    // set countdown timer for 5 mins 
    $countdown = '300' 
    
    if ($countdown == '0'){
    
    update the form somehow? }?>
    
    
    <form id="form1" name="form1" method="POST" action="<?php echo $editFormAction; ?>">
    <input name="hiddenField" type="hidden" value="<?php echo $row_query['somedata']; ?>" />
    <input type="submit" name="Submit" value="Submit" />
    </form>

     

    I'm a bit of a noob so any help would be ace.

     

    Thanks :)

  3. Ive just spotted something that truely doesnt make sense, now my outputted random numbers are random but are only ever either 2 or 3??? There are 3 records that could be randomised (2,3,4) but only ever 2 and 3 are outputted. Why are 4's not being used??

     

    Infact the outputed numbers are only ever: 2,3 or 2,2. The first number is always a 2?? Its as if the limit of 2 is stopping the array from using all the avaliable ShipIDs and only allowing the first 2.

     

    Oh man im confussed :(

     

    Thanks

  4. Hi there, im really stuck here. I have a table of records that are selected from my db and put into an array and randomly chooses them, outputting the results .

     

    <?php 
    $count = 0;
    while ($row = mysql_fetch_assoc($Ships4)){
    $array[$count]['ShipID'] = $row['ShipID'];
    $array[$count]['ShipName'] = $row['ShipName'];
    $array[$count]['Dclass'] = $row['Dclass'];
    $count++;
    
    $total4 = count($array);
    $random4 = rand(0,$total4 - 1);
    $random_ship4 = $array[$random4];
    $ShipID4 = $random_ship4['ShipID'];
    echo $ShipID4;}

     

    This all works fine, however I want to limit the number of random outputs from a number in a record in a different table.

     

    So i added:

     <?php
    if ($count < $row_dclasscorella['Dclass4_totla']){ ?>

    the number from the field is 2.

     

    The trouble is that it doesnt take any notice and outputs the total number a random number for each record. It seems its not limiting it. How can i get this to work please???

     

    $count = 0;
    if ($count < $row_dclasscorella['Dclass4_totla']){
    while ($row = mysql_fetch_assoc($Ships4)){
    $array[$count]['ShipID'] = $row['ShipID'];
    $array[$count]['ShipName'] = $row['ShipName'];
    $array[$count]['Dclass'] = $row['Dclass'];
    $count++;
    
    $total4 = count($array);
    $random4 = rand(0,$total4 - 1);
    $random_ship4 = $array[$random4];
    $ShipID4 = $random_ship4['ShipID'];
    echo $ShipID4;}}?>

     

    Thank You :)

  5. Hi there im trying to modify my php code to add a javaa script link that plays an audio file. The java script works fine with just html:

     

    <script type="text/javascript">
    var channel_max = 10;										// number of channels
    audiochannels = new Array();
    for (a=0;a<channel_max;a++) {									// prepare the channels
    	audiochannels[a] = new Array();
    	audiochannels[a]['channel'] = new Audio();						// create a new audio object
    	audiochannels[a]['finished'] = -1;							// expected end time for this channel
    }
    function play_multi_sound(s) {
    	for (a=0;a<audiochannels.length;a++) {
    		thistime = new Date();
    		if (audiochannels[a]['finished'] < thistime.getTime()) {			// is this channel finished?
    			audiochannels[a]['finished'] = thistime.getTime() + document.getElementById(s).duration*1000;
    			audiochannels[a]['channel'].src = document.getElementById(s).src;
    			audiochannels[a]['channel'].load();
    			audiochannels[a]['channel'].play();
    			break;
    		}
    	}
    }
    </script>
    
    <audio id="multiaudio1" src="Music/reb.wav" preload="auto"></audio>
    <audio id="multiaudio2" src="Music/emp.wav" preload="auto"></audio>
    
    <a href="javascript:play_multi_sound('multiaudio1');">audio1</a><br />
    <a href="javascript:play_multi_sound('multiaudio2');">audio2</a><br />

     

    But when i modify my existing php hyperlink:

     echo '<a href="http://localhost/swb/fleet.php?recordID='.$row_Fleet['FleetName'].'"> <IMG SRC="',$pic1,'" WIDTH="12" HEIGHT="10" BORDER="0" ALT="" CLASS="fmoncalamari"></a>';

     

    to:

     

    echo '<a href="http://localhost/swb/fleet.php?recordID='.$row_Fleet['FleetName'].'" onclick="play_multi_sound(\'multiaudio1\');"> <IMG SRC="',$pic1,'" WIDTH="12" HEIGHT="10" BORDER="0" ALT="" CLASS="fmoncalamari"></a>';

     

    then the hyperlink and parsed id works fine but the audio doesnt at all?

     

    Please help

     

    Thank you

  6. No the audio doesnt work on mouseover or hover, it was meant to only sound when clicked and it works when it is in just html:

     

    <a href="javascript:play_multi_sound('multiaudio1');">Sound1</a>

     

    Just trying to modiy the existing php hyperlink with it, is when it doesnt work. :(

     

  7. Thanks for the reply, when i do it this way the hyperlink and parsed id works fine but the audio doesnt work.

     

    Heres the code im using:

     

    <script type="text/javascript">
    var channel_max = 10;										// number of channels
    audiochannels = new Array();
    for (a=0;a<channel_max;a++) {									// prepare the channels
    	audiochannels[a] = new Array();
    	audiochannels[a]['channel'] = new Audio();						// create a new audio object
    	audiochannels[a]['finished'] = -1;							// expected end time for this channel
    }
    function play_multi_sound(s) {
    	for (a=0;a<audiochannels.length;a++) {
    		thistime = new Date();
    		if (audiochannels[a]['finished'] < thistime.getTime()) {			// is this channel finished?
    			audiochannels[a]['finished'] = thistime.getTime() + document.getElementById(s).duration*1000;
    			audiochannels[a]['channel'].src = document.getElementById(s).src;
    			audiochannels[a]['channel'].load();
    			audiochannels[a]['channel'].play();
    			break;
    		}
    	}
    }
    </script>
    
    <audio id="multiaudio1" src="Music/reb.wav" preload="auto"></audio>
    <audio id="multiaudio2" src="Music/emp.wav" preload="auto"></audio>
    
    <?php echo '<a href="http://localhost/swb/fleet.php?recordID='.$row_Fleet['FleetName'].'" onclick="play_multi_sound(\'multiaudio1\');"> <IMG SRC="',$pic1,'" WIDTH="12" HEIGHT="10" BORDER="0" ALT="" CLASS="fmoncalamari"></a>'; ?>
    

     

    Ive tested the javascript independantly and it works fine... Its just not working with the php. Am i missing something??

     

    Thanks :)

     

  8. Hi there im having real trouble trying to combine a php echo hyperlink with a javascript link. Is this possible?? 

     

    Heres my echoed link:

    <?php echo '<a href="http://localhost/swb/fleet.php?recordID='.$row_Fleet['FleetName'].'"> <IMG SRC="',$pic1,'" WIDTH="12" HEIGHT="10" BORDER="0" ALT="" CLASS="fmoncalamari"></a>'; ?>

     

    Heres the Javascipt:

     

    <a href="javascript:play_multi_sound('multiaudio1');">Flute</a>

     

    Ive been trying combine the two so it will hopefullly then hyperlink an image and play an audio file. Its not working :(

     

    <?php echo '<a href="http://localhost/swb/fleet.php?recordID='.$row_Fleet['FleetName'].' javascript:play_multi_sound('multiaudio1');"> <IMG SRC="',$pic1,'" WIDTH="12" HEIGHT="10" BORDER="0" ALT="" CLASS="fmoncalamari"></a>'; ?>

     

    Im really new to Javascript and so any ideas on how i can combine them would be ace

     

    Thank you. :)

  9. Hi there im just trying to understand how to compare and output results in a table. For example lets say i have the following table:

     

    Beans

    ID

    Type

    Location

     

    And say 3 records:

     

    1

    Baked

    kitchen

     

    2

    Runners

    Garage

     

    3

    Broad

    Kitchen

     

    I want to select only the beans that have matching locations and output the Type: Baked, Broad.

     

    I'm trying to get my head around how to work this out, if you could nudge me in the right direction that would be excellent.

     

    Thank you. :)

  10. Hi there im just trying to understand how to compare and output results in a table. For example lets say i have the following table:

     

    Beans

    ID

    Type

    Location

     

    And say 3 records:

     

    1

    Baked

    kitchen

     

    2

    Runners

    Garage

     

    3

    Broad

    Kitchen

     

    I want to select only the beans that have matching locations and output the Type: Baked, Broad.

     

    I'm trying to get my head around how to work this out, if you could nudge me in the right direction that would be excellent.

     

    Thank you. :)

     

     

  11. What am i chatting about... It doesnt work at all. It gives me mental results. Infact when i echo out the 2nd query here it outputs a FleetName that has the same PlayerName as the logged in session username. Which is completely nuts! Furthermore i need to cater for th fact that their maybe more than one FleetE on the same PlanetName as Fleet. Jeees im lost. :(

  12. FLEET TABLE

    FleetName

    PlanetName

    Detected

    PlayerName

     

    The first query Fleet searches the table where the FleetName equal to a url parsed parameter from a previous page.

     

    <?php $colname_Fleet = "-1";
    if (isset($_GET['recordID'])) {
      $colname_Fleet = (get_magic_quotes_gpc()) ? $_GET['recordID'] : addslashes($_GET['recordID']);
    }
    mysql_select_db($database_swb, $swb);
    $query_Fleet = sprintf("SELECT * FROM fleet WHERE FleetName = %s", GetSQLValueString($colname_Fleet, "text"));
    $Fleet = mysql_query($query_Fleet, $swb) or die(mysql_error());
    $row_Fleet = mysql_fetch_assoc($Fleet);
    $totalRows_Fleet = mysql_num_rows($Fleet); ?>

     

    The second query FleetE searches the same table for the all the Fleets where the playername is NOT equal the session username (playername) AND is equal to PlanetName of the previous query Fleet.

     

    <?php $colname_PlanetName = $row_Fleet['PlanetName'];
    
    $colname_FleetE = "-1";
    if (isset($_SESSION['MM_Username'])) {
      $colname_FleetE = (get_magic_quotes_gpc()) ? $_SESSION['MM_Username'] : addslashes($_SESSION['MM_Username']);
    }
    mysql_select_db($database_swb, $swb);
    $query_FleetE = sprintf("SELECT FleetName, PlanetName FROM fleet WHERE PlayerName <> %s AND PlanetName=%s", GetSQLValueString($colname_FleetE, "text"),GetSQLValueString($colname_PlanetName, "text"));
    $FleetE = mysql_query($query_FleetE, $swb) or die(mysql_error());
    $totalRows_FleetE = mysql_num_rows($FleetE);
    ?>

     

    The idea is that all FleetE records are compared with the single Fleet record matching the PlanetName. So if the PlanetName of any FleetE record is the same as the PlanetName in the single Fleet record then i want it to output the single FleetName of the Fleet record. Before i added the $blnMatch variable it would output the same FleetName however many times as there are records in the FleetE query.

     

    <?php 
    $blnMatch = false;
      while($row_FleetE = mysql_fetch_assoc($FleetE) && (!$blnMatch)){
    
    if ($row_FleetE['PlanetName'] == $colname_PlanetName){
               $blnMatch = true;
       echo $row_Fleet['FleetName'];
       echo' ';
    }} ?>

     

    I hope ive explained well enough.

     

    Thanks

  13. Hi there thanks for the reply, ive tested it and get a wierd error ive never seen before: Notice: Use of undefined constant blnMatch - assumed 'blnMatch' in C:\wamp\www\SWB\fleet_edit.php on line 269

     

    <?php 
    $blnMatch = false;
         while(($row_FleetE = mysql_fetch_assoc($FleetE) && (!blnMatch)){
    
    if ($row_FleetE['PlanetName'] == $colname_PlanetName){
               $blnMatch = true;
       echo $row_Fleet['FleetName'];
       echo' ';
    }} ?>

     

    I had to remove one of the braces on left of th while else it would error: Parse error: syntax error, unexpected '{' in C:\wamp\www\SWB\fleet_edit.php on line 269

    I cant see the problem with {.

     

    I also wondered if it could be ! infrom of the blnMatch on the right of the while loop. If i removed the ! id get many errors: Notice: Use of undefined constant blnMatch - assumed 'blnMatch' in C:\wamp\www\SWB\fleet_edit.php on line 269

     

    That would be outputted as many times as their are records that are being searched in the while loop.

     

    Its close i can feel it in my bones. What would you suggest please??

     

    Thanks

     

     

  14. Ive been playing with the code and found that the first query only need select a single record from its ID:

    <?php 
    $colname_Fleet = "-1";
    if (isset($_GET['recordID'])) {
      $colname_Fleet = (get_magic_quotes_gpc()) ? $_GET['recordID'] : addslashes($_GET['recordID']);
    }
    mysql_select_db($database_swb, $swb);
    $query_Fleet = sprintf("SELECT * FROM fleet WHERE FleetName = %s", GetSQLValueString($colname_Fleet, "text"));
    $Fleet = mysql_query($query_Fleet, $swb) or die(mysql_error());
    $row_Fleet = mysql_fetch_assoc($Fleet);
    $totalRows_Fleet = mysql_num_rows($Fleet);
    
    
    $colname_PlanetName = $row_Fleet['PlanetName'];
    
    $colname_FleetE = "-1";
    if (isset($_SESSION['MM_Username'])) {
      $colname_FleetE = (get_magic_quotes_gpc()) ? $_SESSION['MM_Username'] : addslashes($_SESSION['MM_Username']);
    }
    mysql_select_db($database_swb, $swb);
    $query_FleetE = sprintf("SELECT FleetName, PlanetName FROM fleet WHERE PlayerName <> %s AND PlanetName=%s", GetSQLValueString($colname_FleetE, "text"),GetSQLValueString($colname_PlanetName, "text"));
    $FleetE = mysql_query($query_FleetE, $swb) or die(mysql_error());
    $totalRows_FleetE = mysql_num_rows($FleetE);
    
    <?php while ($row_FleetE = mysql_fetch_assoc($FleetE)){
    
    if ($row_FleetE['PlanetName'] == 'Mon Calamari'){
    echo $row_Fleet['FleetName'];
    echo' ';
    }} ?>
    

     

    This way it works! However it outputs the same $row_Fleet['FleetName'] as many times as it checks each of the FleetE records.

     

    So my question has changed to: How can i limit the number of outputs to a single one???

  15. Hi there im not quite sure where im going wrong here.

     

    I have 2 queries; the first selects all records in a table == Session username. The second selects all records in a table <> Session username

     

    Both work independently but when i try to compare a field in each table (The: PlanetName) it doesnt work. Im trying to make it so that if the same PlanetName is in  the first query and the second in any of the records it will output an ID.

     

    <?php $colname_Fleet = "-1";
    if (isset($_SESSION['MM_Username'])) {
      $colname_Fleet = (get_magic_quotes_gpc()) ? $_SESSION['MM_Username'] : addslashes($_SESSION['MM_Username']);
    }
    mysql_select_db($database_swb, $swb);
    $query_Fleet = sprintf("SELECT FleetName, PlanetName FROM fleet WHERE PlayerName = %s", GetSQLValueString($colname_Fleet, "text"));
    $Fleet = mysql_query($query_Fleet, $swb) or die(mysql_error());
    $totalRows_Fleet = mysql_num_rows($Fleet);
    
    $colname_FleetE = "-1";
    if (isset($_SESSION['MM_Username'])) {
      $colname_FleetE = (get_magic_quotes_gpc()) ? $_SESSION['MM_Username'] : addslashes($_SESSION['MM_Username']);
    }
    mysql_select_db($database_swb, $swb);
    $query_FleetE = sprintf("SELECT FleetName, PlanetName FROM fleet WHERE PlayerName <> %s", GetSQLValueString($colname_FleetE, "text"));
    $FleetE = mysql_query($query_FleetE, $swb) or die(mysql_error());
    $totalRows_FleetE = mysql_num_rows($FleetE);
    
    
    
    while ($row_FleetE = mysql_fetch_assoc($FleetE) && $row_Fleet = mysql_fetch_assoc($Fleet)){
    
    if($row_Fleet['PlanetName'] == $row_FleetE['PlanetName']){
    echo $row_Fleet['FleetName'];
    echo' ';
    }}
    ?>

     

    Any help would be appreciated.

     

    Thanks :)

  16. Hi there i have an array that catches all appropriate records from my database and selects a random row which is then outputted as a hyperlink.

     

    $colname_Class3 = "3";
    $colname_Ships3 = "-1";
    if (isset($_SESSION['MM_Username'])) {
      $colname_Ships3 = (get_magic_quotes_gpc()) ? $_SESSION['MM_Username'] : addslashes($_SESSION['MM_Username']);
    }
    mysql_select_db($database_swb, $swb);
    $query_Ships3 = sprintf("SELECT * FROM ships WHERE PlayerName = %s AND Class=%s AND Template='1'", GetSQLValueString($colname_Ships3, "text"),
    GetSQLValueString($colname_Class3, "int"));
    $Ships3 = mysql_query($query_Ships3, $swb) or die(mysql_error());
    $totalRows_Ships3 = mysql_num_rows($Ships3);
    
    $count = 0;
    while ($row = mysql_fetch_assoc($Ships3)){
    $array[$count]['ShipID'] = $row['ShipID'];
    $array[$count]['ShipName'] = $row['ShipName'];
    $array[$count]['Class'] = $row['Class'];
    $count++;
    }
    
    $total3 = count($array3);
    $random3 = rand(0,$total3 - 1);
    $random_ship3 = $array3[$random3];
    $ShipID3 = $random_ship3['ShipID'];
    $url3 = '<a href="add_ship.php?recordID='.$ShipID3.'">Test3</a>';
    echo '<span style="color: #009900">';
    echo $url3;}
    

     

    This all worked fine until i added another similar query:

    $colname_Class4 = "4";
    $colname_Ships4 = "-1";
    if (isset($_SESSION['MM_Username'])) {
      $colname_Ships4 = (get_magic_quotes_gpc()) ? $_SESSION['MM_Username'] : addslashes($_SESSION['MM_Username']);
    }
    mysql_select_db($database_swb, $swb);
    $query_Ships4 = sprintf("SELECT * FROM ships WHERE PlayerName = %s AND Class=%s AND Template='1'", GetSQLValueString($colname_Ships4, "text"),
    GetSQLValueString($colname_Class4, "int"));
    $Ships4 = mysql_query($query_Ships4, $swb) or die(mysql_error());
    $totalRows_Ships4 = mysql_num_rows($Ships4);
    
    $count = 0;
    while ($row = mysql_fetch_assoc($Ships4)){
    $array[$count]['ShipID'] = $row['ShipID'];
    $array[$count]['ShipName'] = $row['ShipName'];
    $array[$count]['Class'] = $row['Class'];
    $count++;
    }
    
    $total4 = count($array4);
    $random4 = rand(0,$total4 - 1);
    $random_ship4 = $array4[$random4];
    $ShipID4 = $random_ship4['ShipID'];
    $url4 = '<a href="add_ship.php?recordID='.$ShipID4.'">Test4</a>';
    echo $url4;}
    

     

    On first look it seems fine, however once the page is refreshed the parsed recordID's both become the same number,

    e.g: Test3 recordID 8 Test4 recordID 24

    then after refreshed: Test3 recordID 24 Test4 recordID 24

     

    Is there anything wrong with my code??

     

    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.