Jump to content

quick help


seany123

Recommended Posts

i dont know if this is the right section but anyway....

 

im having problems making this work...

 


    <form method="POST">Select Value: <select value=['value']>
<option type=`submit` name=`level` value="Level">Level</option>
<option type=`submit` name=`money` value="money">Money</option>
<option type=`submit` name=`bank` value="bank">Bank</option>
<option type=`submit` name=`points` value="points">Points</option>
<option type=`submit` name=`strength` value="strength">Strength</option>
<option type=`submit` name=`defense` value="defense">Defense</option>
<option type=`submit` name=`speed` value="speed">Speed</option>
<option type=`submit` name=`total` value="total">Total</option>
    </select></form>
    
    
    <form method="POST">Select Value: <select value=['cityid']>
<option type=`submit` name=`All` value="all">All</option>
<option type=`submit` name=`London` value="1">London</option>
<option type=`submit` name=`Newyork` value="2">New york</option>
    <option type=`submit` name=`Birmingham` value="3">Birmingham</option>
    <option type=`submit` name=`Atlanta` value="4">Atlanta</option>
    <option type=`submit` name=`Washington` value="5">washington</option>
    <option type=`submit` name=`Tokyo` value="6">Tokyo</option>
    <option type=`submit` name=`Moscow` value="7">Moscow</option>
    <option type=`submit` name=`Berlin` value="8">Berlin</option>
    <option type=`submit` name=`Madrid` value="9">Madrid</option>
    <option type=`submit` name=`sydney` value="10">Sydney</option>
    <option type=`submit` name=`Chicargo` value="11">Chicargo</option>
    <option type=`submit` name=`Singapore` value="12">Singapore</option>
    <option type=`submit` name=`Mexico city` value="13">Mexico city</option>
    <option type=`submit` name=`Phoenix` value="14">Phoenix</option>
    <option type=`submit` name=`Amsterdam` value="15">Amsterdam</option>
    <option type=`submit` name=`Oslo` value="16">Oslo</option>
    <option type=`submit` name=`Boston` value="17">Boston</option>
    <option type=`submit` name=`HongKong` value="18">Hong Kong</option>
    <option type=`submit` name=`LasVegas` value="19">Las Vegas</option>
    <option type=`submit` name=`Austin` value="20">Austin</option>
    <option type=`submit` name=`Miami` value="21">Miami</option>
    <option type=`submit` name=`Dublin` value="22">Dublin</option>
    <option type=`submit` name=`Oakland` value="23">Oakland</option>
    <option type=`submit` name=`Milan` value="24">Milan</option>
    <option type=`submit` name=`Istanbul` value="25">Istanbul</option>
    <option type=`submit` name=`Toronto` value="26">Toronto</option>
    <option type=`submit` name=`Rome` value="27">Rome</option>
    </select></form>

<td colspan='7' align='center'><input type='submit' name='submit' value='submit'></td>


<?php

if($_POST['cityid'] == "all" && $_POST['value'] == "level")
{

echo "ALL CITIES AND VALUE 1 (LEVEL)";

}

if($_POST['cityid'] == "1" && $_POST['value'] == "strength")
{

echo " CITY LONDON (1) AND VALUE 5 STRENGTH";

}

?>

Link to comment
Share on other sites

Forms need to submit to somewhere - they can't figure out for themselves where they're meant to send the data.

 

In the <form> tag, you need a action='somefile.php' attribute to tell the web browser where to submit that form's data to. Then, in that 'somefile.php', you deal with the data that has been sent to it. You can make a form submit to the same file as itself, but to start with, I'd suggest reading up on HTML forms and getting them to submit to a separate PHP file.

Link to comment
Share on other sites

seany123,

 

Try this code, although I'm not sure how you know where the VALUE 5 etc.. comes from.

 

  </pre>
<form action="<?php%20echo%20%24_SERVER%5B'PHP_SELF'%5D;%20?>" method="POST">
Select Value: 
   Level
   Money
   Bank
   Points
   Strength
   Defense
   Speed
   Total
    
   
   
    Select Value: 
   All
   London
   New york
    Birmingham
    Atlanta
    washington
    Tokyo
    Moscow
    Berlin
    Madrid
    Sydney
    Chicargo
    Singapore
    Mexico city
    Phoenix
    Amsterdam
    Oslo
    Boston
    Hong Kong
    Las Vegas
    Austin
    Miami
    Dublin
    Oakland
    Milan
    Istanbul
    Toronto
    Rome
    





