Welcome aboard Visitor...

Daily Screenshot

Server Costs Target


84% of target met.

Latest Topics

- so i talked with Massi »
- See Commands »
- Now the fun begins »
- Qand answers have returned »
- Call to Arms »
- All Species 8572 Report in »
- hi there »
- Anyone still playing from a decade ago or longer? »
- Game still active. NICE! »
- help me »

Development Blog

- Roadmap »
- Hello strangers, it’s been a while... »
- State of DarkSpace Development »
- Potential planetary interdictor changes! »
- The Silent Cartographer »

Combat Kills

Combat kills in last 24 hours:
Kills chart
UGTO (1) ICC (0) K'Luth (0)

Upcoming Events

- Weekly DarkSpace
11/23/24 +2.0 Days

Search

Anniversaries

No anniversaries today.

Social Media

Why not join us on Discord for a chat, or follow us on Twitter or Facebook for more information and fan updates?

Network

DarkSpace
DarkSpace - Beta
Palestar

[FAQ
Forum Index » » English (General) » » Ship builder...
Goto page ( 1 | 2 Next Page )
 Author Ship builder...
Drafell
Grand Admiral
Mythica

Joined: May 30, 2003
Posts: 2449
From: United Kingdom
Posted: 2005-03-08 14:31   
Link url= http://www.ravenwarriors.com/drafell/ships.php

I will post the code for the ship builder I am working on below.

Main interface:-


";
$counter++;
$slots = "slot_$counter";
}
}

?>







DarkSpace Ship Builder






Quote:


ships.php


$dbh=mysql_connect ("localhost", "ravenwar_drafell", "******") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("ravenwar_ship");

$shipList = "shipList";
$gadgetRef ="gadgetRef";
$SelectShip=$_GET['SelectShip'];

// queries gadgetRef for item info
function gadgetQuery($options1) {
$findGadget = mysql_query("SELECT gagdetName, gadgetId FROM gadgetRef WHERE gadgetSlot='$slot01Gad'");
while (list($gadgetName2, $gadgetId) = mysql_fetch_row($findGadget)) {
$options1.="n";
}
}

//This section catches the ship names from the database

$dbh;

$options = "";

$result = mysql_query("SELECT shipName, shipId FROM shipList");

while (list($shipName, $shipId) = mysql_fetch_array($result)) {
$options.="";
}

