Jump to content

Insert from phpadmin versus form?


twilitegxa

Recommended Posts

<?php

session_start();

//Access Tracking Snippet

//set up static variables
$page_title = "showprofile.php";
$user_agent = getenv("HTTP_USER_AGENT");
$date_accessed = date("Y-m-d");

//connect to server and select database
$conn = mysql_connect("localhost", "root", "")
    or die(mysql_error());
$db = mysql_select_db("smrpg", $conn) or die(mysql_error());

//create and issue query
$sql = "insert into access_tracker values
    ('', '$page_title', '$user_agent', '$date_accessed')";
mysql_query($sql,$conn);
?>

<?php
//check for required info from the query string
if (!$_GET['id']) {
    header("Location: listcharacters.php");
    exit;
}

//connect to server and select database
$conn = mysql_connect("localhost", "root", "")
    or die(mysql_error());
mysql_select_db("smrpg", $conn) or die(mysql_error());

//verify the topic exists
$verify_topic = "select identity from scouts where
    id = $_GET[id]";
$verify_topic_res = mysql_query($verify_topic, $conn)
    or die(mysql_error());

if (mysql_num_rows($verify_topic_res) < 1) {
    //this character does not exist
    $display_block = "<p><em>You have selected an invalid character.
    Please <a href=\"listcharacters.php\">try again</a></em></p>";
} else {
    //gather rest of profile
    $get_posts = "select *, date_format(create_time, '%b %e %Y at %r') as fmt_scout_create_time from scouts where id = $_GET[id]";
        
    $get_posts_res = mysql_query($get_posts, $conn) or die(mysql_error());
    
    //create the display string
    $display_block = "
    <table cellpadding=3 cellspacing=1 border=0 class=list_tables>";
    
    while ($posts_info = mysql_fetch_array($get_posts_res)) {
        $post_id = $posts_info['id'];
        $identity = ucwords($posts_info['identity']);
        $character_create_time = $posts_info['fmt_scout_create_time'];
        $username = $posts_info['username'];
        $name = ucwords(strtolower($posts_info['name']));
        $element_of_influence = $posts_info['element_of_influence'];
        $age = $posts_info['age'];
        $birth_month = $posts_info['birth_month'];
        $birth_date = $posts_info['birth_date'];
        $birth_year = $posts_info['birth_year'];
        $height_feet = $posts_info['height_feet'];
        $height_inches = $posts_info['height_inches'];
        $blood_type = strtoupper($posts_info['blood_type']);
        $hobbies = ucwords(strtolower($posts_info['hobbies']));
        $favorite_color = ucwords(strtolower($posts_info['favorite_color']));
        $favorite_gemstone = ucwords(strtolower($posts_info['favorite_gemstone']));
        $favorite_food = ucwords(strtolower($posts_info['favorite_food']));
        $least_favorite_food = ucwords(strtolower($posts_info['least_favorite_food']));
        $favorite_school_subject = ucwords(strtolower($posts_info['favorite_school_subject']));
        $least_favorite_school_subject = ucwords(strtolower($posts_info['least_favorite_school_subject']));
        $strengths = ucwords(strtolower($posts_info['strengths']));
        $weaknesses = ucwords(strtolower($posts_info['weaknesses']));
        $goal = ucfirst($posts_info['goal']);
        $mission = ucfirst($posts_info['mission']);
        $biography = nl2br($posts_info['biography']);
        $biography = str_replace("\n", "<p>", $biography );
        $getMonth = date('F', mktime(0, 0, 0, $birth_month));
        $character_attack_level = $posts_info['attack_level'];
        
    $get_images = "select * from upload where identity = '$identity'";
    $get_images_res = mysql_query($get_images, $conn) or die(mysql_error());
    
    while ($images_info = mysql_fetch_array($get_images_res)) {
        $image_id = $images_info['id'];
        $image_identity = $images_info['identity'];
        $image_name = $images_info['name'];
        $image_type = $images_info['type'];
        $image_size = $images_info['size'];
        $image_content = $images_info['content'];
        
        //add to display
        $display_block .= "
        <tr>
        <td width=24% valign=top><strong>Character Name:</strong></td>
        <td width=55% valign=top>$name</td>
        <td align=center valign=top rowspan=18><img src='download.php?id=$image_id'></td>
        </tr>
        <tr>
        <td><strong>Element Of Influence:</strong></td>
        <td>$element_of_influence</td>
        </tr>
        <tr>
        <td><strong>Age:</strong></td>
        <td>$age</td>
        </tr>
        <tr>
        <td><strong>Date Of Birth:</strong></td>
        <td>$getMonth $birth_date, $birth_year</td>
        </tr>
        <tr>
        <td><strong>Height:</strong></td>
        <td>$height_feet feet $height_inches inches</td>
        </tr>
        <tr>
        <td><strong>Blood Type:</strong></td>
        <td>$blood_type</td>
        </tr>
        <tr>
        <td><strong>Hobbies:</strong></td>
        <td>$hobbies</td>
        </tr><tr>
        <td><strong>Favorite Color:</strong></td>
        <td>$favorite_color</td>
        </tr>
        <tr>
        <td><strong>Favorite Gemstone:</strong></td>
        <td>$favorite_gemstone</td>
        </tr>
        <tr>
        <td><strong>Favorite Food:</strong></td>
        <td>$favorite_food</td>
        </tr>
        <tr>
        <td><strong>Least Favorite Food:</strong></td>
        <td>$least_favorite_food</td>
        </tr>
        <tr>
        <td><strong>Favorite School Subject:</strong></td>
        <td>$favorite_school_subject</td>
        </tr>
        <tr>
        <td><strong>Least Favorite School Subject:</strong></td>
        <td>$least_favorite_school_subject</td>
        </tr>
        <tr>
        <td><strong>Strengths:</strong></td>
        <td>$strengths</td>
        </tr>
        <tr>
        <td><strong>Weaknesses:</strong></td>
        <td>$weaknesses</td>
        </tr>
        <tr>
        <td><strong>Goal:</strong></td>
        <td>$goal...</td>
        </tr>
        <tr>
        <td><strong>Mission:</strong></td>
        <td>$mission.</td>
        </tr>
        <td> </td>
        <td> </td>
        </tr>
        <tr>
        <td align=right colspan=3>Created By: <strong>$username</strong><br>
        Created On: <em>$character_create_time</em></td>
        </tr>";
        }
        
        //close up the table
        $display_block .= "</table><br>
        <p>$biography</p><br>";
}
}

