Page 1 of 1

help

Posted: Mon Nov 24, 2014 10:30 am
by dragonatter
hy!
I need help with this.
<?php

include_once 'connect.php';
session_start();
include_once 'logo.php';
?>
<link href="style.css" rel="stylesheet" type="text/css" />
<?php

if (isset($_SESSION['player']))
{
$player=$_SESSION['player'];
}
else
{
echo "Not Logged in <br><br> <A href='login.php'>Login</a>";
exit;
}



$playerinfo="SELECT * from players where name='$player'";
$playerinfo2=mysql_query($playerinfo) or die("could not get player stats!");
$playerinfo3=mysql_fetch_array($playerinfo2);
include_once 'statpanel.php';
$playerid = $playerinfo3['id'];
?>
</div>
<div id="table">
<?php
$counter = 0;
echo "<small>";
print "<center>";
print "<table border='0' width='70%' cellspacing='20'>";
print "<tr><td width='25%' valign='top'>";
print "</td>";
print "<td valign='top' width='75%'>";
$invinfo="SELECT * from playermagic where pid='$playerid'";
$invinfo2=mysql_query($invinfo) or die("could not select player magic");
print "<table border='1' bordercolor='white' bgcolor='#ffffff'>";
print "<tr><td>Name<font color='ffffff'>________________</font></td><td>Level<font color='ffffff'>______</td><td>Type<font color='ffffff'>______</td><td>Value<font color='ffffff'>______</td><td>Point Cost<font color='ffffff'>______</td><td><font color='ffffff'>________________</td></tr>";
while($invinfo3=mysql_fetch_array($invinfo2))
{
print "<tr><td>$invinfo3[name]</td><td>$invinfo3[level]</td><td>$invinfo3[type]</td><td>$invinfo3[svalue]</td><td>$invinfo3[scost]</td><td><A href='attack.php?sid=$invinfo3[sid]'>Use Magic</td></tr>";
$counter = 1;

}

print "</table>";
print "</td></tr></table>";
print "</center>";
echo "</small>";

if ($counter == 0)
{
echo "<center>You have no Spells!<br>";
echo "<a href='battle.php>Go Back</center>";
exit;
}

echo "<center><a href='battle.php>NeverMind</center>";

?>
</div>

thia is halls usemagic code. I wanna do a option menu like he did in the register.php where u choose the class instead of this but my html knowledge is bellow 0. But I don't whant a select button. the moment a spell is chosen I whant to use that spell directly,since I will add more spell classes each with a different menu.
tanks in advance and I sincerilly do apologise for my bad English but I stuffer a massive hangover from last night :D

Re: help

Posted: Mon Nov 24, 2014 1:24 pm
by MikuzA
Hello!
You might want to wrap your code inside [ CODE] and [ /CODE] to make it more easier for others to read.
Also you might want to say that what problem you have with your code.

But I guess your issue is here:

Code: Select all

print "<tr><td>$invinfo3[name]</td><td>$invinfo3[level]</td><td>$invinfo3[type]</td><td>$invinfo3[svalue]</td><td>$invinfo3[scost]</td><td><A href='attack.php?sid=$invinfo3[sid]'>Use Magic</td></tr>";
To pinpoint this more closely:

Code: Select all

<A href='attack.php?sid=$invinfo3[sid]'>Use Magic</td>
You are starting a <a>-tag but never ending it, so your Use Magic-link is quite a big one!
So try adding a closer-tag after the text, 'Use Magic'

like this,

Code: Select all

<A href='attack.php?sid=$invinfo3[sid]'>Use Magic</a></td>

Re: help

Posted: Mon Nov 24, 2014 3:15 pm
by hallsofvallhalla
Yep make sure to not label your title as "help". Most people won't even bother looking. If everyone did that it would be a forum full of help posts and no one would no where to go ;)

Also what error are you getting?

Re: help

Posted: Mon Nov 24, 2014 7:31 pm
by dragonatter
there is no problem with the code. it works perfectlly.
Its just that i dont whant the available spells to be listed in a table. insted i whant a option menu similar to the one u did for the register.php where u select the class u whant o have

Re: help

Posted: Mon Nov 24, 2014 7:42 pm
by Epiales

Code: Select all

echo "<center>You have no Spells!<br>";

Code: Select all

echo "<a href='battle.php>Go Back</center>";
exit;

Code: Select all

echo "<center><a href='battle.php>NeverMind</center>";

Also might want to close those <a href>'s off with a </a> as well.

Re: help

Posted: Mon Nov 24, 2014 7:56 pm
by Epiales
You can do something like this:

Code: Select all

<form action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="post">
	<label for='spells[]'>Select the spells that you wish to use:</label><br>
	<select multiple="spells" name="spells[]">
		<option value="Spell">Spell</option>
		<option value="Spell">Spell</option>
		<option value="Spell">Spell</option>
		<option value="Spell">Spell</option>
	</select><br>
	<input type="submit" name="formSubmit" value="Submit" >
</form>
Not tested, but should be close!

Re: help

Posted: Mon Nov 24, 2014 8:03 pm
by Epiales
or just a simple dropdown:

Code: Select all

<label for="spells">Spells</label><br />
        <select name="spell" id="spell">
            <option value="spell">spell1</option>
            <option value="spell">spell2</option>
            <option value="spell">spell3</option>
            <option value="spell">spell4 </option>
        </select>
You should be able to look over the class code that Halls has, and just change a bit of info in order for it to do spells?

Re: help

Posted: Mon Nov 24, 2014 8:11 pm
by Epiales
Or if u're wanting to get spells from the database...

Code: Select all

Select Spell:
    <form method="post" action="spell.php">
    <label for="select"><select name="spell" value="Select" size="10"> 
<?php 

    $sql = "SELECT * FROM spells";  
    $result = mysql_query($sql) or die (mysql_error());  
    while ($row = mysql_fetch_array($result)) 
    { 
            $id=$row["id"]; 
            $name=$row["spell_name"];  
            $options.="<OPTION VALUE=\"$id\">".$name; 
    } 
    ?> 
            <option>
            <? echo $options ?>
            </option>
        </select>
       <input type="submit" name="Submit" value="Submit">
    </form>
Again, not tested, but should give you an idea.

Re: help

Posted: Wed Nov 26, 2014 7:55 pm
by dragonatter
<form method="post" action="spell.php">
i dont have a spell.php
i am trying to create a game like halls was doing in his tutorial, but i need help with many things. can i post the url of my site or it will count as a free advertisment? :D

Re: help

Posted: Thu Nov 27, 2014 3:20 pm
by MikuzA
You might want to follow the tutorial and figure it out that way, helping someone from scratch is kind of difficult.