//fetches chosen ship data from shipList
if(isset($SelectShip)) {
$result2=mysql_query("SELECT shipName, shipFaction, shipDescription FROM shipList WHERE shipId='$SelectShip'");
list($shipName2, $shipFact2, $shipDesc2) = mysql_fetch_row($result2);

// creates a result of slot_1, slot_2 etc dependant on $counter
$counter=1;
$slots = "slot_$counter";

//this loop should enumerate all of the slots on the ship
while($counter<=64){

// $slot0 '$slots' is included for debugging-ouputs fieldname currently being read

$result3=mysql_query("SELECT '$slots',$slots FROM shipList WHERE shipId='$SelectShip' AND $slots IS NOT NULL");

list($slot0,$slot1) = mysql_fetch_row($result3);

$slot01Gad = substr ($slot1, 0, 2); // retrieves gadget type from string slot_x

//$findGadget = mysql_query("SELECT gagdetName, gadgetId FROM gadgetRef WHERE gadgetSlot='$slot01Gad'");
//while (list($gadgetName, $gadgetId) = mysql_fetch_array($findGadget)) {
// $options1.="";
//}
$slot01Fore = substr ($slot1, 2, 1); // retrieves true/false for Fore Mount
$slot01Left = substr ($slot1, 3, 1); // retrieves true/false for Left Mount
$slot01Right = substr ($slot1, 4, 1); // retrieves true/false for Right Mount
$slot01Aft = substr ($slot1, 5, 1); // retrieves true/false for Aft Mount
// prints data into the table on screen
if (isset($slot1)){
if($slot01Fore==1){
$slot02Fore="Yes";
} else {$slot02Fore="No";
}
if($slot01Left==1){
$slot02Left="Yes";
} else {$slot02Left="No";
}
if($slot01Right==1){
$slot02Right="Yes";
} else {$slot02Right="No";
}
if($slot01Aft==1){
$slot02Aft="Yes";
} else {$slot02Aft="No";
}} ELSE {
BREAK;
}
$options3.= "
$slot02Fore$slot02Left $slot02Right$slot02Aft










Select Ship FactionDisabled Select Ship Model
//Prints ship spam
echo "$shipName2 - $shipFact2";
?>






echo "$shipDesc2";
?>


This section will have the ship layout.




echo $options3;
echo "$slot1";
echo "$slot0";
?>
Gadget Type ForeLeftRightAft







Script Resource
Quote:

interface.js

//check for current browser version
function Is() {
var agent = navigator.userAgent.toLowerCase();
this.major = parseInt(navigator.appVersion);
this.minor = parseFloat(navigator.appVersion);
this.ns = ((agent.indexOf('mozilla')!=-1) && ((agent.indexOf('spoofer')==-1) && (agent.indexOf('compatible') == -1)));
this.ns2 = (this.ns && (this.major == 2));

this.ns3 = (this.ns && (this.major == 3));
this.ns4 = (this.ns && (this.major == 4));
this.ns6 = (this.ns && (this.major >= 5));
this.ie = (agent.indexOf("msie") != -1);
this.ie3 = (this.ie && (this.major == 2));
this.ie4 = (this.ie && (this.major >= 4));
this.op3 = (agent.indexOf("opera") != -1);
}

var is = new Is()

//prepare variables
if(is.ns4 || is.ns6) {
doc = "document";
sty = "";
htm = ".document";
} else if(is.ie4) {
doc = "document.all";
sty = ".style";
htm = "";
}




Current Databse tables:-

Quote:

Ship DB

CREATE TABLE shipList (
shipId int(5) NOT NULL auto_increment,
shipName varchar(50) NOT NULL,
shipFaction ENUM('Kluth','UGTO','ICC') NOT NULL,
shipDescription TINYTEXT NOT NULL default '',
PRIMARY KEY (shipId),
UNIQUE shipId (shipId),
UNIQUE shipName (shipNam)e,
slot_01 varchar(6),
slot_02 varchar(6),
slot_03 varchar(6),
slot_04 varchar(6),
slot_05 varchar(6),
slot_06 varchar(6),
slot_07 varchar(6),
slot_08 varchar(6),
slot_09 varchar(6),
slot_10 varchar(6),
slot_11 varchar(6),
slot_12 varchar(6),
slot_13 varchar(6),
slot_14 varchar(6),
slot_15 varchar(6),
slot_16 varchar(6),
slot_17 varchar(6),
slot_18 varchar(6),
slot_19 varchar(6),
slot_20 varchar(6),
slot_21 varchar(6),
slot_22 varchar(6),
slot_23 varchar(6),
slot_24 varchar(6),
slot_25 varchar(6),
slot_26 varchar(6),
slot_27 varchar(6),
slot_28 varchar(6),
slot_29 varchar(6),
slot_30 varchar(6),
slot_31 varchar(6),
slot_32 varchar(6),
slot_33 varchar(6),
slot_34 varchar(6),
slot_35 varchar(6),
slot_36 varchar(6),
slot_37 varchar(6),

slot_38 varchar(6),
slot_39 varchar(6),
slot_40 varchar(6),
slot_41 varchar(6),
slot_42 varchar(6),
slot_43 varchar(6),
slot_44 varchar(6),
slot_45 varchar(6),
slot_46 varchar(6),
slot_47 varchar(6),
slot_48 varchar(6),
slot_49 varchar(6),
slot_50 varchar(6),
slot_51 varchar(6),
slot_52 varchar(6),
slot_53 varchar(6),
slot_54 varchar(6),
slot_55 varchar(6),
slot_56 varchar(6),
slot_57 varchar(6),
slot_58 varchar(6),
slot_59 varchar(6),
slot_60 varchar(6),
slot_61 varchar(6),
slot_62 varchar(6),
slot_63 varchar(6),
slot_64 varchar(6)))



Quote:

Gadget DB

CREATE TABLE gadgetRef (
gadgetId NOT NULL auto_increment,
gadgetName varchar(50),
gadgetSlot varchar(2),
gadgetDesc varchar(255) NOT NULL))



Quote:

Faction DB

CREATE TABLE factionRef (
factionID NOT NULL auto_increment,
factionName varchar(50) NOT NULL,
factionShortName varchar(6) NOT NULL,
factionDescription TINYTEXT NOT NULL))