//gather stats and derived values; fix where statement

$get_stats = "select * from stats where identity = '$identity'";

$get_stats_res = mysql_query($get_stats, $conn) or die(mysql_error());

$display_block .= "
<table cellpadding=3 cellspacing=3 border=0 width=100%>";

while ($stats_info = mysql_fetch_array($get_stats_res)) {
        $body = $stats_info['body'];
        $mind = $stats_info['mind'];
        $soul = $stats_info['soul'];
        
$display_block .= "
<tr>
<td valign=top>
<table cellspacing=3 cellpadding=3 border=0 width=90% align=center class=list_tables>
<th colspan=3>Stats And Derived Values</th>
<tr>
<td>Body</td>
<td class=align_levels>$body</td>
<td> </td>
</tr>
<tr>
<td>Mind</td>
<td class=align_levels>$mind</td>
<td> </td>
</tr>
<tr>
<td>Soul</td>
<td class=align_levels>$soul</td>
<td> </td>
</tr>";
}

//gather derived values
$get_derived = "select * from derived_values where identity = '$identity'";

$get_derived_res = mysql_query($get_derived, $conn) or die(mysql_error());

while ($derived_info = mysql_fetch_array($get_derived_res)) {
    $health = $derived_info['health'];
    $energy = $derived_info['energy'];
    $acv1 = $derived_info['acv1'];
    $acv2 = $derived_info['acv2'] . ' (for Sailor Scout Attack)';
    $dcv1 = $derived_info['dcv1'];
    $dcv2 = $derived_info['dcv2'] . ' (for Sailor Scout Attack)';
    $total_cp = $derived_info['total_cp'];
    
if($health == 0 || $health == '0' || $health == null){$GLOBALS['health'] = "";}
if($energy == 0 || $energy== '0' || $energy == null){$GLOBALS['energy'] = "";}
if($acv1 == 0 || $acv1 == '0' || $acv1 == null){$GLOBALS['acv1'] = "";}
if($acv2 == 0 || $acv2 == '0' || $acv2 == null){$GLOBALS['acv2'] = "";}
if($dcv1 == 0 || $dcv1 == '0' || $dcv1 == null){$GLOBALS['dcv1'] = "";}
if($dcv2 == 0 || $dcv2 == '0' || $dcv2 == null){$GLOBALS['dcv2'] = "";}
if($total_cp == 0 || $total_cp == '0' || $total_cp== null){$GLOBALS['total_cp'] = "";}

$display_block .= "
<tr>
<td colspan=3> </td>
</tr>
<tr>
<td>Health Points</td>
<td class=align_levels>$health</td>
<td> </td>
</tr>
<tr>
<td>Energy Points</td>
<td class=align_levels>$energy</td>
<td> </td>
</tr>
<tr>
<td>Attack Combat Value</td>
<td class=align_levels>$acv1</td>
<td>$acv2</td>
</tr>
<tr>
<td>Defense Combat Value</td>
<td class=align_levels>$dcv1</td>
<td>$dcv2</td>
</tr>
<tr>
<td>Total Character Points</td>
<td class=align_levels>$total_cp</td>
<td> </td>
</tr>
</table><br>";

}