</form>
<br><br>if(isset($_POST['submit'])) {<br>   echo $_POST['cityid'] . " => " . $_POST['value'];<br>}<br>?><b

Link to comment
Share on other sites

that seems to have done the trick...

 

but i wanna use it in this....

 

 


<?php
include("lib.php");
define("PAGENAME", "Hall Of Fame");
$player = check_user($secret_key, $db);
$i = 1;
include("templates/private_header.php");
?>


<form action ="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
Select Value: <select name="value">
   <option name="level" value="Level">Level</option>
   <option name="money" value="money">Money</option>
   <option name="bank" value="bank">Bank</option>
   <option name="points" value="points">Points</option>
   <option name="strength" value="strength">Strength</option>
   <option name="defense" value="defense">Defense</option>
   <option name="speed" value="speed">Speed</option>
   <option name="total" value="total">Total</option>
    </select>
   
   
    Select Value: <select name="cityid">
   <option name="All" value="all">All</option>
   <option name="London" value="1">London</option>
   <option name="Newyork" value="2">New york</option>
    <option name="Birmingham" value="3">Birmingham</option>
    <option name="Atlanta" value="4">Atlanta</option>
    <option name="Washington" value="5">washington</option>
    <option name="Tokyo" value="6">Tokyo</option>
    <option name="Moscow" value="7">Moscow</option>
    <option name="Berlin" value="8">Berlin</option>
    <option name="Madrid" value="9">Madrid</option>
    <option name="sydney" value="10">Sydney</option>
    <option name="Chicargo" value="11">Chicargo</option>
    <option name="Singapore" value="12">Singapore</option>
    <option name="Mexico city" value="13">Mexico city</option>
    <option name="Phoenix" value="14">Phoenix</option>
    <option name="Amsterdam" value="15">Amsterdam</option>
    <option name="Oslo" value="16">Oslo</option>
    <option name="Boston" value="17">Boston</option>
    <option name="HongKong" value="18">Hong Kong</option>
    <option name="LasVegas" value="19">Las Vegas</option>
    <option name="Austin" value="20">Austin</option>
    <option name="Miami" value="21">Miami</option>
    <option name="Dublin" value="22">Dublin</option>
    <option name="Oakland" value="23">Oakland</option>
    <option name="Milan" value="24">Milan</option>
    <option name="Istanbul" value="25">Istanbul</option>
    <option name="Toronto" value="26">Toronto</option>
    <option name="Rome" value="27">Rome</option>
    </select>
   <br/>
   <br/>
   <td colspan='7' align='center'><input type='submit' name='submit' value='submit'></td>
   </form>

