sql database quiery

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
utdfederation
Forum Newbie
Posts: 7
Joined: Fri Aug 29, 2008 6:57 pm

sql database quiery

Post by utdfederation »

hello guys.

was wondering if someone could help me out at all please?

this is my problem:

in my form where the client has to choose which games he/she has i have the following code:

Code: Select all

	<tr><td align='right' valign='top'>&nbsp;<b>Select Games You Own:</b></td>
	<td align='left'> 
	<input type='checkbox' name='games[]' value='CODUO'> Call Of Duty United Offensive<br> 
	<input type='checkbox' name='games[]' value='COD2'> Call Of Duty 2<br> 
	<input type='checkbox' name='games[]' value='COD4MW'> Call Of Duty 4 Modern Warfare<br> 
	<input type='checkbox' name='games[]' value='CODWAW'> Call Of Duty 5 World At War<br> 
	<input type='checkbox' name='games[]' value='CODMW2'> Call Of Duty 6 Modern Warfare 2<br>
	<input type='checkbox' name='games[]' value='CODBO'> Call Of Duty 7 Black Ops<br>
	</td></tr>
now for the information to be stored in my sql database i have this code:

Code: Select all

$db->sql_query("CREATE TABLE ".$prefix."_joinus_apps (
aid INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
realname VARCHAR( 25 ) NOT NULL ,
gamename VARCHAR( 25 ) NOT NULL ,
email VARCHAR( 50 ) NOT NULL ,
gender INT( 1 ) NOT NULL ,
day VARCHAR( 2 ) NOT NULL ,
month VARCHAR( 2 ) NOT NULL ,
year VARCHAR( 4 ) NOT NULL , 
country INT( 1 ) NOT NULL ,
xfire VARCHAR (25) NOT NULL ,
games INT( 1 ) NOT NULL ,
microphone INT( 1 ) NOT NULL ,
teamspeak2 INT( 1 ) NOT NULL ,
date VARCHAR( 10 ) NOT NULL)");
the part that says:

Code: Select all

games INT( 1 ) NOT NULL ,
do i have this part correct?

also for the client to select which country they are from i have this code:

Code: Select all

	<tr><td align='right'><b>Country:</b><br></td>
    <td align='left'><select name ='country' value='$country'>
			<option value=''></option>
			<option value='Albania'>Albania</option>
			<option value='Andorra'>Andorra </option>	
			<option value='Argentina'>Argentina </option>
			<option value='Australia'>Australia </option>
			<option value='Austria'>Austria </option>
			<option value='Belarus'>Belarus </option>
			<option value='Belgium'>Belgium </option>
			<option value='Brazil'>Brazil </option>
			<option value='Bolivia'>Bolivia </option>
			<option value='Bosnia'>Bosnia </option>
			<option value='Bulgaria'>Bulgaria </option>
			<option value='Canada'>Canada </option>
			<option value='Chile'>Chile </option>
			<option value='China'>China </option>
			<option value='Colombia'>Colombia </option>
			<option value='Croatia'>Croatia </option>
			<option value='Cyprus'>Cyprus </option>
			<option value='CzechRep'>CzechRep </option>
			<option value='Denmark'>Denmark </option>
			<option value='England'>England </option>
			<option value='Estonia'>Estonia </option>
			<option value='Finland'>Finland </option>
			<option value='France'>France </option>
			<option value='Germany'>Germany </option>
			<option value='Greece'>Greece </option>
			<option value='Hungary'>Hungary </option>
			<option value='Iceland'>Iceland </option>
			<option value='India'>India </option>
			<option value='Iraq'>Iraq </option>
			<option value='Ireland'>Ireland </option>
			<option value='Israel'>Israel </option>
			<option value='Italy'>Italy </option>
			<option value='Jamaica'>Jamaica </option>
			<option value='Japan'>Japan </option>
			<option value='Korea'>Korea </option>
			<option value='Latvia'>Latvia </option>
			<option value='Liechtenstein'>Liechtenstein </option>
			<option value='Lithuania'>Lithuania </option>
			<option value='Luxembourg'>Luxembourg </option>
			<option value='Macedonia'>Macedonia </option>
			<option value='Malta'>Malta </option>
			<option value='Mexico'>Mexico </option>
			<option value='Moldova'>Moldova </option>
			<option value='Monaco'>Monaco </option>
			<option value='Morocco'>Morocco </option>
			<option value='Netherlands'>Netherlands </option>
			<option value='New Zealand'>New Zealand </option>
			<option value='Nigeria'>Nigeria </option>
			<option value='Norway'>Norway </option>
			<option value='Paraguay'>Paraguay </option>
			<option value='Poland'>Poland </option>
			<option value='Portugal'>Portugal </option>
			<option value='Romania'>Romania </option>
			<option value='Russia'>Russia </option>
			<option value='San Marino'>San Marino </option>
			<option value='Scotland'>Scotland </option>
			<option value='Singapore'>Singapore </option>
			<option value='Slovakia'>Slovakia </option>
			<option value='Slovenia'>Slovenia </option>
			<option value='South Africa'>South Africa </option>
			<option value='Spain'>Spain</option>
			<option value='Sweden'>Sweden</option>
			<option value='Switzerland'>Switzerland</option>
			<option value='Tunisia'>Tunisia</option>
			<option value='Turkey'>Turkey</option>
			<option value='Ukraine'>Ukraine</option>
			<option value='United States'>United States&nbsp;&nbsp;&nbsp;</option>
			<option value='Uraguay'>Uraguay</option>
			<option value='Venezuela'>Venezuela</option>
			<option value='Wales'>Wales</option>
			<option value='Yugoslavia'>Yugoslavia</option>
	</select><br></td></tr>	