//gather defects
$get_defects = "select * from scout_defects where identity = '$identity'";
$get_defects_res = mysql_query($get_defects, $conn) or die(mysql_error());

$display_block .= "

<table cellpadding=3 cellspacing=3 border=0 width=90% align=center class=list_tables>
<th colspan=3>Character Defects</th>";

while ($defects_info = mysql_fetch_array($get_defects_res)) {
    $defects_id = $defects_info['id'];
    $defects_identity = $defects_info['identity'];
    $defects_id = $defects_info['defect_id'];
    $desc = $defects_info['desc'];
    $defects_level = $defects_info['level'];
    
    if($defects_info['desc'] != ""){
   $desc = "(" . $defects_info['desc'] . ")";
}else{
   $desc = "";
}
    
$get_defects_names = "select * from defects where id = '$defects_id'";
$get_defects_names_res = mysql_query($get_defects_names, $conn) or die(mysql_error());

while ($defects_names_info = mysql_fetch_array($get_defects_names_res)) {
    $defects_names_id = $defects_names_info['id'];
    $defect = $defects_names_info['defect'];
    
$display_block .= "
    
<tr>
<td>$defect $desc</td>
<td>$defects_level</td>
<td> </td>
</tr>";

}
}

$display_block .= "
</table></td>";

// gather attributes and sub-attributes
$get_attributes = "select * from scout_attributes where identity = '$identity'";

$get_attributes_res = mysql_query($get_attributes, $conn)
    or die(mysql_error());

$display_block .= "
<td valign=top>
<table cellspacing=3 cellpadding=3 border=0 width=90% align=center class=list_tables>    
<th colspan=3>Character Attributes And Sub-Attributes</th>
<tr>
<td align=center><b>Attribute/Sub-Attribute</b></td>
<td align=center><b>Level</td>
<td align=center><b>Points</b></td>
</tr>";