<?php
$query = $db->execute("select `id`, `username`, `level`, `money`, `last_active`, `banned`, `staff`, `rm`, `ncolor`, `city_id` from `players` order by `level` desc limit 50");
while($member = $query->fetchrow())
{
if(isset($_POST['submit'])) 
{ 
if ($_POST['cityid'] == 1 && $_POST['value'] == "all")
{
if($member[city_id'] == 1)
{
    echo "<td>";
    echo "<td>" . number_format($i++) . "</td>\n";
    echo "<td><a href=\"profile.php?id=" . $member['username'] . "\">";
    
    if ($member['banned'] >= 1)
    {
    echo "<b>[b] </b>"; 
    echo "<STRIKE>" .$member['username']. "</STRIKE></td>";
    }
    else if ($member['ncolor'] == 1)
    {
    echo "<font color=\"blue\">".$member['username']."</font>";
    }
    else if($member['ncolor'] == 2)
    {
    echo "<font color=\"green\">".$member['username']."</font>";
    }
    else if($member['ncolor'] == 3)
    {
    echo "<font color=\"yellow\">".$member['username']."</font>";
    }
    else if($member['ncolor'] == 4)
    {
    echo "<font color=\"pink\">".$member['username']."</font>";
    }
    else if($member['ncolor'] == 5)
    {
    echo "<font color=\"silver\">".$member['username']."</font>";
    }
    else if($member['staff'] >= 1)
    { 
    echo "<font color=\"gold\">".$member['username']."</font>";
    }
    else if($member['rm'] >= 1)
    {
    echo "<font color=\"red\">".$member['username']."</font>";
    }
    else
    {
    echo "<font color=\"\">".$member['username']."</font>";	
    }
    echo "<td>" . number_format($member['level']) . "</td>\n";
    echo "<td>$" . number_format($member['money']) . "</td>\n";
    if ($member['last_active'] >= Time()-1200)
    {
    echo "<td><font color=\"lime\">Online</font></td>";
    }
    else
    {
    echo "<td><font color=\"red\">Offline</font></td>";
    }
    echo "</tr>\n";     
    }

}
}
}
?>

Link to comment
Share on other sites

A blank screen usually means syntax errors without error reporting on.

 

Like 9three mentioned turn on error reporting.  You can do this by putting this at the top of your page directly after you <?php tag:

 

ini_set ("display_errors", "1");
error_reporting(E_ALL);

Link to comment
Share on other sites

everytime i add that nothing happens...

 

anyway i fixed the problem... i have just 1 last issue....

 

with this code....

 


<?php
include("lib.php");
define("PAGENAME", "Hall Of Fame");
$player = check_user($secret_key, $db);
$i = 1;
include("templates/private_header.php");
?>

<style type="text/css">
<!--
body, td, th {
   color: #FFFFFF;
}
body {
   background-color: #000000;
}
a:link {
   color: #FF0000;
}
a:visited {
   color: #FF0000;
}
a:hover {
   color: #666666;
}
a:active {
   color: #FF0000;
}
.style5 {color: #FFFFFF}
-->
</style>

<table width="650" border="1" cellpadding="0" cellspacing="0" bordercolor="#FF0000">
  <tr>
    <td align="center" class="style5"><strong>Hall Of Fame </strong></td>
  </tr>
</table>


<form action ="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
Select Value: <select name="value">
   <option name="level" value="level">Level</option>
   <option name="money" value="money">Money</option>
   <option name="bank" value="bank">Bank</option>
   <option name="points" value="points">Points</option>
   <option name="strength" value="strength">Strength</option>
   <option name="defense" value="defense">Defense</option>
   <option name="speed" value="speed">Speed</option>
   <option name="total" value="total">Total</option>
    </select>
   
   
    Select Value: <select name="cityid">
   <option name="all" value="all">All</option>
   <option name="London" value="1">London</option>
   <option name="Newyork" value="2">New york</option>
    <option name="Birmingham" value="3">Birmingham</option>
    <option name="Atlanta" value="4">Atlanta</option>
    <option name="Washington" value="5">washington</option>
    <option name="Tokyo" value="6">Tokyo</option>
    <option name="Moscow" value="7">Moscow</option>
    <option name="Berlin" value="8">Berlin</option>
    <option name="Madrid" value="9">Madrid</option>
    <option name="sydney" value="10">Sydney</option>
    <option name="Chicargo" value="11">Chicargo</option>
    <option name="Singapore" value="12">Singapore</option>
    <option name="Mexico city" value="13">Mexico city</option>
    <option name="Phoenix" value="14">Phoenix</option>
    <option name="Amsterdam" value="15">Amsterdam</option>
    <option name="Oslo" value="16">Oslo</option>
    <option name="Boston" value="17">Boston</option>
    <option name="HongKong" value="18">Hong Kong</option>
    <option name="LasVegas" value="19">Las Vegas</option>
    <option name="Austin" value="20">Austin</option>
    <option name="Miami" value="21">Miami</option>
    <option name="Dublin" value="22">Dublin</option>
    <option name="Oakland" value="23">Oakland</option>
    <option name="Milan" value="24">Milan</option>
    <option name="Istanbul" value="25">Istanbul</option>
    <option name="Toronto" value="26">Toronto</option>
    <option name="Rome" value="27">Rome</option>
    </select>
   <br/>
   <br/>
   <td colspan='7' align='center'><input type='submit' name='submit' value='submit'></td>
   </form>
  
<table width="54%" border="0" align="left">
<tr>
<th width="8%"> 
<th width="14%">Rank 
<th width="26%"><b>Username</b></td>
<th width="16%"><strong>Level</strong>
<th width="20%"><strong>Money</strong>
<th width="16%">Status</tr>

<?php
if(isset($_POST['submit'])) 
{ 
if ($_POST['cityid'] == "all" && $_POST['value'] == "level")
{

$query = $db->execute("select `id`, `username`, `level`, `money`, `last_active`, `banned`, `staff`, `rm`, `ncolor`, `city_id` from `players` order by `level` desc limit 50");
while($member = $query->fetchrow())
{
    echo "<td>";
    echo "<td>" . number_format($i++) . "</td>\n";
    echo "<td><a href=\"profile.php?id=" . $member['username'] . "\">";
    
    if ($member['banned'] >= 1)
    {
    echo "<b>[b] </b>"; 
    echo "<STRIKE>" .$member['username']. "</STRIKE></td>";
    }
    else if ($member['ncolor'] == 1)
    {
    echo "<font color=\"blue\">".$member['username']."</font>";
    }
    else if($member['ncolor'] == 2)
    {
    echo "<font color=\"green\">".$member['username']."</font>";
    }
    else if($member['ncolor'] == 3)
    {
    echo "<font color=\"yellow\">".$member['username']."</font>";
    }
    else if($member['ncolor'] == 4)
    {
    echo "<font color=\"pink\">".$member['username']."</font>";
    }
    else if($member['ncolor'] == 5)
    {
    echo "<font color=\"silver\">".$member['username']."</font>";
    }
    else if($member['staff'] >= 1)
    { 
    echo "<font color=\"gold\">".$member['username']."</font>";
    }
    else if($member['rm'] >= 1)
    {
    echo "<font color=\"red\">".$member['username']."</font>";
    }
    else
    {
    echo "<font color=\"\">".$member['username']."</font>";	
    }
    echo "<td>" . number_format($member['level']) . "</td>\n";
    echo "<td>$" . number_format($member['money']) . "</td>\n";
    
if ($member['last_active'] >= Time()-1200)
    {
    echo "<td><font color=\"lime\">Online</font></td>";
    }
    else
    {
    echo "<td><font color=\"red\">Offline</font></td>";
    }
    echo "</tr>\n";     
    }
  }
}


if(isset($_POST['submit'])) 
{ 
if ($_POST['cityid'] == "1" && $_POST['value'] == "level")
{

$query = $db->execute("select `id`, `username`, `level`, `money`, `last_active`, `banned`, `staff`, `rm`, `ncolor`, `city_id` from `players` order by `level` desc limit 50");
while($member = $query->fetchrow())
{
if($member['city_id'] == 1)
{
    echo "<td>";
    echo "<td>" . number_format($i++) . "</td>\n";
    echo "<td><a href=\"profile.php?id=" . $member['username'] . "\">";
    
    if ($member['banned'] >= 1)
    {
    echo "<b>[b] </b>"; 
    echo "<STRIKE>" .$member['username']. "</STRIKE></td>";
    }
    else if ($member['ncolor'] == 1)
    {
    echo "<font color=\"blue\">".$member['username']."</font>";
    }
    else if($member['ncolor'] == 2)
    {
    echo "<font color=\"green\">".$member['username']."</font>";
    }
    else if($member['ncolor'] == 3)
    {
    echo "<font color=\"yellow\">".$member['username']."</font>";
    }
    else if($member['ncolor'] == 4)
    {
    echo "<font color=\"pink\">".$member['username']."</font>";
    }
    else if($member['ncolor'] == 5)
    {
    echo "<font color=\"silver\">".$member['username']."</font>";
    }
    else if($member['staff'] >= 1)
    { 
    echo "<font color=\"gold\">".$member['username']."</font>";
    }
    else if($member['rm'] >= 1)
    {
    echo "<font color=\"red\">".$member['username']."</font>";
    }
    else
    {
    echo "<font color=\"\">".$member['username']."</font>";	
    }
    echo "<td>" . number_format($member['level']) . "</td>\n";
    echo "<td>$" . number_format($member['money']) . "</td>\n";
    
if ($member['last_active'] >= Time()-1200)
    {
    echo "<td><font color=\"lime\">Online</font></td>";
    }
    else
    {
    echo "<td><font color=\"red\">Offline</font></td>";
    }
    echo "</tr>\n";     
    }
  }
}
}
?>

 

 

it displays when called brilliantly... but before i hit submit the table is empty....

 

how do i make it so it displays something.. then changes after i hit submit....

 

or.. is it possible to start the page with something already submited?

Link to comment
Share on other sites

And another thing...

 

is it possible for once the form has been submitted... for the scroll menus to stay on the value submitted??

 

so say i chose

 

 

<option name="bank" value="bank">Bank</option>

 

and

 

<option name="Moscow" value="7">Moscow</option>

 

instead of it then going back to the top... could i keep them fixed on them 2? until i refresh / reload the page etc??

Link to comment
Share on other sites

how do i make it so it displays something.. then changes after i hit submit....

 

or.. is it possible to start the page with something already submited?

 

Check if the posts are set, with isset().  If they are keep the value the same, if not assign the variable a default value.

 

 

 

Link to comment
Share on other sites

isnt that what this is?

 

if(isset($_POST['submit'])) 

 

 

Yes, that tells you that that submit button has been clicked.

 

You now want to have default values for everything else.  So you need to see if they are set (have been assigned any values) if they have then keep them the same if not then you need to create a default value.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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