and again for the information to be collected in my sql database i have this code:

Code: Select all

country INT( 1 ) NOT NULL ,
do i have that right at all?

thanks in advance

dang it, i just realised i have posted this in the wrong part of the forum when it should be posted in the msql section.
sorry about that, please move to the correct section if this is the wrong place please.
[...Moved to Databases forum by moderator...]

again sorry about that
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: sql database quiery

Post by califdon »

I don't follow what it is you are trying to do. Do you really want to create a new table for every player of every game? That doesn't sound like a good idea to me. The answers to your 2 questions depend entirely on what you are going to represent in the table. If you define a field as INT(1), you can only ever have 10 values (0 through 9). I'd guess that this is not what you need to do.
utdfederation
Forum Newbie
Posts: 7
Joined: Fri Aug 29, 2008 6:57 pm

Re: sql database quiery

Post by utdfederation »

this is what i have:

i am using ravennuke which is a web based content management system (CMS) for clan websites.
i am trying to create a form by where the user has to fill in certain data so it gets processed to the sql database so that info gets passed onto the admin page where i can view who has registered for full membership and with what credentials.

these are my scripts:

this one is the install file that installs all the data needed for the database.

Code: Select all

<?php

require_once("mainfile.php");
global $admin, $prefix, $db;
if(!is_array($admin)) {
    $adm = base64_decode($admin);
    $adm = explode(":", $adm);
    $admin_name = "$adm[0]";
} else {
    $admin_name = "$admin[0]";
}

   $isadmin = $db->sql_fetchrow($db->sql_query("SELECT * FROM ".$prefix."_authors WHERE aid='$admin_name'"));
if ($isadmin['radminsuper']==1) {

switch($op) {

    default:
        $pagetitle = "Join Us";
        include("header.php");
        title("$pagetitle");
        OpenTable();
        echo "<table align='center' border='0' cellpadding='2' cellspacing='2'>\n";
        echo "<form action='".$_SERVER['PHP_SELF']."' method='post'>\n";
        echo "<tr><td>This script will install or upgrade the tables for the $pagetitle.</td></tr>\n";
        echo "<tr><td><b>Backup data tables before going on!</b></td></tr>\n";
        echo "<tr><td><select name='op'>\n";
        echo "<option value=''>--- Install Options ---</option>\n";
        echo "<option value='install'>Install</option>\n";
        echo "<option value='update'>Update</option>\n";
        echo "<option value='uninstall'>Uninstall</option>\n";
        echo "</select> <input type='submit' value='Commit'></td></tr>\n";
        echo "<tr><td><b>Once you have finished with this script, delete it from your server!</b></td></tr>\n";
        echo "</form>";
        echo "</table>\n";
        CloseTable();
        include("footer.php");
    break;

    case "install":
        $pagetitle = "Join Us: Install";
        include("header.php");
        title("$pagetitle");
        OpenTable();

$db->sql_query("CREATE TABLE ".$prefix."_joinus_apps (
aid INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
realname VARCHAR( 25 ) NOT NULL ,
gamename VARCHAR( 25 ) NOT NULL ,
email VARCHAR( 50 ) NOT NULL ,
gender INT( 1 ) NOT NULL ,
day VARCHAR( 2 ) NOT NULL ,
month VARCHAR( 2 ) NOT NULL ,
year VARCHAR( 4 ) NOT NULL , 
country INT( 1 ) NOT NULL ,
xfire VARCHAR (25) NOT NULL ,
games INT( 1 ) NOT NULL ,
microphone INT( 1 ) NOT NULL ,
teamspeak2 INT( 1 ) NOT NULL ,
date VARCHAR( 10 ) NOT NULL)");

        echo "Done!<br>\n";
        echo "<a href=\"index.php\">Go back to index</a>\n";
        CloseTable();
        include("footer.php");
    break;
	
	case "update":
	 $pagetitle = "Join Us: Update";
        include("header.php");
        title("$pagetitle");
        OpenTable();
		
	$db->sql_query("ALTER TABLE ".$prefix."_joinus_apps ADD age INT( 3 ) NOT NULL AFTER email");
	
	     echo "Done!<br>\n";
        echo "<a href=\"index.php\">Go back to index</a>\n";
        CloseTable();
        include("footer.php");
	break;
	
	case "uninstall":
	 $pagetitle = "Join Us: Uninstall";
        include("header.php");
        title("$pagetitle");
        OpenTable();
		
	$db->sql_query("DROP TABLE ".$prefix."_joinus_apps");
	
	     echo "Done!<br>\n";
        echo "<a href=\"index.php\">Go back to index</a>\n";
        CloseTable();
        include("footer.php");
	break;
 }

} else {
    $pagetitle = "Join Us: ERROR";
    include("header.php");
    title("$pagetitle");
    OpenTable();
    echo "<center><b>Sorry, ONLY super admins may run this script</b><center>\n";
    CloseTable();
    include("footer.php");
}
?>
this is the part that the user has to fill in:

Code: Select all

<?php

if (!defined('MODULE_FILE')) {
    die ("You can't access this file directly...");
}

///////////////////////////////////////////////////
//Choose to send a mail here !! (Yes = 1, No = 0)//
///////////////////////////////////////////////////
$sendmail = 1;
///////////////////////////////////////////////////
///////////////////////////////////////////////////

require_once("mainfile.php");
$module_name = basename(dirname(__FILE__));
$pagetitle = "- Clan Application";
get_lang($module_name);

function Index(){
global $db, $prefix, $cookie, $user, $module_name, $gfx_chk, $bgcolor1, $bgcolor2, $bgcolor3, $bgcolor4;
include("header.php");

if(is_user($user)){
cookiedecode($user);
$username = $cookie[1];
}

OpenTable();
echo"<center><font size='24' class='title'><b>Clan Application</b></font><br><hr><br>

	<span style='color:#FF3333;'><b>PLEASE NOTE!</b></span><br><br>
	If you want to apply for Full Membership into our gaming clan, then please complete our application form below.<br /> 
	Our recruitment officer will review your application and contact you via your registered email.<br />
	We encourage all new applicants to please be patient, you will be contacted.<br><br>	
	Thank You<br><br><hr><br>


    <table><tr><td>		
	<form method='post' action='modules.php?name=$module_name&op=Apply'>
	<table border='0' cellspacing='2' cellpadding='3'>			


	<tr><td align='right'><b>Your Real Name:</b><br></td>
    <td align='left'><input type='text' name='realname' value='$realname' size=35><br></td></tr>


	<tr><td align='right'><b>Your Gaming Name:</b></td>
    <td align='left'><input type='text' name='gamename' value='$gamename' size=35></td></tr>	
		
		
	<tr><td align='right'><b>Your E-mail:</b><br></td>
    <td align='left'><input type='text' name='email' value='$email' size=35><br></td></tr>
	

    <tr><td align='right'><b>Gender:</b><br></td>
    <td align='left'><select name ='gender' value='$gender'>
			<option value=''></option>	
			<option value='1'>Male</option>	
			<option value='0'>Female</option>
	</select><br></td></tr>
	
	<tr><td align='right'>&nbsp;<b>Date of Birth:</b></td>
    <td align='left'><input type='text' name='day' value='$day' size=2> <input type='text' name='month' value='$month' size=2> <input type='text' name='year' value='$year' size=4></td></tr>

	<tr><td align='right'></b></td>
    <td align='left'>&nbsp;<font style='font-size:9px;'>(dd-mm-yyyy )</font></td></tr>
	
	
	<tr><td align='right'><b>Country:</b><br></td>
    <td align='left'><select name ='country' value='$country'>
			<option value=''></option>
			<option value='Albania'>Albania</option>
			<option value='Andorra'>Andorra </option>	
			<option value='Argentina'>Argentina </option>
			<option value='Australia'>Australia </option>
			<option value='Austria'>Austria </option>
			<option value='Belarus'>Belarus </option>
			<option value='Belgium'>Belgium </option>
			<option value='Brazil'>Brazil </option>
			<option value='Bolivia'>Bolivia </option>
			<option value='Bosnia'>Bosnia </option>
			<option value='Bulgaria'>Bulgaria </option>
			<option value='Canada'>Canada </option>
			<option value='Chile'>Chile </option>
			<option value='China'>China </option>
			<option value='Colombia'>Colombia </option>
			<option value='Croatia'>Croatia </option>
			<option value='Cyprus'>Cyprus </option>
			<option value='CzechRep'>CzechRep </option>
			<option value='Denmark'>Denmark </option>
			<option value='England'>England </option>
			<option value='Estonia'>Estonia </option>
			<option value='Finland'>Finland </option>
			<option value='France'>France </option>
			<option value='Germany'>Germany </option>
			<option value='Greece'>Greece </option>
			<option value='Hungary'>Hungary </option>
			<option value='Iceland'>Iceland </option>
			<option value='India'>India </option>
			<option value='Iraq'>Iraq </option>
			<option value='Ireland'>Ireland </option>
			<option value='Israel'>Israel </option>
			<option value='Italy'>Italy </option>
			<option value='Jamaica'>Jamaica </option>
			<option value='Japan'>Japan </option>
			<option value='Korea'>Korea </option>
			<option value='Latvia'>Latvia </option>
			<option value='Liechtenstein'>Liechtenstein </option>
			<option value='Lithuania'>Lithuania </option>
			<option value='Luxembourg'>Luxembourg </option>
			<option value='Macedonia'>Macedonia </option>
			<option value='Malta'>Malta </option>
			<option value='Mexico'>Mexico </option>
			<option value='Moldova'>Moldova </option>
			<option value='Monaco'>Monaco </option>
			<option value='Morocco'>Morocco </option>
			<option value='Netherlands'>Netherlands </option>
			<option value='New Zealand'>New Zealand </option>
			<option value='Nigeria'>Nigeria </option>
			<option value='Norway'>Norway </option>
			<option value='Paraguay'>Paraguay </option>
			<option value='Poland'>Poland </option>
			<option value='Portugal'>Portugal </option>
			<option value='Romania'>Romania </option>
			<option value='Russia'>Russia </option>
			<option value='San Marino'>San Marino </option>
			<option value='Scotland'>Scotland </option>
			<option value='Singapore'>Singapore </option>
			<option value='Slovakia'>Slovakia </option>
			<option value='Slovenia'>Slovenia </option>
			<option value='South Africa'>South Africa </option>
			<option value='Spain'>Spain</option>
			<option value='Sweden'>Sweden</option>
			<option value='Switzerland'>Switzerland</option>
			<option value='Tunisia'>Tunisia</option>
			<option value='Turkey'>Turkey</option>
			<option value='Ukraine'>Ukraine</option>
			<option value='United States'>United States&nbsp;&nbsp;&nbsp;</option>
			<option value='Uraguay'>Uraguay</option>
			<option value='Venezuela'>Venezuela</option>
			<option value='Wales'>Wales</option>
			<option value='Yugoslavia'>Yugoslavia</option>
	</select><br></td></tr>	
	
	
    <tr><td align='right'><b>Xfire:</b><br></td>
    <td align='left'><input type='text' name='xfire' value='$xfire' size=35><br></td></tr>
  
  
	<tr><td align='right' valign='top'>&nbsp;<b>Select Games You Own:</b></td>
	<td align='left'> 
	<input type='checkbox' name='games[]' value='CODUO'> Call Of Duty United Offensive<br> 
	<input type='checkbox' name='games[]' value='COD2'> Call Of Duty 2<br> 
	<input type='checkbox' name='games[]' value='COD4MW'> Call Of Duty 4 Modern Warfare<br> 
	<input type='checkbox' name='games[]' value='CODWAW'> Call Of Duty 5 World At War<br> 
	<input type='checkbox' name='games[]' value='CODMW2'> Call Of Duty 6 Modern Warfare 2<br>
	<input type='checkbox' name='games[]' value='CODBO'> Call Of Duty 7 Black Ops<br>
	</td></tr>


    <tr><td align='right'><b>Working Microphone?</b><br></td>
    <td align='left'><select name ='microphone' value='$microphone'>
			<option value=''></option>	
			<option value='1'>Yes</option>	
			<option value='0'>No</option>
	</select><br></td></tr>

	
    <tr><td align='right'><b>Teamspeak 2?</b><br></td>
    <td align='left'><select name ='teamspeak2' value='$teamspeak2'>
			<option value=''></option>	
			<option value='1'>Yes</option>	
			<option value='0'>No</option>
	</select><br></td></tr>		
  
   
";
	mt_srand ((double)microtime()*1000000);
	$maxran = 1000000;
	$random_num = mt_rand(0, $maxran);
    echo "<tr><td colspan='2'>".security_code(array(1,2,3,4,5,6,7,8), 'stacked'); // Closing td and tr must be in security_code() function.

 
	echo "</table><input type='hidden' name='op' value='Apply'>
	</td></tr></table>
    <input type='submit' name='submit' value='Apply'>
    </form></center>";
CloseTable();
include("footer.php");
}

