Jump to content

Recommended Posts

Say i wanted to make a list with only female names and i wrote the whole file for it but it kept showing both Male and Female names how would i remove the male names from the list without deleting them out of the SQL?

 

I wish i knew how to word this better for what I'm looking for....

 

 

----------------------------------------------Don't know if you need this----------------------------------------------

MySQL

 

    Server: Localhost via UNIX socket

    Server version: 5.0.91

    Protocol version: 10

    User: tpkrpgn1@localhost

    MySQL charset: UTF-8 Unicode (utf8)

 

Web server

 

    cpsrvd 11.28.64

    MySQL client version: 5.0.91

    PHP extension: mysql

 

phpMyAdmin

 

    Version information: 3.3.8.1

----------------------------------------------Don't know if you need this----------------------------------------------

 

Also is there a way to delete previous posts?

I'm not sure what you mean.  Are these names in a file or database?  Do you want to extract these names and put them in a file?  If you want to extract the female names from the database then you would just do a simple select query with a condition to check for female.

I'm not sure what you mean.  Are these names in a file or database?  Do you want to extract these names and put them in a file?  If you want to extract the female names from the database then you would just do a simple select query with a condition to check for female.

They are in a SQL Database

 

 

You need a column called "gender" then you make a select to only select where gender = 'female'.

This is what i have been trying to do but i don't understand how....

Show us the structure of your table. Is it MySQL btw?

Its in PHPMyAdmin, i don't know if its MySQL or just SQL? or are those the same thing? o.o

I assume you mean this?

 

(`id`, `trainer`, `gender`, `name`, `party1`, `party2`, `party3`, `party4`, `party5`, `party6`, `level`, `exp`, `hp`, `totalhp`, `att`, `def`, `box`, `days`, `battle_wins`, `battle_losses`, `move1`, `move2`, `move3`, `move4`, `attbon`, `defbon`, `totalexp`, `sold`, `traded`, `item`, `soldtrainer`)

 

Its not the whole Male/Female thing i was using that as an example since i wasn't sure if i used Pokemon people would understand it.

 

Basically what I'm trying to do is make it where if traded=1 the Pokemon doesn't appear on the list at all.

 

This is the code that makes up the list

 

<div class="contentcontent"><p class="title"><center>Trade pokemon with trainer #<?=$_GET['q']?></p></center>