while ($attributes_info = mysql_fetch_array($get_attributes_res)) {
    $attributes_id = $attributes_info['id'];
    $attribute_identity = $attributes_info['identity'];
    $attribute_id = $attributes_info['attribute_id'];
    $attribute_level = $attributes_info['level_id'];

$get_attribute_names = "SELECT * FROM attributes WHERE id = '$attribute_id'";

$get_attribute_names_res = mysql_query($get_attribute_names, $conn) or die(mysql_error());
    
while ($attribute_names_info = mysql_fetch_array($get_attribute_names_res)) {
    $attribute_names_id = $attribute_names_info['id'];
    $attribute_names_attribute = $attribute_names_info['attribute'];
    $attributes_names_points = $attribute_names_info['points'];
    $attributes_points = ($attributes_names_points * $attribute_level);

    $display_block .= "
    
<tr>
<td>$attribute_names_attribute</td>
<td class=align_levels>$attribute_level</td>
<td class=align_levels>$attributes_points</td>
</tr>";

}
}

$get_sub_attributes = "select * from scout_sub_attributes where identity = '$identity'";
$get_sub_attributes_res = mysql_query($get_sub_attributes, $conn) or die(mysql_error());

while ($sub_attributes_info = mysql_fetch_array($get_sub_attributes_res)) {
    $sub_attributes_id = $sub_attributes_info['id'];
    $sub_attributes_identity = $sub_attributes_info['identity'];
    $sub_attributes_attribute_id = $sub_attributes_info['sub_attribute_id'];
    $sub_attributes_level_id = $sub_attributes_info['level_id'];
    $sub_attributes_notes = $sub_attributes_info['notes'];
    
$get_sub_attribute_names = "select * from sub_attributes where id = '$sub_attributes_attribute_id'";
$get_sub_attribute_names_res = mysql_query($get_sub_attribute_names, $conn) or die(mysql_error());

while ($sub_attribute_names_info = mysql_fetch_array($get_sub_attribute_names_res)) {
    $sub_attribute_names_id = $sub_attribute_names_info['id'];
    $sub_attribute_names_attribute = $sub_attribute_names_info['sub_attribute'];
    $sub_attribute_names_points = $sub_attribute_names_info['points'];
    $sub_attributes_points = ($sub_attribute_names_points * $sub_attributes_level_id);

Link to comment
Share on other sites

$display_block .= "
<tr>
<td class=indent>$sub_attribute_names_attribute</td>";    

if ($sub_attributes_level_id == null) {
    $display_block .= "<td> </td>
    <td> </td></tr>";
    } else {
$display_block .= "
<td class=align_levels>$sub_attributes_level_id</td>
<td class=align_levels>$sub_attributes_points</td></tr>";
}

//gather attacks
$get_items = "select * from items where identity = '$identity' and acquired = 1 order by level asc";
$get_items_res = mysql_query($get_items, $conn) or die(mysql_error());

while ($items_info = mysql_fetch_array($get_items_res)) {
    $item_id = $items_info['id'];
    $item_identity = $items_info['identity'];
    $items = $items_info['item'];
    $item_desc = $items_info['desc'];
    $item_level = $items_info['level'];
    $item_points = ($sub_attribute_names_points * $item_level);
    
if ($sub_attribute_names_attribute == 'Item Of Power') {
$display_block .= "
<tr>
<td class=indent2>- $items</td>
<td class=align_levels>$item_level</td>
<td class=align_levels>$item_points</td>
</tr>
<tr>";

}
}

}
}

//gather attacks
$get_attacks = "select * from attacks where identity = '$identity' and level <= '$character_attack_level' and learned = 1 order by level desc";
$get_attacks_res = mysql_query($get_attacks, $conn) or die(mysql_error());

while ($attacks_info = mysql_fetch_array($get_attacks_res)) {
    $attack_id = $attacks_info['id'];
    $attack_identity = $attacks_info['identity'];
    $attack = $attacks_info['attack'];
    $primary = $attacks_info['primary_attack'];
    $secondary = $attacks_info['secondary_attack'];
    $attack_level = $attacks_info['level'];
    $attack_points = ($sub_attribute_names_points * $attack_level);
    $learned = $attacks_info['learned'];
    
//checks for primary and secondary attacks
    if($secondary == 1) $attack_points = 2;
elseif($primary == 0 && $secondary == 0) $attack_points = 1;

if ($sub_attribute_names_attribute == 'Sailor Scout Attack') {
$display_block .= "
<tr>
<td class=indent2>- $attack</td>
<td class=align_levels>$attack_level</td>
<td class=align_levels>$attack_points</td>
</tr>
<tr>";

}
}