[ This Message was edited by: Drafell Moraxi on 2005-03-27 22:50 ]
_________________
It's gone now, no longer here...Yet still I see, and still I fear.rnrn
rnrn
DarkSpace Developer - Retired

  Goto the website of Drafell
BackSlash
Marshal
Galactic Navy


Joined: March 23, 2003
Posts: 11183
From: Bristol, England
Posted: 2005-03-08 15:38   
use that .hta thing again and I will MURDER YOU, I can host it for the time being if you want something like www.ravenwarriors.com/drafell.
_________________


Drafell
Grand Admiral
Mythica

Joined: May 30, 2003
Posts: 2449
From: United Kingdom
Posted: 2005-03-08 15:49   
.hta is great for making CD's menus if you know html and nothing else. Saves learning other languages.

Anyway... more stuff added to the top.

Hosting would be appreciated. I hope oyu have MySQL installed and php


[ This Message was edited by: Mr Black on 2005-03-08 15:55 ]
_________________
It's gone now, no longer here...Yet still I see, and still I fear.rnrn
rnrn
DarkSpace Developer - Retired

  Goto the website of Drafell
Drafell
Grand Admiral
Mythica

Joined: May 30, 2003
Posts: 2449
From: United Kingdom
Posted: 2005-03-16 11:58   
Updated Code
_________________
It's gone now, no longer here...Yet still I see, and still I fear.rnrn
rnrn
DarkSpace Developer - Retired

  Goto the website of Drafell
kenetiks
Admiral
Galactic Navy


Joined: November 21, 2001
Posts: 1130
From: Bandcamp
Posted: 2005-03-16 15:05   
Ok Draf try this and let me know what errors you get.



$dbh=mysql_connect ("localhost", "ravenwar_drafell", "rob") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("ravenwar_ship");


$shipList = "shipList";
$gadgetRef ="gadgetRef";

//This section catches the ship names from the database

$dbh;

$options = "";

$result = mysql_query("SELECT shipName, shipId FROM shipList");

while (list($shipName, $shipId) = mysql_fetch_array($result1)) {
$options.="n";
}

//fetches chosen ship data from shipList
if(isset($SelectShip)) {
$result2=mysql_query("SELECT shipName, shipFact, shipDesc FROM shipList WHERE shipId='$SelectShip'");
list($shipName2, $shipFact2, $shipDesc2) = mysql_fetch_row($result2);
}
?>






DarkSpace Ship Builder














Select Ship FactionDisabled Select Ship Model





This section will have the ship layout.
//Prints ship spam
echo "$shipName2
$shipFact2
$shipDesc2";
?>


_________________


  Email kenetiks   Goto the website of kenetiks
Drafell
Grand Admiral
Mythica

Joined: May 30, 2003
Posts: 2449
From: United Kingdom
Posted: 2005-03-27 14:50   
I am having problems with the following section:-


";
$counter++;
}
Quote:

$counter=1;
$slots = 'slot_' . $counter;
while ($counter<=64){
$result3=mysql_query("SELECT $slots FROM shipList WHERE shipId='$SelectShip'");
list($slot1) = mysql_fetch_row($result3);
$slot01Gad = substr ($slot1, 0, 2);
$slot01Fore = substr ($slot1, 2, 1);
$slot01Left = substr ($slot1, 3, 1);
$slot01Right = substr ($slot1, 4, 1);
$slot01Aft = substr ($slot1, 5, 1);
$options3 = "
$slot01Fore$slot01Left $slot01Right$slot01Aft



It works in that format, but if it try moving '$slots = 'slot_' . $counter;' to inside the while loopsit stops working. I am needing it to run this loop 64 times, each time slot_ goes up one value which coresponds directly to the field name in the DB. any ideas?
_________________
It's gone now, no longer here...Yet still I see, and still I fear.rnrn
rnrn
DarkSpace Developer - Retired

  Goto the website of Drafell
Shigernafy
Admiral

Joined: May 29, 2001
Posts: 5726
From: The Land of Taxation without Representation
Posted: 2005-03-27 15:15   
If you're doing a set number of iterations (64 in your case), I find for loops are a bit more clear.. at least, I think it is more obvious what you're doing.

for ($i=0; $i<64; $i++) {
//code here
}

you can use $i if you need to as it will be going up each time (or call it something other than i, obviously) and is a good marker for where you are in your progress.. though I didn't really look at your code too much so I don't know if it would help terribly with your task.
I just think its cleaner than lines explicitly incrementing a counter and whatnot, as it does it automatically.

er, Now that I've read over the code: You're trying to set this $slots variable, and apparently having trouble doing so - but where do you even use it?
also, it might be an error with mixing types - maybe try $slots = "slot_$counter";
Don't use single quotes, though, or it will take $counter literally and just give you $slots = slot_$counter, rather than slot_1
_________________
* [S.W]AdmBito @55321 Sent \"I dunno; the French had a few missteps. But they're on the right track, one headbutt at a time.\"

  Email Shigernafy
Drafell
Grand Admiral
Mythica

Joined: May 30, 2003
Posts: 2449
From: United Kingdom
Posted: 2005-03-27 15:27   
The $slots variable is used in the MySQL query to retrieve the data from the corresponding row name. I tried slot_$counter but this fails to combine the values correctly into a single string value. IE slot_1 or slot_64. It looks like it should work but you actually end up with a weird mess.
The problem I have is that I can get the routine to run 64 times but, if i move the $slots definition to inside the while loop it just returns a null value and fails to recalculate on each run.
Using a For loops also fails to recalculate the $slots varaible on each iteration


[ This Message was edited by: Drafell Moraxi on 2005-03-27 15:36 ]
_________________
It's gone now, no longer here...Yet still I see, and still I fear.rnrn
rnrn
DarkSpace Developer - Retired

  Goto the website of Drafell
Drafell
Grand Admiral
Mythica

Joined: May 30, 2003
Posts: 2449
From: United Kingdom
Posted: 2005-03-27 15:48   

";
$counter++;
}
Quote:

$counter=1;
while ($counter<=64){
$slots = "slot_$counter";
$result3=mysql_query("SELECT $slots FROM shipList WHERE shipId='$SelectShip'");
list($slot1) = mysql_fetch_row($result3);
$slot01Gad = substr ($slot1, 0, 2);
$slot01Fore = substr ($slot1, 2, 1);
$slot01Left = substr ($slot1, 3, 1);
$slot01Right = substr ($slot1, 4, 1);
$slot01Aft = substr ($slot1, 5, 1);
$options3 = "
$slot01Fore$slot01Left $slot01Right$slot01Aft



doesnt work... unless $slots is defined before the while loop and wont work if $slots is redefined inside the loop
_________________
It's gone now, no longer here...Yet still I see, and still I fear.rnrn
rnrn
DarkSpace Developer - Retired

  Goto the website of Drafell
Drafell
Grand Admiral
Mythica

Joined: May 30, 2003
Posts: 2449
From: United Kingdom
Posted: 2005-03-27 17:57   
The variables and functions explained:-


";
$counter++;
}
Quote:

$counter=1;
$slots = "slot_$counter"; // creates a result of slot_1, slot_2 etc dependant on
// $counter, works outside the loop but doesnt inside

//this loop should enumerate all of the slots on the ship but fails
while($counter<=64){
$result3=mysql_query("SELECT $slots FROM shipList WHERE shipId='$SelectShip'");
list($slot1) = mysql_fetch_row($result3);
$slot01Gad = substr ($slot1, 0, 2); // retrieves gadget type from string slot_x
$slot01Fore = substr ($slot1, 2, 1); // retrieves true/false for Fore Mount
$slot01Left = substr ($slot1, 3, 1); // retrieves true/false for Left Mount
$slot01Right = substr ($slot1, 4, 1); // retrieves true/false for Right Mount
$slot01Aft = substr ($slot1, 5, 1); // retrieves true/false for Aft Mount
// prints data into the table on screen
$options3 = "
$slot01Fore$slot01Left $slot01Right$slot01Aft


_________________
It's gone now, no longer here...Yet still I see, and still I fear.rnrn
rnrn
DarkSpace Developer - Retired

  Goto the website of Drafell
Coeus {NCX-Charger}
Admiral, I can't read,
Sundered Weimeriners


Joined: February 16, 2004
Posts: 3635
From: South Philly
Posted: 2005-03-27 18:57   
Try this bro:

";
}
Quote:
for ($counter=1;$counter<=64;$counter++){
$slots = "slot_$counter";
$result3=mysql_query("SELECT $slots FROM shipList WHERE shipId='$SelectShip'");
list($slot1) = mysql_fetch_row($result3);
$slot01Gad = substr ($slot1, 0, 2); // retrieves gadget type from string slot_x
$slot01Fore = substr ($slot1, 2, 1); // retrieves true/false for Fore Mount
$slot01Left = substr ($slot1, 3, 1); // retrieves true/false for Left Mount
$slot01Right = substr ($slot1, 4, 1); // retrieves true/false for Right Mount
$slot01Aft = substr ($slot1, 5, 1); // retrieves true/false for Aft Mount
// prints data into the table on screen
$options3 = "
$slot01Fore$slot01Left $slot01Right$slot01Aft


_________________


Darkspace: Twilight

  Goto the website of Coeus {NCX-Charger}
Drafell
Grand Admiral
Mythica

Joined: May 30, 2003
Posts: 2449
From: United Kingdom
Posted: 2005-03-27 20:30   
I fixed it.. all due to a space and a dot. but now....
Can't get the gadget lookup to work


";
$counter++;
$slots = "slot_$counter";
}
Quote:

// creates a result of slot_1, slot_2 etc dependant on $counter
$counter=1;
$slots = "slot_$counter";

//this loop should enumerate all of the slots on the ship
while($counter<=64){

// $slot0 '$slots' is included for debugging-ouputs fieldname currently being read

$result3=mysql_query("SELECT '$slots',$slots FROM shipList WHERE shipId='$SelectShip' AND $slots IS NOT NULL");

list($slot0,$slot1) = mysql_fetch_row($result3);

$slot01Gad = substr ($slot1, 0, 2); // retrieves gadget type from string slot_x

//$findGadget = mysql_query("SELECT gagdetName, gadgetId FROM gadgetRef WHERE gadgetSlot='$slot01Gad'");
//while (list($gadgetName, $gadgetId) = mysql_fetch_array($findGadget)) {
// $options1.="";
//}
$slot01Fore = substr ($slot1, 2, 1); // retrieves true/false for Fore Mount
$slot01Left = substr ($slot1, 3, 1); // retrieves true/false for Left Mount
$slot01Right = substr ($slot1, 4, 1); // retrieves true/false for Right Mount
$slot01Aft = substr ($slot1, 5, 1); // retrieves true/false for Aft Mount
// prints data into the table on screen
if (isset($slot1)){
if($slot01Fore==1){
$slot02Fore="Yes";
} else {$slot02Fore="No";
}
if($slot01Left==1){
$slot02Left="Yes";
} else {$slot02Left="No";
}
if($slot01Right==1){
$slot02Right="Yes";
} else {$slot02Right="No";
}
if($slot01Aft==1){
$slot02Aft="Yes";
} else {$slot02Aft="No";
}} ELSE {
BREAK;
}
$options3.= "
$slot02Fore$slot02Left $slot02Right$slot02Aft




[ This Message was edited by: Drafell Moraxi on 2005-03-27 22:51 ]
_________________
It's gone now, no longer here...Yet still I see, and still I fear.rnrn
rnrn
DarkSpace Developer - Retired

  Goto the website of Drafell
Shigernafy
Admiral

Joined: May 29, 2001
Posts: 5726
From: The Land of Taxation without Representation
Posted: 2005-03-28 01:13   

//$findGadget = mysql_query("SELECT gagdetName, gadgetId FROM gadgetRef WHERE gadgetSlot='$slot01Gad'");

"gagdet" ... I don't know the error messages, but the typo could be a problem.
_________________
* [S.W]AdmBito @55321 Sent \"I dunno; the French had a few missteps. But they're on the right track, one headbutt at a time.\"

  Email Shigernafy
Drafell
Grand Admiral
Mythica

Joined: May 30, 2003
Posts: 2449
From: United Kingdom
Posted: 2005-03-28 05:01   
Thats me suffering from code blindness. Thnx shig.

_________________
It's gone now, no longer here...Yet still I see, and still I fear.rnrn
rnrn
DarkSpace Developer - Retired

  Goto the website of Drafell
Lawman
Fleet Admiral
Sundered Weimeriners


Joined: February 28, 2003
Posts: 276
From: New Jersey
Posted: 2005-03-28 06:50   
Nice.
_________________


  Email Lawman   Goto the website of Lawman
Goto page ( 1 | 2 Next Page )
Page created in 0.019999 seconds.


Copyright © 2000 - 2024 Palestar Inc. All rights reserved worldwide.
Terms of use - DarkSpace is a Registered Trademark of PALESTAR