<form action="/trade5.php?a=<?=$_GET['q']?>" method="POST"><table class="w100"><tr><td class="w50"><p class="center">Your Pokémon<br /><select name="mytrade[]" multiple="multiple" size="20"><option value="niks" selected>(No Pok&#233;mon)</option><?while($owntradert=mysql_fetch_object($owntraderss1)){?><option value="<?=$owntradert->id?>"><?=$owntradert->name?> <?=$owntradert->gender?> (Level:<?=$owntradert->level?>)</option><?}?></select></p></td>

<td class="w50"><p class="center"><?=$trading->username?>'s Pokémon<br /><select name="othertrade[]" multiple="multiple" size="20"><option value="niks" selected>(No Pok&#233;mon)</option><?while($tradert=mysql_fetch_object($traderss1)){?><option value="<?=$tradert->id?>"><?=$tradert->name?> <?=$tradert->gender?> (Level:<?=$tradert->level?>)</option><?}?></select></p></td></table>

 

This is the WHOLE php file

 

<?php

session_start();

require_once 'dbconf.php';

include("figg.php");

if(!isset($_SESSION['user'])){

?>

<script language="text/javascript">

alert('You are not logged in.');

</script><?

header ("Location: login.php");

}

else{

session_start();



$snorretje1 = mysql_query("SELECT * FROM `users` WHERE `username`='" . $_SESSION['user'] . "'");

$snorretje = mysql_fetch_object($snorretje1);

$user1 = mysql_query("SELECT * FROM `users` WHERE `id`='$snorretje->id'");

$user = mysql_fetch_object($user1);

require_once 'figg.php';

$pokemon1 = mysql_query("SELECT * FROM `poke_owned` WHERE `trainer`='$user->username' AND `party1`='1'");

$sex = mysql_query("SELECT * FROM `poke_owned` WHERE `traded`='1'");

$pokemon = mysql_fetch_object($pokemon1);

$poke1 = mysql_query("SELECT * FROM `pokemon` WHERE `name`='$pokemon->name'");

$poke = mysql_fetch_object($poke1);

$amo1= mysql_query("SELECT * FROM `poke_owned` WHERE `trainer`='$user->username'");

$amo=mysql_num_rows($amo1);

$trading1=mysql_query("SELECT * FROM `users` WHERE `id`='" . $_GET['q'] . "'");

$trading=mysql_fetch_object($trading1);

$traderss1=mysql_query("SELECT * FROM `poke_owned` WHERE `box`='1' AND `trainer`='" . $trading->username . "' ORDER BY `name` ASC");

$traderss=mysql_fetch_object($traderss1);

$owntraderss1=mysql_query("SELECT * FROM `poke_owned` WHERE `box`='1' AND `trainer`='" . $user->username . "' ORDER BY `name` ASC");






?>



<?include("leftmenu.php");?>



<?if($_GET['q']==""){?>
<div class="title">Trade pokemon</div>
<div class="contentcontent">
<br>
<center>



<?if(!isset($_POST['mytrade'])){ if(!isset($_POST['othertrade'])){?>

Please enter the number of the trainer you would like to trade with:<br>
<br>


<form name="form" action="trade5.php" method="get">

  <input type="text" name="q" />

  <input type="submit" name="Submit" value="Trade" class="button" />

</form>

<?}}}?>



<?if($_GET['q']!=""){

if ($user->id == $_GET['q'])

  {

  echo "<div class=\"contentcontent\"><p class=\"title\">Trade pokemon</p><br><center>You can't trade yourself... Silly buns...</center></div>";
include("rightmenu.php");
  exit;

  }


$trading1=mysql_query("SELECT * FROM `users` WHERE `id`='" . $_GET['q'] . "'");

$trading=mysql_fetch_object($trading1);

$trading1=mysql_query("SELECT * FROM `users` WHERE `id`='" . $_GET['q'] . "'");

$num=mysql_num_rows($trading1);

if($num==0){echo("<center><b>No user found with that ID.</b></center>");}

if($num==1){

?>



<div class="contentcontent"><p class="title"><center>Trade pokemon with trainer #<?=$_GET['q']?></p></center>

<form action="/trade5.php?a=<?=$_GET['q']?>" method="POST"><table class="w100"><tr><td class="w50"><p class="center">Your Pokémon<br /><select name="mytrade[]" multiple="multiple" size="20"><option value="niks" selected>(No Pok&#233;mon)</option><?while($owntradert=mysql_fetch_object($owntraderss1)){?><option value="<?=$owntradert->id?>"><?=$owntradert->name?> <?=$owntradert->gender?> (Level:<?=$owntradert->level?>)</option><?}?></select></p></td>

<td class="w50"><p class="center"><?=$trading->username?>'s Pokémon<br /><select name="othertrade[]" multiple="multiple" size="20"><option value="niks" selected>(No Pok&#233;mon)</option><?while($tradert=mysql_fetch_object($traderss1)){?><option value="<?=$tradert->id?>"><?=$tradert->name?> <?=$tradert->gender?> (Level:<?=$tradert->level?>)</option><?}?></select></p></td></table>

<center><input type="submit" value="Trade"> <?}}
$bs=2;
if ($bs == 1) {
?> ' <?
}

if(isset($_POST[mytrade])){

{

$trading1=mysql_query("SELECT * FROM `users` WHERE `id`='" . $_GET['a'] . "'");

$trading=mysql_fetch_object($trading1);



$id1=mysql_query("SELECT * FROM `trade`");

$id=mysql_fetch_object($id1);

$numbl=mysql_num_rows($id1);

if($numbl==0)

{

$tradeid=0;

}

else

{

$tradeid=$id->tradeid+1;

}



$ytrade=$_POST[mytrade];




if($ytrade){

foreach ($ytrade as $y)

mysql_query("INSERT INTO `trade` (`from`, `to`, `pokid`,`tradeid`,`owner`) values('" . $user->id . "','" . $_GET['a'] . "','" . $y . "','" . $tradeid . "','" . $user->id . "')")or die(mysql_error());

$theother1=mysql_query("SELECT * FROM `users` WHERE `id`='" . $_GET['a'] . "'");

$theother=mysql_fetch_object($theother1);

$error1=mysql_query("SELECT * FROM `poke_owned` WHERE `trainer`='" . $theother->username . "'  AND `id`='" . $y . "' OR `trainer`='" . $user->username . "' AND `id`='" . $y . "'");

$error=mysql_num_rows($error1);

if($error==0 && $y!=niks)

{

echo("Don't try to cheat!");

exit;

}

}

if($ytrade){

foreach ($ytrade as $y) 

mysql_query("UPDATE poke_owned SET traded=1 WHERE id='" . $y . "'");



mysql_query("DELETE FROM `trade` WHERE `pokid`='niks'");

}

{

}

}











$otrade=$_POST[othertrade];



if($otrade){

foreach ($otrade as $o)

mysql_query("INSERT INTO `trade` (`from`, `to`, `pokid`,`tradeid`, `owner`) values('" . $user->id . "','" . $_GET['a'] . "','" . $o . "','" . $tradeid . "','" . $_GET['a'] . "')")or die(mysql_error());

$theother1=mysql_query("SELECT * FROM `users` WHERE `id`='" . $_GET['a'] . "'");

$theother=mysql_fetch_object($theother1);

$error1=mysql_query("SELECT * FROM `poke_owned` WHERE `trainer`='" . $theother->username . "'  AND `id`='" . $o . "' OR `trainer`='" . $user->username . "' AND `id`='" . $y . "'");

$error=mysql_num_rows($error1);

if($error==0 && $o!=niks)

{

echo("Don't try to cheat!");

exit;

}

}

if($otrade){

foreach ($otrade as $o)

mysql_query("UPDATE poke_owned SET traded=1 WHERE id='" . $o . "'");

mysql_query("DELETE FROM `trade` WHERE `pokid`='niks'");

}

unset($_POST[mytrade]);

unset($_POST[othertrade]);

?><meta http-equiv="Refresh" content="0; url=/traded.php"><?
}



?>









<br>





<p> </p>

<p class="center">

</p>

</div>

<?include("rightmenu.php");?>

</html>

<?}?>

 

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.