function Apply($realname, $gamename, $email, $gender, $day, $month, $year, $country, $xfire, $teamspeak2, $microphone){
global $db, $prefix, $bgcolor1, $bgcolor2, $bgcolor3, $bgcolor4, $gfx_chk, $sitekey, $sitename, $adminmail, $sendmail, $module_name;

include("header.php");
    OpenTable(); 

$match = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_joinus_apps WHERE username='$gamename'"));
if($match > 0){

	/* Already Registered Error Message */
	echo ("<center><img src=\"images/error.gif\"></center><br>");
	echo "<center><br><br><b>Sorry $gamename<br>It appears you have already submitted an application</b><br><br><br></center>";	
	echo ("<meta http-equiv='refresh' content='3;URL=http://www.yoursite.com/index.php'><br>");
	echo ("<center><b>[</b>  You Are Being Redirected  <b>]</b>");
	
}else{	
	
$gfx_check = $_POST['gfx_check'];
    if (!security_code_check($gfx_check, array(1,2,3,4,5,6,7,8))) {
	
	/* Invalid Security Code Error Message */
    echo ("<center><img src=\"images/error.gif\"></center><br>");
	echo ('<center><b>Invalid Security Code</b><br><br><br>Please go back and try again</center><br><br>');
	echo ('<center>[ <a href="javascript:history.go(-1)">Go Back</a> ]</center>'); 
	
    CloseTable(); 
    include ("footer.php"); 
    die(); 
    }else{
	security_code(array(1,2,3,4,5,6,7,8));
	}


if($realname !="" && $gamename !="" && $email !="" && $gender !="" && $day !="" && $month !="" && $year !="" && $country !="" && $xfire !=""  && $teamspeak2 !="" && $microphone !=""){

$games = $_POST['games']; 
$usergames = ""; 
for($i=0;$i<count($games);$i++){ 
if($games[$i]!=""){ 
$usergames .= "<br>".$games[$i]; 
} 
} 
if($usergames !="") 
$usergames = substr($usergames,2);

$db->sql_query("INSERT INTO ".$prefix."_joinus_apps VALUES (NULL, '$realname', '$gamename', '$email', '$gender', '$day', '$month', '$year', '$country', '$xfire', '$usergames', '$teamspeak2', '$microphone', now())");

if($sendmail == 1){
	$to = $adminmail;
	$emailsubject = 'Clan Application';
	$message = 'There is a new <b>Clan Application</b> awaiting your attention!!';
	$header = "From: $gamename <$email>\n";
	$header .= "Reply-To: $email";
	mail($to,$emailsubject,$message,$header);
	
}

	/* Success Message */
	echo ("<center><img src=\"images/success.gif\"></center><br>");
	echo ("<center><b>Your Membership Application has been successfully submitted!</b><br><br><br>");
	echo ("<meta http-equiv='refresh' content='5;URL=http://www.yoursite/index.php'><br>");
    echo ("<center><b>[</b>  You will now be redirected  <b>]</b>");
	
}else{

	/* Error Message */
	echo ("<center><img src=\"images/error.gif\"></center><br>");
	echo ("<center><b>Please Complete All Fields!</b></center><br>");
	echo ('<center>[ <a href="javascript:history.go(-1)">Go Back</a> ]</center>');
}
}

CloseTable();
include("footer.php");
}

