1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Problem With Get Variable

Discussion in 'PHP' started by Jeremy Benson, Jun 20, 2014.

  1. #1
    I'm having trouble with $_GET. I'm trying to access a variable, but it keeps getting a weird value. I send values to the same page through various links on the page, but the links don't seem to be sending the right values or something.

    These are the links

    <div id="dashboardcontrols" style="background-color: #99CCFF; height:20px;">
       <!-- Own Profile Controls. -->
           <abbr title="Post an item for swap."><a href="dashboard.php?option=swap" style="margin-right:20px;">Post Swap</a></abbr>
           <abbr title="Check alerts."><a href="dashboard.php?option=alerts" style="margin-right:20px;">Alerts</a></abbr>
           <abbr title="Check messages."><a href="dashboard.php?option=messages" style="margin-right:20px;">Messages</a></abbr>
           <abbr title="Check ad campaings."><a href="dashboard.php?option=advertising" style="margin-right:20px;">Advertising</a></abbr>
           <abbr title="Purchase gifts."><a href="dashboard.php?option=store" style="margin-right:20px;">Store</a></abbr>
           <abbr title="Edit profile."><a href="dashboard.php?option=edit" style="margin-right:20px;">Edit Profile</a></abbr>      
           <abbr title="Friends."><a href="dashboard.php?option=friends" style="margin-right:20px;">Friends</a></abbr>
           <abbr title="Billing."><a href="dashboard.php?option=billing" style="margin-right:20px;">Billing</a></abbr>
           <abbr title="Tango Prime help."><a href="dashboard.php?option=help" style="margin-right:20px;">Help</a></abbr>
         </div>   
    HTML:
    Here's the code. If you see any other bugs feel free to let me know :) There's no shortage in the project at the moment, lol.

    
    session_start();
    
    require('steps/scripts/php/sqldata.php');
    
    if(!isset($_SESSION['ID']))
    {
    
       $_SESSION['ID'] = 1;
       
    }else{
    
       $idCheck = $_SESSION['ID'];
    
    }
    
    if(isset($_GET['error']))
    {
    
       $error = $_GET['error'];
    
    }else{
    
     $error = "none";
    
    }
    
    // if a user is logged in as a guest send them to the guest profile.
    
    if($_SESSION['ID'] == 1)
    {
    
       header('Location: profile.php?handle=guest');
       exit;
       
    }
    
    $handle = "";
    
    $dashboardOption = "";
    
    $retrievedHandle = [];
    $retrievedMessages = [];
    $retrievedAnalytics = [];
    $retrievedTopFriends = [];
    
    $pageHeight = "780px;";
    
    //Get user's handle
    $dbConnect = new PDO($dsn, $dbUserName, $dbPassword, [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]);
    
    try{
    
       $dbHandleStatement = $dbConnect->prepare("SELECT `handle` FROM `users` WHERE `ID` = ?");
       $dbHandleStatement->execute([$idCheck]);
       $retrievedHandle = $dbHandleStatement->fetch();
       $handle = $retrievedHandle[0];
    
    }catch(\PDOException $e){  }
    
    //Get user's analytics
    
         $dbAnalyticsStatement = $dbConnect->prepare("SELECT `totalPluses`, `totalMinuses`, `starAverage`, `profileViews`, `adClicks`, `swapsComplete`, `friendTotal` FROM `analytics` WHERE `ID` = ?");
       
       try{
       
         $dbAnalyticsStatement->execute([$idCheck]);
         $retrievedAnalytics = $dbAnalyticsStatement->fetchAll();
         
       }catch(\PDOException $e){  }
       
       $totalPluses = $retrievedAnalytics[0][0];
       $totalMinuses = $retrievedAnalytics[0][1];
       $starAverage = $retrievedAnalytics[0][2];
       $profileViews = $retrievedAnalytics[0][3];
       $totalAdClicks = $retrievedAnalytics[0][4];
       $totalSwaps = $retrievedAnalytics[0][5];
       $totalFriends = $retrievedAnalytics[0][6];
       
       //Calculate Analytics
    
       if($totalPluses > 999999){  $totalPluses = "Billion+"; }  
       if($totalMinuses > 999999){  $totalMinuses = "Billion+"; }
       if($totalPluses > 999999){  $totalPluses = "Billion+"; }  
       if($profileViews > 999999){  $profileViews = "Billion+"; }  
       if($totalAdClicks > 999999){  $totalAdClicks = "Billion+"; }
       if($totalSwaps > 999999){  $totalSwaps = "Billion+"; }
       if($totalFriends > 999999){  $totalfriends = "Billion+"; }
       
       //Ready dashboard output
    if(isset($_GET['option']))
    {
    
       $dashboardOption = $_GET['option'];
       
    }else{
    
       header('Location: dashboard.php?option=edit');
    
    }
         
    $dashboardHtml1 = "";
    
    $htmlInterpolation = "";
    
    $dashboardHtml2 = "";
    
    
    PHP:

     
    Jeremy Benson, Jun 20, 2014 IP
  2. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #2
    Well, you don't say anything about what "weird values" you're getting. What happens that doesn't work?
    Besides - you're assigning $_GET['option'] to $dashboardOption, but $dashboardOption is not used anywhere in the code you provided.
     
    PoPSiCLe, Jun 20, 2014 IP
  3. EricBruggema

    EricBruggema Well-Known Member

    Messages:
    1,740
    Likes Received:
    28
    Best Answers:
    13
    Trophy Points:
    175
    #3
    Why this?
    1. if(!isset($_SESSION['ID']))
    2. {
    3. $_SESSION['ID'] = 1;
    4. }
    5. else{
    6. $idCheck = $_SESSION['ID'];
    7. }
    and not like this

    $idCheck = $_SESSION['id'] = isset($_SESSION['id']) ? $_SESSION['id'] : 1;
     
    EricBruggema, Jun 20, 2014 IP
  4. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #4
    I'm assuming that's a slight typo, and that you meant the following:
    
    $idCheck = isset($_SESSION['ID']) ? $_SESSION['ID'] : 1;
    
    Code (markup):
    I just wonder - why are you using 1 as a default user? Why not just have it empty, and check to see if $idCheck is empty? Or do you have a default user-id in the database?
     
    PoPSiCLe, Jun 21, 2014 IP
  5. EricBruggema

    EricBruggema Well-Known Member

    Messages:
    1,740
    Likes Received:
    28
    Best Answers:
    13
    Trophy Points:
    175
    #5
    Maby 1 is stated as a guest... and no not realy a typo ;)
     
    EricBruggema, Jun 21, 2014 IP
  6. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #6
    There's no point in having $_SESSION['id'] before the check for isset(), really
     
    PoPSiCLe, Jun 22, 2014 IP
  7. Jeremy Benson

    Jeremy Benson Well-Known Member

    Messages:
    364
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    123
    #7
    Yeah, I just used 1 as guest. I used $dashboardOption later on. The values I get are like swap, swap, swap, messages, lol. Even though the links all have different queries for the value. I'll get more code..

    The following is a lot of code, but you probably wont have to look at all of it. Basically I run through a switch case on dashboardOption to set up output html.

    
    switch($dashboardOption){
         case"swap":
           if(isset($_GET['error']))
           {
           
             $pageHeight = "840px;";
           
           }else{
           
             $pageHeight = "820px;";
           
           }
           
           $dashboardHtml1 = "<span style=\"font-size:xx-large;\">Post A Swap</span>\n"
                   .   "<form name=\"postswapform\" id=\"postswapform\" action=\"steps/scripts/php/postswap.php\" method=\"post\" enctype=\"multipart/form-data\"><br />\n"
                   .     "<label>Item Title</label><br />\n"
                   .     "<input type=\"text\" name=\"title\"/><br /><br />\n"
                   .     "<label>Type</label><br />\n"
                   .     "<select id=\"type\" onchange=\"changeCatagories();\" name=\"swapType\">\n"
                   .       "<option value=\"system\">System</option>\n"
                   .       "<option value=\"computer\">Computer</option>\n"
                   .       "<option value=\"mega swap\">Mega Swap</option>\n"
                   .       "<option value=\"game\">Game</option>\n"
                   .       "<option value=\"movie\">Movie</option>\n"
                   .       "<option value=\"book\">Book</option>\n"
                   .       "<option value=\"comic\">Comics/GN</option>\n"
                   .       "<option value=\"trading card\">Trading Card</option>\n"
                   .     "</select><br /><br />\n"         
                   .       "<label>Catagory</label><br />\n"
                   .       "<select id=\"catagorylist\" name=\"swapCatagory\">\n"
                   .       "<option value=\"nintendo\">Nintendo</option>\n"
                   .       "<option value=\"playstation\">Playstation</option>\n"
                   .       "<option value=\"xbox\">Xbox<option value=\"psp\">PSP</option>\n"
                   .       "<option value=\"ds\">DS</option></option>\n"
                   .       "<option value=\"genisis\">Genisis</option>\n"
                   .       "<option value=\"atarii\">Atarii</option>\n"
                   .       "<option value=\"other\">Other</option>\n"
                   .       "</select><br /><br />\n";
                         
               $htmlInterpolation =   "<label>Game Systems</label><br />\n"
                         .   "<span><select id=\"gamesystem\" name=\"gameSystem\">"
                         . "</select></span><br /><br />\n";
               $dashboardHtml2   =   "<label>Image</label><br /><br />\n"
                   .       "<input id=\"imagefile\" type=\"file\" name=\"swapImage\"/><br /><br />\n"
                   .       "<label>Wanted</label><br />\n"
                   .       "<select name=\"wanted\">\n"
                   .         "<option value=\"system\">System</option>\n"
                   .         "<option value=\"computer\">Computer</option>\n"
                   .         "<option value=\"mega swap\">Mega Swap</option>\n"
                   .         "<option value=\"game\">Game</option>\n"
                   .         "<option value=\"movie\">Movie</option>\n"
                   .         "<option value=\"book\">Book</option>\n"
                   .         "<option value=\"comic\">Comic/GN</option>\n"
                   .         "<option value=\"trading card\">Trading Card</option>\n"
                   .       "</select><br /><br />\n"
                   .         "<label>Postal Code</label><br />\n"
                   .         "<input type=\"text\" name=\"postalCode\" /><br /><br />\n"
                   .         "<label>Description</label><br />\n"
                   .         "<textarea name=\"itemDescription\" cols=\"24\" rows=\"4\"></textarea><br /><br />\n"
                   .         "<label>Priority Listing 1$</label><br/><label></label>\n"
                   .         "<abbr title=\"Lists in searches before non-priority postings.\"><input type=\"checkbox\" name=\"priority\"/></abbr><label>Yes.</label><br /><br />\n"
                   .         "<input type=\"submit\" value=\"Post Item\" onclick=\"postSwap();\">\n"
                   .         "<label id=\"erroroutput\"></label></form>\n";
         break;
         case"alerts":
         $pageHeight = "780px;";
           // Get alerts from alerts table.
           
           $alertStatement = $dbConnect->prepare("SELECT `ID`, `type`, `from`, `item1`, `item2` , `message`  FROM `alerts` WHERE `handle` = ?");
           $retrievedAlerts = [];
           
           try{
           
             $alertStatement->execute([$handle]);
             $retrievedAlerts = $alertStatement->fetchAll();
             
           }catch(\PDOException $e){  }
           
         break;
         case"edit":
         $pageHeight = "658px;";
           //Get audio and video information
           //if no audio or video uploaded
           $dashboardHtml1 = "<span style=\"font-size:xx-large;\">Edit Profile</span><br /><br />"
                     .   "<div id=\"editprofileform\" style=\"width:320px; height:560px; float:left;\">"
                     .     "<form enctype=\"multipart/form-data\" method=\"post\" action=\"steps/scripts/php/editprofile.php\">"
                     .       "<label>Profile Picture</label><br /><input type=\"file\" name=\"profilePicFile\" /><br /><br />"
                     .       "<label>Video/Mp3</label><br /><input type=\"file\" name=\"audioVideoFile\" /><br /><br />"
                     .       "<label>Bio</label><br /><br />"
                     .       "<textarea cols=\"38\" rows=\"10\" maxlength=\"343\" name=\"bio\"></textarea><br /><br />"
                     .       "<label>Player Type</label><br /><br />"
                     .       "<input type=\"radio\" name=\"playerType\" value=\"audio\"/>"
                     .       "<span>audio</span><input type=\"radio\" name=\"playerType\" value=\"video\" />"
                     .       "<span>video</span><br /><br /><input type=\"submit\" value=\"Submit\" style=\"float:right;\" /></form>"
                     .     "</div>"
                     .     "<div id=\"editplayerwrapper\" style=\"width:320px; height:560px; float:right;\">"
                     .       "<span style=\"font-size:xx-large;\">Player Files</span><br /><br />"
                     .       "<span>Select Three Mp3s or one video</span><br />"
                     .     "<div id=\"songdisplay\" style=\"background-color:white;height:460px; width:312px;margin-top:12px;\">"
                     .           "<!-- disaply songs here. -->";
                               
         $dashboardInterpolation = "";
         
         
         $dashboardHtml2 = "</div></div>";
         break;
         case"messages":
         $pageHeight = "780px;";
         // collect messages from database
         
         $dbMessagesStatement = $dbConnect->prepare("SELECT `from`, `subject`, `message`, `unread`, `ID` FROM `messages` WHERE `handle` = ?");
         
         try{
         
         $dbMessagesStatement->execute([$handle]);
         $retrievedMessages = $dbMessagesStatement->fetchAll();
         
         }catch(\PDOException $e){  }
         
         //Opening messages html
         
           $dashboardHtml1 = "<span style=\"font-size:xx-large;\">Messages</span><br /><br />"
           .   "<div id=\"messagesdisplay\" style=\"background-color:white;width:950px;height:260px; overflow:scroll; border:thin black groove;\">"
           .     "<div id=\"messagecontrols\"><abbr title=\"Delete selected messages.\"><div onclick=\"deleteMessages();\" style=\"height:20px; width:20px; cursor:pointer; cursor:hand;\"><img alt=\"trash\" src=\"system/images/buttons/trash.png\" /></div></abbr></div><br />";
           
           // create the messages
           
           for($i = 0; $i < count($retrievedMessages); $i++){
         
             $htmlInterpolation = $htmlInterpolation . "<div onclick=\"openMessage(" . $retrievedMessages[$i]['ID'] . ");\" id=\"" . $retrievedMessages[$i]['ID'] . "\">";
             $htmlInterpolation = $htmlInterpolation . "<input onclick=\"checkMessage(" . $retrievedMessages[$i]['ID'] . ");\" id=\"" . ($i + 1) . "\" type=\"checkbox\"/>";
             $htmlInterpolation = $htmlInterpolation . "<span style=\"margin-left:4px;\"><b>From:</b></span>";
             $htmlInterpolation = $htmlInterpolation . "<span id=\"sender\">";
         
           //add from
               
             $htmlInterpolation = $htmlInterpolation . $retrievedMessages[$i]['from'];
             
             $htmlInterpolation = $htmlInterpolation . "</span>";
         
             $htmlInterpolation = $htmlInterpolation . "<span id=\"subject\" style=\"margin-left:8px;\"><b>Subject:</b></span>";
         
             $htmlInterpolation = $htmlInterpolation . "<span>";
         
             //add subject
    
             $htmlInterpolation = $htmlInterpolation . $retrievedMessages[$i]['subject'];
         
             $htmlInterpolation = $htmlInterpolation . "</span>";
           
             $htmlInterpolation = $htmlInterpolation . "<span style=\"margin-left:4px;\"><b id=\"readstatus\">";
         
             // add unread status     
                   
             if($retrievedMessages[$i]['unread'] == "yes")
             {
           
               $htmlInterpolation = $htmlInterpolation . "unread</b></span>";
           
             }else { $htmlInterpolation = $htmlInterpolation . "</b></span>"; }
         
               $htmlInterpolation = $htmlInterpolation . "</div>";
         
             
    
           }       //closeing messages html
           
           $dashboardHtml2 = "</div>"
           .   "<form><br />"
           .     "<span>To/From:</span><br />"
           .     "<input id=\"messageto\" type=\"text\" name=\"messageTo\"/><br /><br />"
           .     "<span>Subject:</span><br />"
           .     "<input id=\"messagesubject\" type=\"text\" name=\"subject\" /><br /><br />"
           .     "<textarea id=\"messagebox\" cols=\"116\" rows=\"14\" spellcheck=\"true\" draggable=\"false\"></textarea>"
           .   "</form>"
           .   "<button onclick=\"sendMessage();\" style=\"float:right;\">Send!</button>";
           break;
         case"advertising":
          ...// And so on.
    ?>
    
    <!DOCTYPE html>
    <html>
    
    <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
    <title>Tago Prime: Dashboard</title>
    <link href="steps/css/dashboard/ffdashboard.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="steps/scripts/javascript/jquery.js"></script>
    <script type="text/javascript" src="steps/scripts/javascript/dbfunctions.js"></script>
    <script type="text/javascript" src="steps/scripts/javascript/alertfunctions.js"></script>
    </head>
    
    <body>
    
    <div id="page" style="height:945px; width:1332px;">
       <div id="searchbar" style="background-color: #99CCFF;height:40px;">
         <div id="logo" style="float:left; width:169px; height:40px;"></div>
         <form >
           <input type="text" style="padding:4px;margin:4px;"/>
           <button style="padding:4px;margin:4px;">Search</button>
           <div style="background-color:yellow; height:40px; width:40px; display:inline; float:right; cursor:hand; cursor:pointer;"></div>
         <div style="background-color:pink; height:40px; width:40px; display:inline; float:right; cursor:hand; cursor:pointer;"></div>
         <div style="background-color:purple; height:40px; width:40px; display:inline; float:right;cursor:hand;cursor:pointer;"></div>
         </form>   
       </div>
       
       <div id="profilepic" style="background-color:#99CCFF;; float:left; height:169px; width:169px; display:inline; margin-top:12px;"></div>
       
       <div id="highrollerad" style="background-color: #99FF99; float:right; height:169px; margin-top:12px; width:1151px;">
       
       </div>
       
       <div id="dashboardinfowrapper" style="background-color:#99CCFF; float:right; height:169px; margin-top:12px; width:1151px;">
           <span id="usernameoutput" style="font-size:xx-large;padding:20px;">Tango Prime</span><br />
           <p style="padding:20px;">Welcome to your dashboard! This is the place to go when you want do all kinds of cool
           stuff on Tango Prime. You can set up your profile, check your alerts,<br />
            post swaps, and
           message friends. Don't forget to keep any eye on those trades and offers. Things
           will move pretty fast on Tango Prime once the ball gets rolling. <br />
           You don't want to miss a sweet offer. Anyway have fun setting everything up!</p>
       </div>
    
       <div id="ad1" style="background-color:pink; margin-top:12px; height:169px; width:169px; float:left;">
         <div id="ad1header" style="text-align:center;"><span id="ad1headeroutput">Ad Space</span></div>
       </div>
    
       
       
       
       <div id="adspacewrapper" style="background-color:pink; margin-top:12px; height:169px; width:169px; float:right;">
         <div id="adspaceheader" style="height:20px; text-align:center">Ad Space</div>
         <div id="adspaceimage" style="width:169px; height:149px;cursor:hand; cursor:pointer;">
         </div>
       </div>
               <div style="background-color: #FFCC66; float:left; height:338px;width:169px; margin-top:12px;" class="auto-style1">
                 <div style="height:20px;"><b>Analytics</b></div><br />
                 <span>Star Average:</span><span style="margin-left:22px;"><?php echo $starAverage; ?></span><br /><br />
                 <span>Total Pluses:</span><span style="margin-left:27px;"><?php echo $totalPluses; ?></span><br /><br />
                 <span>Total Minuses:</span><span style="margin-left:14px;"><?php echo $totalMinuses; ?></span><br /><br />
                 <span>Profile Views:</span><span style="margin-left:16px;"><?php echo $profileViews; ?></span><br /><br />
                 <span>Swaps:</span><span style="margin-left:62px;"><?php echo $totalSwaps; ?></span><br /><br />
                 <span>Friends:</span><span style="margin-left:55px;"></span><?php echo $totalFriends; ?><br /><br />
                 <span>Ad Clicks:</span><span style="margin-left:38px;"><?php echo $totalAdClicks; ?></span><br />             
               </div>
    
       
       <div id="dashboardwrapper" style="background-color: #99FF99; float:right; height:<?php echo $pageHeight; ?>margin-right:12px; margin-top:12px; width:970px;">
    
         <div id="dashboardcontrols" style="background-color: #99CCFF; height:20px;">
       <!-- Own Profile Controls. -->
           <abbr title="Post an item for swap."><a href="dashboard.php?option=swap" style="margin-right:20px;">Post Swap</a></abbr>
           <abbr title="Check alerts."><a href="dashboard.php?option=alerts" style="margin-right:20px;">Alerts</a></abbr>
           <abbr title="Check messages."><a href="dashboard.php?option=messages" style="margin-right:20px;">Messages</a></abbr>
           <abbr title="Check ad campaings."><a href="dashboard.php?option=advertising" style="margin-right:20px;">Advertising</a></abbr>
           <abbr title="Purchase gifts."><a href="dashboard.php?option=store" style="margin-right:20px;">Store</a></abbr>
           <abbr title="Edit profile."><a href="dashboard.php?option=edit" style="margin-right:20px;">Edit Profile</a></abbr>       
           <abbr title="Friends."><a href="dashboard.php?option=friends" style="margin-right:20px;">Friends</a></abbr>
           <abbr title="Billing."><a href="dashboard.php?option=billing" style="margin-right:20px;">Billing</a></abbr>
           <abbr title="Tango Prime help."><a href="dashboard.php?option=help" style="margin-right:20px;">Help</a></abbr>
         </div>   
         
         <div id="dashboardoutput" style="padding:12px;">
           <?php
             
             if($dashboardOption == "messages" || $dashboardOption == "edit" || $dashboardOption = "swap"){
               
             //   echo $dashboardHtml1 . $htmlInterpolation . $dashboardHtml2;
               
               echo $dashboardOption;
               
               if($error == "yes" && $dashboardOption == "swap" && isset($_GET['error']))
               {
                 echo "<span>Fill all fields. Include an image. Use a stock image if you must, but be honest in your description. Must be jpg, jpeg, png, or gif.</span>";   
               }
               
             }elseif($dashboardOption == "friends"){
               
                 echo $dashboardHtml1;
                             
                 echo "<div id=\"alphabetical\">";
                 
                 //Place friends letters here.
    
                 echo "</div>";   
                 
                 echo "<div id=\"numerical\">";
                 
                 //Place numbers here.
                 
                 echo "</div>";
                 
                 //Friend divs and images go here.
                 
                 echo "<div style=\"background-color:blue;height:42px; width:42px; margin-left:12px; margin-top:12px; float:left; display:inline;\"></div>";
                 
                 echo "<form>"
                   .   "<input type=\"text\" style=\"margin-top:20px;\" />"
                   .   "<input type=\"button\" value=\"search!\"style=\"margin-top:20px;\"/>"
                 .   "</form>";
                 
               echo "</div>";   
                     
             }elseif($dashboardOption == "alerts"){
             
                     //Arrays to hold the values of the alerts.
                     $alertID = [];
                     $alertType = [];
                     $alertFrom =  [];
                     $alertItem1 = [];
                     $alertItem2 = [];
                     $alertMessage = [];
                     
                     $retrievedMime = [];
               
               foreach($retrievedAlerts as $L1)
                 { foreach($L1 as $L2 => $value)
                   {   
                                                     
                     if($L2 === "ID")
                     {
                     
                       array_push($alertID, $value);
    
                     }
                     
                     if($L2 === "type")
                     {
    
                       array_push($alertType, $value);
    
                     }
    
                     if($L2 === "from")
                     {
                           
                       array_push($alertFrom, $value);
                     
                     }
                     if($L2 === "item1")
                     {
    
                       array_push($alertItem1, $value);
       
                     }
                     if($L2 === "item2")
                     {
                     
                       array_push($alertItem2, $value);
                     
                     }
                     if($L2 === "message")
                     {
                     
                       array_push($alertMessage, $value);         
                     
                     }
                     
                 }
                 
               }
                     $elementCount = count($alertID);
             
                   for($i = 0; $i < $elementCount && $i < 9; $i++)
                   {
                     // Layout a friend request alert.
                     if($alertType[$i] === "friend request")
                     {
                       //Star the friend request information.
                       echo "<div class=\"alertwrapper\" id=\"" . "alert" . $alertID[$i] . "\" name=\"alert\" style=\"height:62px; width:400px; margin-bottom:12px; padding:4px;\">\n"
                        . "\t\t\t\t<div id=\"alertimage\" style=\"background-color:blue; height:62px; width:62px; float:left;\">\n";
                     
                     
                       //Get the mime type for the user.
                       
                         $retrieveMime = $dbConnect->prepare("SELECT `profileImageMime` FROM `profileSettings` WHERE `handle` = ?");
                         
                         try{
                         
                           $retrieveMime->execute([$alertFrom[$i]]);
                           $retrievedMime = $retrieveMime->fetch();
                       
                         }catch(\PDOException $e){  }
                         
                                               
                           if(!empty($retrievedMime))
                           {
                               echo "\t\t\t\t\t\t<img alt=\"alertpic1\" src=\"users/" . $alertFrom[$i] . "/images/profile" . $retrievedMime[0] . "\" style=\"background-color:blue;height:62px; width:62px;\" />\n";
                           
                           }else{
                           
                             echo "\t\t\t\t\t\t<img alt=\"alertpic1\" src=\"system/images/profile/stockprofile.jpg\" style=\"background-color:blue;height:62px; width:62px;\" />\n";
                           
                           }
                           
                           echo "\t\t\t\t</div>\n"
                           . "\t\t\t\t<div>\n"
                           . "\t\t\t\t\t<span>&nbsp;Handle:" . $alertFrom[$i];
                                                 
                           echo  "\t\t\t\t\t</span><span></span><br />\n"
                             . "\t\t\t\t\t<span>&nbsp;Message:Friend Request</span><span></span><br />\n"
                             . "\t\t\t\t\t<span>&nbsp;<a style=\"cursor:hand;cursor:pointer;\" onclick=\"acceptFriend(" . $alertID[$i] . "," . "'" . $handle . "'" . ","  . "'" . $alertFrom[$i] . "'" . ");\">accept</a></span>"
                             . "\t\t\t\t\t<span style=\"margin-left:8px;\">"
                             . "\t\t\t\t\t<a style=\"cursor:hand;cursor:pointer;\" onclick=\"denyFriend(" . $alertID[$i] . "," . "'" . $handle . "'" . ","  . "'" . $alertFrom[$i] . "'" . ");\">deny</a></span>\n"
                             . "\t\t\t\t</div>\n"
                             . "\t\t\t</div>\n";
                           
                       }
                   
                     }
                     
             }else{   
             
               //DEBUG   echo $dashboardHtml1;
             }
                 
            ?>
           
           
         </div>
       </div>
    </div>
    </body>
    
    </html>
    
    PHP:
     
    Jeremy Benson, Jun 23, 2014 IP
  8. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #8
    That... is some very contrived code. There is quite a lot that could be simplified - for instance, the multiple echo-statements doesn't make any sense. You should also drop using "" (double quotes) for echoing out stuff, and just concoct variables inside the echo-statement, if need be - something like this:
    
    echo '<p>This is an example of a paragraph echoed out</p>
    <p>and this is another one, with a '.$variable.' inside it</p>';
    
    Code (markup):
    And why don't you pull the values for the options and such from a database as well? Would make it much easier to change / update the list if need be.

    As for the $_GET and problem I'm not sure, I haven't really looked at the code that much - I'm thinking it's probably a relatively easy problem, but without the database and direct access to the files, it gets to be a little bit too much to get into. I would suggest simplifying the code - just try the bare minimum to get the $_GET-query to work, and display the content (var_dump the result, for that matter), and then add more stuff when you get that bit sorted out.
     
    PoPSiCLe, Jun 23, 2014 IP
  9. Jeremy Benson

    Jeremy Benson Well-Known Member

    Messages:
    364
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    123
    #9
    pulling the options from a database is a good idea. Never thought of it. I never new how to interpolate variable in single quotes... I read somewhere that they didn't have the processing power so user double quotes, lol. Thanks for the info. I'll add this to my notes.
     
    Jeremy Benson, Jun 24, 2014 IP
  10. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #10
    Your code seems to stem a bit from Javascript, or maybe C-something, I dunno - multiple echo-statements, and adding echo-statements with concoctination . between them... not needed, as echo ignores whitespace in PHP, and returns/linebreaks doesn't matter (in the code, that is). I would have a look at the code, but again, I'm a little too busy with my own projects right now - I do think that you could probably trim that down quite a bit, by simplifying a few bits.
     
    PoPSiCLe, Jun 24, 2014 IP
  11. Jeremy Benson

    Jeremy Benson Well-Known Member

    Messages:
    364
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    123
    #11
    Ah yeah, if I get energetic I'll wipe that section out, and re-write it. If not I'll carry all the lessons on into my next project... I have been taking notes so your guys's lessons aren't in vein, lol.
     
    Jeremy Benson, Jun 25, 2014 IP
  12. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #12
    Uhm, what makes full words abbreviations? Why do you have fixed redundant style in the markup? Not really the cause of your issues (oddball PHP that doesn't even make sense is) but certainly it can't be helping matters.

    As the saying goes: "If you have to use title on an anchor, there's something wrong with the contents of the anchor!"

    Even just this one line:
    $pageHeight = "840px;";

    Throws up massive warning flags that whatever it is you're trying to accomplish, you're doing it ALL WRONG.

    Not that I could figure out what that mess is trying to accomplish.
     
    deathshadow, Jun 25, 2014 IP
  13. Jeremy Benson

    Jeremy Benson Well-Known Member

    Messages:
    364
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    123
    #13
    Well, I'm here to learn. I'm stetting the page height dynamically, at least it worked, lol. I just can't learn anything when people are like redundant code, mess, yada, lol... I gotta know where, how and why...
     
    Jeremy Benson, Jun 25, 2014 IP