//gather neutral attributes
$get_neutral_attributes = "select * from scout_neutral_attributes where identity = '$identity'";
$get_neutral_attributes_res = mysql_query($get_neutral_attributes, $conn) or die(mysql_error());

while ($neutral_attributes_info = mysql_fetch_array($get_neutral_attributes_res)) {
    $neutral_attributes_id = $neutral_attributes_info['id'];
    $neutral_attributes_identity = $neutral_attributes_info['identity'];
    $neutral_attributes_attribute_id = $neutral_attributes_info['attribute_id'];
    $neutral_attributes_level_id = $neutral_attributes_info['level_id'];
    
$get_neutral_attribute_names = "select * from neutral_attributes where id = '$neutral_attributes_attribute_id'";
$get_neutral_attribute_names_res = mysql_query($get_neutral_attribute_names, $conn) or die(mysql_error());

while ($neutral_attribute_names_info = mysql_fetch_array($get_neutral_attribute_names_res)) {
    $neutral_attribute_names_id = $neutral_attribute_names_info['id'];
    $neutral_attribute_names_attribute = $neutral_attribute_names_info['attribute'];
    $neutral_attribute_names_points = $neutral_attribute_names_info['points'];
    $neutral_attribute_points = ($neutral_attributes_level_id * $neutral_attribute_names_points);
    
$display_block .= "
<tr>
<td>$neutral_attribute_names_attribute</td>
<td class=align_levels>$neutral_attributes_level_id</td>
<td class=align_levels>$neutral_attribute_points</td>
</tr>";

}
}

$display_block .= "
</table></td></tr></table><br>";

$display_block .= "
<table border=0 width=100%>
<tr>
<td width=50% valign=top>
<table>
<tr>
<td align=center><h1>Items Of Power</h1></td>";

$get_items = "select * from items where identity = '$identity' and acquired = 1";
$get_items_res = mysql_query($get_items, $conn) or die(mysql_error());

while ($items_info = mysql_fetch_array($get_items_res)) {
    $items_id = $items_info['id'];
    $items_identity = $items_info['identity'];
    $item = $items_info['item'];
    $item_desc = nl2br($items_info['desc']);
    $item_level = $items_info['level'];
    $item_points = ($sub_attribute_names_points * $item_level);
    
$display_block .= "
<tr>
<td class=hanging-indent>
<i>$item --- </i><br>
$item_desc</td></tr>";

}

$display_block .= "</table></td><td valign=top width=50%>
<table>
<tr>
<td align=center><h1>Sailor Scout Attacks</td></tr>";

//gather attacks
$get_attacks = "select * from attacks where identity = '$identity' and learned = 1 order by level asc";
$get_attacks_res = mysql_query($get_attacks, $conn) or die(mysql_error());

while ($attacks_info = mysql_fetch_array($get_attacks_res)) {
    $attack_id = $attacks_info['id'];
    $attack_identity = $attacks_info['identity'];
    $attack = $attacks_info['attack'];
    $attack_desc = nl2br($attacks_info['desc']);
    $primary = $attacks_info['primary_attack'];
    $secondary = $attacks_info['secondary_attack'];
    $attack_level = $attacks_info['level'];
    $attack_points = ($sub_attribute_names_points * $attack_level);
    
    $display_block .= "
<tr>
<td class=hanging-indent>
<i>$attack --- </i><br>
$attack_desc</td></tr>";

}

$display_block .= "</table></td></tr></table>";

$display_block .= "<table border=0 cellpadding=3 cellspacing=3 width=100%>
    <tr>
    <td width=50% valign=top>
    <table>
    <tr>
    <td align=center><h1>Transformations</h1></td>
    </tr>";

$get_transformations = "select * from transformations where identity = '$identity'";
$get_transformations_res = mysql_query($get_transformations, $conn) or die(mysql_error());