switch ($op) {

    default:
	Index();
    break;
	
	case "Apply":
	Apply($realname, $gamename, $email, $gender, $day, $month, $year, $country, $xfire, $teamspeak2, $microphone);
	break;

}

?>
and this file is the part that when i goto my admin panel, shows me who has filled out my application form:

Code: Select all

<?php

if (!defined('ADMIN_FILE')) {
	die ("Access Denied");
}

$module_name = "Join_Us";

global $prefix, $db, $admin_file;
$aid = substr("$aid", 0,25);
$row = $db->sql_fetchrow($db->sql_query("SELECT title, admins FROM ".$prefix."_modules WHERE title='Join_Us'"));
$row2 = $db->sql_fetchrow($db->sql_query("SELECT name, radminsuper FROM ".$prefix."_authors WHERE aid='$aid'"));
$admins = explode(",", $row['admins']);
$auth_user = 0;
for ($i=0; $i < sizeof($admins); $i++) {
	if ($row2['name'] == "$admins[$i]" AND !empty($row['admins'])) {
		$auth_user = 1;
	}
}

if ($row2['radminsuper'] == 1 || $auth_user == 1) {

	function Join_Us() {
		global $prefix, $db, $admin_file, $bgcolor1, $bgcolor2, $bgcolor3, $bgcolor4;
		include ("header.php");
		OpenTable();
			echo"<center><font class='title'><b>Clan Applications</b></font><br><br>"; 
			
			$rows = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_joinus_apps"));
			echo"<table><tr><td>";
			if($rows > 0){
			echo"<table border='0' cellpadding='3' cellspacing='1' bgcolor=$bgcolor4>";
			echo"<tr bgcolor=$bgcolor3><td><b>&nbsp;&nbsp;&nbsp;&nbsp;Applicants Name&nbsp;&nbsp;&nbsp;&nbsp;</b></td><td><b>&nbsp;&nbsp;&nbsp;&nbsp;Application Date&nbsp;&nbsp;&nbsp;&nbsp;</b></td><td><b></b></td></tr>";
		$result = $db->sql_query("SELECT * FROM ".$prefix."_joinus_apps ORDER BY date ASC");
			while($row = $db->sql_fetchrow($result)){
			$appid = $row['aid'];
			$gamename = $row['gamename'];
			$appdate = $row['date'];
			echo"<tr bgcolor=$bgcolor1>
			<td><a href=\"".$admin_file.".php?op=Join_Us_Info&appid=$appid\">$gamename</a></td>
			<td>$appdate</td>
			<td><a href=\"".$admin_file.".php?op=Join_Us_Delete&appid=$appid&ok=0\"><img src=\"images/delete.gif\" alt='Delete' title='Delete' border=\"0\"></a></td></tr>";
			}
			echo"</table>";
			}else{
			echo'No New Applications';
			}
			echo"</td></tr></table>";
		CloseTable();		
		include ("footer.php");
	}

	function Join_Us_Info($appid) {
	global $prefix, $db, $admin_file, $bgcolor1, $bgcolor2, $bgcolor3, $bgcolor4;

include("header.php");
OpenTable();

$row = $db->sql_fetchrow($db->sql_query("SELECT * FROM ".$prefix."_joinus_apps WHERE aid='$appid'"));
	$realname = $row['realname'];
	$gamename = $row['gamename'];	
	$email = $row['email'];
	$gender = $row['gender'];
	$day = $row['day'];
	$month = $row['month'];
	$year = $row['year'];
	$country = $row['country'];
	$xfire = $row['xfire'];
	$games = $row['games'];
	$microphone = $row['microphone'];
	$teamspeak2 = $row['teamspeak2'];
	$appdate = $row['date'];

if($gender == 1){
$gender ="Male";
}else{
$gender ="Female";
}	
	
if($teamspeak2 == 1){
$teamspeak2 ="Yes";
}else{
$teamspeak2 ="No";
}	

if($microphone == 1){
$microphone ="Yes";
}else{
$microphone ="No";
}

echo"<center><font class='title'><b>Clan Applications</b></font><br><br>
    <table cellpadding='3' cellspacing='1' border='0' width='300' bgcolor='$bgcolor4'>
	
	
		<tr><td align='left' bgcolor='$bgcolor2' nowrap><b>Real Name:</b></td>
		<td align='left' bgcolor='$bgcolor1'>$realname</td></tr>
		
		
		<tr><td align='left' bgcolor='$bgcolor2' nowrap><b>Gaming Name:</b></td>
		<td align='left' bgcolor='$bgcolor1'>$gamename</td>
		</tr>		
		
		
		<tr><td align='left' bgcolor='$bgcolor2' nowrap><b>E-Mail:</b></td>
		<td align='left' bgcolor='$bgcolor1'><a href='mailto:$email'>$email</a></td>
		</tr>
		
		
		<tr><td align='left' bgcolor='$bgcolor2' nowrap><b>Gender:</b></td>
		<td align='left' bgcolor='$bgcolor1'>$gender</td>
		</tr>


		<tr><td align='left' bgcolor='$bgcolor2' nowrap><b>Date of Birth:</b></td>
		<td align='left' bgcolor='$bgcolor1'>$day-$month-$year</td>
		</tr>	
		
			
		<tr><td align='left' bgcolor='$bgcolor2' nowrap><b>Country:</b></td>
		<td align='left' bgcolor='$bgcolor1'>$country</td>
		</tr>				
		
		
		<tr><td align='left' bgcolor='$bgcolor2' nowrap><b>Xfire:</b></td>
		<td align='left' bgcolor='$bgcolor1'><a href='http://www.xfire.com/profile/$xfire' target='_blank'>$xfire</a></td>
		</tr>

		<tr><td align='left' valign='top' bgcolor='$bgcolor2' nowrap><b>Games Owned:</b></td> 
        <td align='left' bgcolor='$bgcolor1'>$games</td> 
        </tr>
		
		<tr><td align='left' bgcolor='$bgcolor2' nowrap><b>Microphone:</b></td>
		<td align='left' bgcolor='$bgcolor1'>$microphone</td>
		</tr>	
		
		
		<tr><td align='left' bgcolor='$bgcolor2' nowrap><b>Teamspeak 2:</b></td>
		<td align='left' bgcolor='$bgcolor1'>$teamspeak2</td>
		</tr>";
		
		
echo"</table>
<br><br><b>[</b> <a href=\"".$admin_file.".php?op=Join_Us\">Go Back</a> <b>|</b> <a href=\"".$admin_file.".php?op=Join_Us_Delete&appid=$appid&ok=0\">Delete Application</a> <b>]</b>
	</center>";
CloseTable();
include("footer.php");

}	
	
	
	
	
	function Join_Us_Delete($appid, $ok=0) {
	global $prefix, $db, $admin_file;
	if ($ok == 1) {
	
		$db->sql_query("delete from ".$prefix."_joinus_apps where aid='$appid'");
		
		Header("Location: ".$admin_file.".php?op=Join_Us");
	} else {
		include("header.php");
		OpenTable();
		echo"<center><br><br>Are you sure you want to delete this application?<br><br>"
		."[ <a href=\"".$admin_file.".php?op=Join_Us\">"._NO."</a> | <a href=\"".$admin_file.".php?op=Join_Us_Delete&appid=$appid&ok=1\">"._YES."</a> ]</center><br><br>";
	CloseTable();
	include("footer.php");
}
}	

	switch ($op) {

		case "Join_Us":
		Join_Us();
		break;
		
		case "Join_Us_Info":
		Join_Us_Info($appid);
		break;
		
		case "Join_Us_Delete":
		Join_Us_Delete($appid, $ok);
		break;
		
		}
} else {
	include("header.php");
	GraphicAdmin();
	OpenTable();
	echo "<center><b>"._ERROR."</b><br><br>You do not have permission to access this module \"$module_name\"</center>";
	CloseTable();
	include("footer.php");
}

?>
i suppose i should of posted these scripts in the first place then you would probably been able to see what i was on about, sorry about that sir.

anyways, whats happening is this:

1) when the user fills out the form, the imputted data gets relayed back to my admin section so i can view who has applied and with what credentials.
the 2 parts i'm struggling with is:

the user selects which country they are from by using the dropdown format.
when he/she hits submit, it sends the data to my sql then back to my admin section where i can view what he/she has selected, but it only shows this as 1 and not the country they selected.

2) when the user selects what games they have by putting ticks next to the game title the data that gets sent back to my admin section shows up as again 1 and not the titles that the user has ticked.

i am trying to be clear about what is going on, sorry if this all sounds kuckoo.

but i know what i am on about but it's trying to explain it the best way i know how considering my knowledge of php and databases are very limited.
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: sql database quiery

Post by califdon »

I won't try to read all those scripts, but the fact that you are using a content management system is pertinent. Basically, I wouldn't create a new table for every user. That will make it extremely difficult to extract data about the total game environment. I know very little about game software, but ordinarily, a database table represents a whole class of things, such as people, or objects, or documents, or events, or transactions. Each table might contain hundreds, thousands, or millions of records, each one representing one of those things. My guess is that what you need is ONE table, into which you store records, one for each player. Thus, your script would NOT contain SQL that begins "CREATE TABLE..." Instead, it would contain SQL that begins "INSERT INTO tblPlayers...". You would create the one table just one time, even before you write your first script.

I don't have the familiarity with games that would enable me to give you much more help, but I think you're on the wrong track the way you're going.
utdfederation
Forum Newbie
Posts: 7
Joined: Fri Aug 29, 2008 6:57 pm

