Jump to content

mrt003003

Members
  • Posts

    174
  • Joined

  • Last visited

    Never

Posts posted by mrt003003

  1. Hi there I have a parent window that if certain php conditions are met it echos a child window.

     

    if ...... php condition.....{
    echo "<script type='text/javascript'>";
    echo " window.open('http://localhost/swb/events.php','new_window1','status=1,scrollbars=1,resizable=0,menu=no,width=1000,height=800');";
    echo "</script>"; }

     

    After the child window is created the user then uses that window on various different pages within it. I want to make it that when the child window closes the parent page is then refreshed (And if again the php conditions have been meet the child window will be echoed again).

     

    The trouble is that the user navagates over various pages within the child window.

     

    Can you help me please because im quite stuck.

     

    Thank you :)

  2. Hi there i have a parent window that on a php event will open a new child window. This child window is used over various pages and then navigates back to the original page in the child window and thats the problem. Ive got it working so that indeed the parent window does refresh but everytime i use the child window to navigate to another page. I need to be able to do the stuff on the pages in the child window and then go back to the same start page in the child window and close and refersh.

     

    Im probably not making much sense..

     

    Thanks :)

  3. The error is: 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'f LEFT JOIN Ships s ON (f.FleetID = s.FleetID) WHERE s.FleetID IS NULL' at line 2

    Thanks :)

  4. Hi there,

     

    Im trying to delete a record from one table where the id of that table is not used in the 2nd table. I can get it to work fine with a select but not as a delete:

     

    SELECT *
      FROM Fleet f
    LEFT JOIN Ships s ON (f.FleetID = s.FleetID)
    WHERE s.FleetID IS NULL

     

    This works fine but if i try to delete

     

    DELETE *
      FROM Fleet f
    LEFT JOIN Ships s ON (f.FleetID = s.FleetID)
    WHERE s.FleetID IS NULL

     

    It gives me a mysql error??

     

    Any ideas??

     

    Thanks :)

  5. Hi there,

     

    I was wonderin if its possible to create a select query from one table thats Where clause is determinded from another table. For example my 2 tables are: Structures and Planetstructures. Structures holds the structure details and Planetstructures holds the planet details and the structure detals etc.. When there are 3 of any planetstructure records of the same type, i want to select the data in the structures table leaving out the structure that coresponds to the planetstructure with more than 3 records of the same type.

     

    SELECT s.StructureName, s.Maintenance, g.PlanetStructureID, g.ConstructionTime, g.PlanetID FROM structures s
    LEFT JOIN planetstructures g ON (s.StructureID = g.StructureID)
    WHERE p.PlanetID = %s[b] AND Totalrows of any one type < 3

     

    I hope ive made sense. Any ideas on how i can achieve this please??

     

    Thanks :)

  6. Hi there im going a little bit mad now.... i spent a while trying to work out why my form didnt update or redirect... After head scratching i remade a test form... That also doesnt update or redirect?? I must be missing something here?? So basically when the user clicks submit nothing happens, why??

     

    <?php require_once('Connections/swb.php'); ?>
    <?php
    session_start();
    if (!function_exists("GetSQLValueString")) {
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
    {
      $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
    
      $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
    
      switch ($theType) {
        case "text":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;    
        case "long":
        case "int":
          $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case "double":
          $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
          break;
        case "date":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;
        case "defined":
          $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
          break;
      }
      return $theValue;
    }
    }
    
    $editFormAction = $_SERVER['PHP_SELF'];
    if (isset($_SERVER['QUERY_STRING'])) {
      $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
    }
    
    if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
      $updateSQL = sprintf("UPDATE player SET `Day`=%s WHERE PlayerName=%s",
                           GetSQLValueString($_POST['days'], "int"),
                           GetSQLValueString($_POST['playername'], "text"));
    
      mysql_select_db($database_swb, $swb);
      $Result1 = mysql_query($updateSQL, $swb) or die(mysql_error());
    
      $updateGoTo = "logout.php";
      if (isset($_SERVER['QUERY_STRING'])) {
        $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
        $updateGoTo .= $_SERVER['QUERY_STRING'];
      }
      header(sprintf("Location: %s", $updateGoTo));
    }
    
    
    
    ?>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Untitled Document</title>
    </head>
    
    <body>
    
    <form action="<?php echo $editFormAction; ?>" id="form1" name="form1" method="POST">
    
    <input type="button" value="End Turn" /> 
    
    
    <input name="days" type="hidden" id="days" value="1"/> 
    <input name="playername" type="hidden" id="playername" value="<?php echo $_SESSION['MM_Username']; ?>">
    <input type="hidden" name="MM_update" value="form1">
    </form>
    
    </body>
    </html>

     

    Thanks :)

  7. Hi there,

     

    Ive never used AJAX before and was hoping for a point in the right direction. Im have a psp/mysql site.

     

    I have a drop down menu in a form that is populated from a table -  Names.  I need it so that when a name is selected by the user a hidden field in the form is updated with a value. So that both fields would be updated in the database at the same time on submitting the form.

     

    Any ideas on where i can find a tutorial or guide to achieve this please???

     

    Thanks

  8. Hi there i have some delete link and processing code here:

     

    <?php 
    planet.php page
    
    echo'<a href="http://localhost/swb/cancelship.php?recordID='.$row_Ships['ShipID'].'" class="arialred" style="color: #FF0000">Cancel</a>';
    
    cancelship.php page
    
    if ((isset($_GET['recordID'])) && ($_GET['recordID'] != "")) {
      $deleteSQL = sprintf("DELETE FROM ships WHERE ShipID=%s",
                           GetSQLValueString($_GET['recordID'], "int"));
    
      mysql_select_db($database_swb, $swb);
      $Result1 = mysql_query($deleteSQL, $swb) or die(mysql_error());
    
      $deleteGoTo = "planet.php";
      if (isset($_SERVER['QUERY_STRING'])) {
        $deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?";
        $deleteGoTo .= $_SERVER['QUERY_STRING'];
      }
      header(sprintf("Location: %s", $deleteGoTo));
    }?>

     

    The trouble is that the page the delete links on  is determined by an ID from a different table. After i delete the record i wish to remain on the original page but parse the PlanetID. At the moment it just loads the original page again but because it doesnt parse the PlanetID so the page doesnt work.

     

    Original page that has the delete link has PlanetID key. From that you are given a list of these delete links with their own key ShipID, which is used to delete those records.

     

    So how can i parse the PlanetID back????

     

    Thanks   

  9. Its now inserting and redirecting...!!!  I had some form elements set as text and not int...

     

    Its still not quite working right though as it only ever inserts the first record, even if im clicking submit on the second record??? Am i missing something here?

    Is there a problem with using echoed form elements in a loop??

    For example, i have records that are outputted and with each row is a form with submit button and hidden fields.. Its only ever inserting the first row in the database regardless of submiting a different row???

     

    THanks

  10. Hi there im having trouble with my code and was hoping someone may be able to help me?

     

    I think the trouble i am having is because i am echoing the form elements (form, hidden) and the value in those elements.

     

    This part is fine i think:

     

    $editFormAction = $_SERVER['PHP_SELF'];
    if (isset($_SERVER['QUERY_STRING'])) {
      $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
    }
    
    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")){
    
    
                          
      $insertSQL = sprintf("INSERT INTO ships (ShipName, FleetID, PlayerName, Image1, Image2, Credits, HealthA, HealthB, MaxHealthA, MaxHealthB, Class, Hyperspace, PlanetID, Building, Maintenance) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                           GetSQLValueString($_POST['shipname1'], "text"),
                           GetSQLValueString($_POST['fleetid1'], "int"),
                           GetSQLValueString($_POST['playername1'], "text"),
                           GetSQLValueString($_POST['image11'], "text"),
                           GetSQLValueString($_POST['image21'], "text"),
                           GetSQLValueString($_POST['credits1'], "int"),
                           GetSQLValueString($_POST['healtha1'], "int"),
                           GetSQLValueString($_POST['healthb1'], "int"),
                           GetSQLValueString($_POST['maxhealtha1'], "int"),					  
                           GetSQLValueString($_POST['maxhealthb1'], "int"),
    	GetSQLValueString($_POST['class1'], "int"),
                           GetSQLValueString($_POST['hyperspace1'], "int"),
    				   GetSQLValueString($_POST['planetid1'], "int"),
    				   GetSQLValueString($_POST['building1'], "int"),
    				   GetSQLValueString($_POST['maintenance1'], "int"));
    
      mysql_select_db($database_swb, $swb);
      $Result1 = mysql_query($insertSQL, $swb) or die(mysql_error());
    
       $insertGoTo = "planet.php";
      if (isset($_SERVER['QUERY_STRING'])) {
        $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
        $insertGoTo .= $_SERVER['QUERY_STRING'];
      }
      header(sprintf("Location: %s", $insertGoTo));
    }
    

     

    The problem may lay here:

     

    <?php echo'<form id="form1" name="form1" method="post" action="">';echo'<table width="400" border="0" align="top">'; 
          do {  echo '<tr>
            <td width="200" align="center">'; echo '<span class="arial12">'; echo "<img src=".$row_Ships["Image1"]." height =\"250\" width=\"400\">"; echo'|  Maintenance: '; echo $row_Ships['Maintenance'];echo ' | '; echo'<input type="submit" name="Submit" value="Build" />'; echo' |  Construction Time: '; echo $row_Ships['Building']; echo' | ';echo '</td></tr>'; echo"  <input name='fleetid1' type='hidden' id='fleetid1' value='".$totalRows_Fleet." + '1''/>";
    echo" <input name='fleetname1' type='hidden' id='fleetname1' value='Fleet ".$totalRows_Fleet." + '1''/>";
    echo" <input name='shipname1' type='hidden' id='shipname1' value='".$row_Ships['ShipName']."'/>";
    echo" <input name='playername1' type='hidden' id='playername1' value='".$_SESSION['MM_Username']."'/>";
    echo" <input name='credits1' type='hidden' id='credits1' value='".$row_Ships['Credits']."'/>";
    echo" <input name='image11' type='hidden' id='image11' value='".$row_Ships['Image1']."'/>";
    echo" <input name='image21' type='hidden' id='image21' value='".$row_Ships['Image2']."'/>";
    echo" <input name='healtha1' type='hidden' id='healtha1' value='".$row_Ships['HealthA']."'/>";
    echo" <input name='healthb1' type='hidden' id='healthb1' value='".$row_Ships['HealthB']."'/>";
    echo" <input name='maxhealtha1' type='hidden' id='maxhealtha1' value='".$row_Ships['MaxHealthA']."'/>";
    echo" <input name='maxhealthb1' type='hidden' id='maxhealthb1' value='".$row_Ships['MaxHealthB']."'/>";
    echo" <input name='class1' type='hidden' id='class1' value='".$row_Ships['Class']."'/>";
    echo" <input name='hyperspace1' type='hidden' id='hyperspace1' value='".$row_Ships['Hyperspace']."'/>";
    echo" <input name='maintenance1' type='hidden' id='maintenance1' value='".$row_Ships['Maintenance']."'/>";
    echo" <input name='Planetid1' type='hidden' id='planetid1' value='".$row_Credits['PlanetID']."'/>";
    echo" <input name='building1' type='hidden' id='building1' value='".$row_Ships['Building']."'/>";		
    
    	} while ($row_Ships = mysql_fetch_assoc($Ships)); echo '</table></form>';?>

     

    No records are insterted at all?? The page redirection after insert is not happening either.

     

    If anybody coould help that would be brilliant...

     

    Thank You :)

  11. Hi there im trying to set a single variable multiple rows of data that are echoed using a single variable. The trouble is i just cant seem to make it work by trying to add a while or do loop..

     

    The variable is $alderaanfleetalt  and consists of:

     

    $fleetname = "FleetName";
    $shipname = "Ship Name";

     

    Which is just text stored in two other variables. The select query row of data is added the $alderaanfleetalt variable.

     

    $alderaanfleetalt =  $fleetname." ".$row_Alderaanfleet['FleetName']."</br>".$shipname." ".$row_Alderaanfleet['ShipName']; 

     

    At the moment only a single row appears. ive tried to add a while/do loop so that multiple rows are outputted but its not working.

     

    do{ 
    $alderaanfleetalt =  $fleetname." ".$row_Alderaanfleet['FleetName']."</br>".$shipname." ".$row_Alderaanfleet['ShipName'];
    } while ($row_Alderaanfleet = mysql_fetch_assoc($Alderaanfleet)); 
    

     

    Im a bit lost here and not even sure it can be done this way... Any help would be ace.

     

    Thank you :)

     

     

  12. Ok so whats the best way to overcome this problem please??

    Is this javascript tooltip like an addon that is installed onto firefox or is it javascript source code i use on my page?? Im not sure where to start.

     

     

    Thank you :)

  13. Heres where i assign text to two variables:

    $alderaancredits = "Credit Output: ";
    $alderaancyard = "Construction Yard Level:";

     

    Then I assign my 3rd variable with the text from the other variables and the data from my database:

    $alderaanalt = $alderaancredits."" .$row_Alderaan['Credits']." <br/>".$alderaancyard." ".$row_Alderaan['CYardLevel1'];
    

     

    And finally i had the variable with all the text and data from the database to the alt or title of my hyperlink:

     

    echo '<a href="http://localhost/swb/planet.php?recordID='.$row_Planet['PlanetID'].'" title ="' .$alderaanalt. '">

     

    This is then outputted as: Credits  50 <br/> Construction Yard 1

     

    I want it to look like:

     

    Credits  50

    Construction Yard 1

     

    Thanks :)

     

     

  14. Yes exactly...

     

    The break is added after the data of the Credits so:

     

    $alderaanalt = $alderaancredits."" .$row_Alderaan['Credits']." </br>".$alderaancyard." ".$row_Alderaan['CYardLevel1'];

     

    Credits  50

    Construction Yard 1

     

    but instead it just outputs the </br>

     

     

    Credits  50 </br> Construction Yard 1

     

    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.