while ($transformation_info = mysql_fetch_array($get_transformations_res)) {
    $transformation_id = $transformation_info['id'];
    $transformation_identity = $transformation_info['identity'];
    $transformation = $transformation_info['transformation'];
    $transformation_desc = $transformation_info['desc'];
    $transformation_level = $transformation_info['level'];
    
    $display_block .= "
    <tr>
    <td class=hanging-indent>
    <i>$transformation --- </i><br>
    $transformation_desc</td></tr>";
    
    }
    
    $display_block .= "</table></td>
    <td width=50% valign=top>
    <table>
    <tr>
    <td align=center><h1>Attribute/Sub-Attribute Notes</h1></td></tr>
    <tr>
    <td>
    <ol>";
    
//gather attributes and sub-attributes notes

$get_sub_notes = "select * from scout_sub_attributes where identity = '$identity' and notes IS NOT NULL";
$get_sub_notes_res = mysql_query($get_sub_notes, $conn) or die(mysql_error());

while ($sub_notes_info = mysql_fetch_array($get_sub_notes_res)) {
    $sub_notes = nl2br($sub_notes_info['notes']);
    $sub_id = $sub_notes_info['sub_attribute_id'];
    
    $display_block.= "
    <li>$sub_notes</li>";
    
    }
    
//gather neutral notes

$get_neutral_notes = "select notes from scout_neutral_attributes where identity = '$identity' and notes IS NOT NULL";
$get_neutral_notes_res = mysql_query($get_neutral_notes, $conn) or die(mysql_error());

while ($neutral_notes_info = mysql_fetch_array($get_neutral_notes_res)) {
    $neutral_notes = nl2br($neutral_notes_info['notes']);
    
    $display_block .= "
    <li>$neutral_notes</li>";
    
    }
    
//gather defect notes

$get_defect_notes = "select notes from scout_defects where identity = '$identity' and notes IS NOT NULL";
$get_defect_notes_res = mysql_query($get_defect_notes, $conn) or die(mysql_error());

while ($defect_notes_info = mysql_fetch_array($get_defect_notes_res)) {
    $defect_notes = nl2br($defect_notes_info['notes']);
    
    $display_block .= "
    <li>$defect_notes</li>";
    
    }
    
    $display_block .= "</ol></table></td></tr></table>";

?>
<html>
<head>
<title><?php print $identity; ?>'s Profile</title>
<style type="text/css" media="screen">
/*<![CDATA[*/
@import url(global.css); 
/*]]>*/
</style>
</head>
<body>
<!-- HEADER -->
<h1 class="logo">Sailor Moon RPG</h1>
<!-- /HEADER -->
<?php include("topnav.php"); ?>
<div id="main">
<?php include("includes/log.php"); ?>
<?php include("mainnav.php"); ?>
<h1 align="center"><?php print $identity; ?></h1>
<?php print $display_block; ?>
</div>
<?php include("bottomnav.php"); ?><!-- FOOTER -->
<!-- FOOTER -->
<div id="footer_wrapper">
<div id="footer">
<p>Sailor Moon and all characters
are<br /> 
trademarks of Naoko Takeuchi.</p>
<p>Copyright © 2009 Liz Kula. All rights reserved.<br />
A product of <a href="#" target="_blank">Web Designs By Liz</a> systems.</p>
<div id="foot-nav">
<ul>
<li><a href="http://validator.w3.org/check?uri=http://webdesignsbyliz.com/digital/index.php" target="_blank"><img src="http://www.w3.org/Icons/valid-xhtml10-blue" alt="Valid XHTML 1.0 Transitional" height="31" width="88" /></a></li>
<li><a href="http://jigsaw.w3.org/css-validator/validator?uri=http://webdesignsbyliz.com/digital/global.css" target="_blank"><img class="c2" src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="Valid CSS!" /></a></li>
</ul>
</div>
</div>
</div>
<!-- /FOOTER -->
</body>
</html>

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.