Re: sql database quiery

Post by utdfederation »

nono it's not that kind of database.

this is what i mean sir:
the user fills out this form.
Image

the the data gets processed and sent to here in my admin section telling me who the new user is and what they selected:
Image

as you can see i have selected the country Canada but in the bottom image it reports it back saying i chose 0 when it should say canada
and again as you can see i have selected 3 game titles but in the bottom image it reports it back saying i selected 0 when it should say the game title names,
such as:
Call Of Duty: United Offensive, Call Of Duty 2, Call Of Duty 4 Modern Warfare
utdfederation
Forum Newbie
Posts: 7
Joined: Fri Aug 29, 2008 6:57 pm

Re: sql database quiery

Post by utdfederation »

but there is something wrong with the country selection in the install file listed above with the data inside it and there is something wrong with the way sql is reporting or naming what games the user has selected.
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: sql database quiery

Post by califdon »

None of that means anything to me, but more importantly, none of that means anything to the way the database is designed. What do you mean by "it's not that kind of database"?? A database is a database, and it must be designed properly or it won't do the job.

The failure of data to be stored in the database (or perhaps reported back from the database) is an unrelated issue. That is undoubtedly caused by a defect in the PHP code that either writes the data or reads the data. That's probably somewhere in the content management system code. Have you made changes to any of that code, such as adding the Country field? If you did, you no doubt overlooked one place in the code that needed to be changed.
utdfederation
Forum Newbie
Posts: 7
Joined: Fri Aug 29, 2008 6:57 pm

Re: sql database quiery

Post by utdfederation »

yes that was it. adding a country field
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: sql database quiery

Post by califdon »

That's not an easy task, even for someone who is experienced. You would have to trace through all the logic of every script that could be involved, determining how the original author handled each operation that involved the form fields in any way, and make appropriate changes. That's far more than can be accomplished in a forum like this. I'm sorry to be so negative, but it's not something I would undertake.
User avatar
getmizanur
Forum Commoner
Posts: 71
Joined: Sun Sep 06, 2009 12:28 pm

Re: sql database quiery

Post by getmizanur »

looking at your create table code your "country" field is type int(1) that is why you are getting 0.

change your country field type to varchar

Code: Select all

$db->sql_query("CREATE TABLE ".$prefix."_joinus_apps (
aid INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
realname VARCHAR( 25 ) NOT NULL ,
gamename VARCHAR( 25 ) NOT NULL ,
email VARCHAR( 50 ) NOT NULL ,
gender INT( 1 ) NOT NULL ,
day VARCHAR( 2 ) NOT NULL ,
month VARCHAR( 2 ) NOT NULL ,
year VARCHAR( 4 ) NOT NULL , 
country INT( 1 ) NOT NULL ,
xfire VARCHAR (25) NOT NULL ,
games INT( 1 ) NOT NULL ,
microphone INT( 1 ) NOT NULL ,
teamspeak2 INT( 1 ) NOT NULL ,
date VARCHAR( 10 ) NOT NULL)");
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: sql database quiery

Post by califdon »

getmizanur wrote:looking at your create table code your "country" field is type int(1) that is why you are getting 0.

change your country field type to varchar
It's probably an Int because it's a foreign key into a table of Countries, which is why it is so difficult to make changes to an application written by someone else. If you change that field's datatype in the database without understanding why it was coded that way, you could lose all your country information. Experienced developers can analyze the entire application and determine what to do, but a beginner can get into a lot of trouble trying to modify a complex application.
User avatar
getmizanur
Forum Commoner
Posts: 71
Joined: Sun Sep 06, 2009 12:28 pm

Re: sql database quiery

Post by getmizanur »

califdon wrote: It's probably an Int because it's a foreign key into a table of Countries, which is why it is so difficult to make changes to an application written by someone else
mmm...i don't think it is a foreign key. the field type int(1) is too small to be a foreign key, it only can hold values of 0-9. it can't be regions because there is more than 10 regions in the world (plus it does not make sense to be regions). also, the questioner has added the country field so the questioner either must have added country field to the table or the original programmer may have got it wrong which i doubt.
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Re: sql database quiery

Post by superdezign »

That is incorrect. The number in the parentheses is the display width and does not affect the range of data that can be held. It most likely is a foreign key, especially if you did not design this table yourself.
User avatar
getmizanur
Forum Commoner
Posts: 71
Joined: Sun Sep 06, 2009 12:28 pm

Re: sql database quiery

Post by getmizanur »

That is incorrect. The number in the parentheses is the display width
cheers, for pointing that out.
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Re: sql database quiery

Post by superdezign »

That's what DevNet is all about. We share our thoughts and then we improve each other's knowledge. :D
Post Reply