Jump to content

runnerjp

Members
  • Posts

    2,214
  • Joined

  • Last visited

Posts posted by runnerjp

  1. how could i make the bleow code show radon friends??

     

    <? 
    
    $sql="SELECT friends.friendname, users.image FROM friends INNER JOIN users ON (users.Username=friends.friendname) WHERE friends.username='Admin' GROUP BY friends.friendname ORDER BY users.Username limit 9 ";
    $res = mysql_query($sql) or die(mysql_error());
    
    echo "<table>";
                            $i = 0;
                            while($row = mysql_fetch_assoc($res)){
                                    $i++;
                                    if ($i % 3 == 0)
                                            echo '<tr>';
                                   
                                    echo "<td><a href=\"http://www.runningprofiles.com/members/". $row['friendname'] ."\"><img src=\"http://www.runningprofiles.com/members/images/mini/" . $row['image'] . "\" /></a><br /> </td>";
                                                   
                                    if ($i % 3 == 0)
                                            echo '</tr>';
    
                                    if( $i == 9 ) break;
                            }
                            echo "</table>";
    ?> 
    

  2. here is my script

     

    <? include'../../settings.php';
    
    $sql="SELECT friends.friendname, users.image FROM friends INNER JOIN users ON (users.friendname=friends.friendname) WHERE friends.username='Admin' GROUP BY friends.friendname ORDER BY users.friendname ";
    
    // Showing
    $res = mysql_query($sql) or die(mysql_error());
    echo '<table><tr><th>Name</th><th>Picture</th></tr>'; 
    
    while($row = mysql_fetch_assoc($res)){
      echo "<tr><td>" . $row['friendname'] . "</td><td><td>". $row['image"] ."</td></tr>";
    }
    echo "</table>"; 
    
    ?> 

     

    but i would like to change it as users only have 1 profile picture and i would like to have it like this

     

    Untitled.jpg

  3. how could i join these 2 querys

    $result1=mysql_query ("SELECT friendname FROM friends WHERE username='Admin' ORDER BY friendname"); 
    $myrow1 = mysql_fetch_array ($result);
    $friendname=$myrow1[friendname];
    $result=mysql_query ("SELECT image FROM users WHERE friendname='$friendname'"); 
    
    //loop statement 
    while ($myrow = mysql_fetch_array ($result)) 
    { 
    // this is the column 1 
    if ($column == 1) 
    { 
    printf("<tr><td><b></b>%s</td>",$myrow[image]); 
    
    } 
    else{ 
    //this  is the column 2   
    printf("<td><b></b>%s</td></tr>",$myrow[image]); 
    
    } 
    //increment the count 
    $count += 1; 
    // this is a modulus operator it gets the remainder of the equation 
    $column = $count % 2; 
    } 
    
    ?> 

     

    so then i can echo out image??

  4. ok i did this

     

          <?php
      require_once '../settings.php';
    
    $q = mysql_query("SELECT friendname FROM friends WHERE username='Admin' ORDER BY friendname");
    $count = mysql_num_rows($q);
    $results = array();
    while ($line = mysql_fetch_array($q)) $results[] = $line;
    
    $split = ceil($count / 2);
    // then you can display it in a table
    echo "<table>";
    for ($i = 1; $i <= $split; $i++) {
        $left = $i; $right = $i + $split;
        echo "<tr>";
        echo "<td>{$results[$left][friendname]}</td>";
        if ($right == $count) { // odd number of results (left column has the extra)
            echo "<td></td>";
        } else {
            echo "<td>{$results[$right][friendname]}</td>";
        }
        echo "</tr>\n";
    }
    echo "</table>"; 
    ?> 

     

     

    but i only get runnerjp putputted even though my db loos like this

     

    id friendname username

    Edit Delete 25 runnerjp Admin

    Edit Delete 24 Admin runnerjp

    Edit Delete 23 Princessemma Admin

    Edit Delete 22 Admin Princessemma

  5. im presuming this is login.php?

     

    try that..sometime spaces cause the error!...also is thius included on any page or are you looking at this directly?

     

    <?php
    session_start(); // Starts the session.
    // Includes the db and form info.
    include("conf.inc.php");?>
    <center>try me</center>
    <?
    if ($_SESSION['logged'] == 1) { // User is already logged in.
       header("Location: main.php"); // Goes to main page.
       exit(); // Stops the rest of the script.
    } else {
       if (!isset($_POST['submit'])) { // The form has not been submitted.
          echo "<form action=\"login.php\" method=\"POST\">";
          echo "<table>";
          echo "<tr>";
          echo "<td colspan=\"2\">Login:</td>";
          echo "</tr>";
          echo "<tr>";
          echo "<td width=\"50%\">Username:</td><td width=\"50%\"><input name=\"username\" size=\"18\" type=\"text\" />";
          echo "</tr>";
          echo "<tr>";
          echo "<td width=\"50%\">Password:</td><td width=\"50%\"><input name=\"password\" size=\"18\" type=\"text\" />";
          echo "</tr>";
          echo "<tr>";
          echo "<td colspan=\"2\"><input type=\"submit\" name=\"submit\" value=\"Submit\"</td>";
          echo "</tr>";
          echo "</table>";
          echo "</form>";
       } else {
          $username = form($_POST['username']);
          $password = md5($_POST['password']); // Encrypts the password.
          $q = mysql_query("SELECT * FROM `users` WHERE username = '$username' AND password = '$password'") or die (mysql_error()); // mySQL query
          $r = mysql_num_rows($q); // Checks to see if anything is in the db 
          if ($r == 1) { // There is something in the db. The username/password match up.
             $_SESSION['logged'] = 1; // Sets the session.
             header("Location: main.php"); // Goes to main page.
             exit(); // Stops the rest of the script.
          } else { // Invalid username/password.
             exit("Incorrect username/password!"); // Stops the script with an error message.
          }
       }
    }
    mysql_close($db_connect); // Closes the connection.
    ?>

  6. i have a popup window where users can upload there profile picture... is there anyway in which when a users closes the popup window , it could refresh the main window and show their new avatar ???

  7. ok you would have to have ur db filled with ip and locations ect... so a quick way is to use anouther site and pull there results like so

     

    <?
    $ip = '59.93.196.219';
    $url = "http://www.ipmango.com/api.php?ip=".$ip;
    $xml = simplexml_load_file($url);
    echo "IP address : {$xml->ipaddress} <br />";
    echo "City : {$xml->city} <br />";
    echo "Region : {$xml->region} <br />";
    echo "Country Name : {$xml->countryname} <br />";
    echo "Latitude : {$xml->latitude} <br />";
    echo "Longitude : {$xml->longitude} <br />";
    ?>

  8. ok iv tried this

     

    <?php 
    error_reporting(E_ALL); 
    session_start();
    require_once '../settings.php';
    include "../info.php"; // sets username/id ect
    ?><form action="<?php echo $_server['php-self'];  ?>" method="post" enctype="multipart/form-data" id="something" class="uniForm">
            <input name="new_image" id="new_image" size="30" type="file" class="fileUpload" />
            <button name="submit" type="submit" class="submitButton">Upload/Resize Image</button>
    </form>
    <?php
            if(isset($_POST['submit'])){
              if (isset ($_FILES['new_image'])){
                                      $file_name = $_FILES['new_image']['name'];
                                    $getExt = explode ('.', $file_name);
                    $file_ext = $getExt[count($getExt)-1];
                                    // Adding extension verification
                                    $allowed_ext = "|jpg|png|gif|jpeg|svg|bmp|";
                                    if (!strpos($allowed_ext, "|".$file_ext."|")) die("Extension: $file_ext is not allowed!");              
                                    // End extension verification           
                                    $imagename = "$id.$file_ext";
                                    
                  $source = $_FILES['new_image']['tmp_name'];
                  $target = "images/$id.$file_ext";
                              
                  move_uploaded_file($source, $target);
    
                  $imagepath = $imagename;
                  $save = "images/thumbs/" . $imagepath; //This is the new file you saving
                  $file = "images/" . $imagepath; //This is the original file
    
                  list($width, $height) = getimagesize($file) ; 
    
                  // Adding proportionate image resizing, with max values
                              
                              /*
                              $modwidth = 200; 
    
                  $diff = $width / $modwidth;
    
                  $modheight = $height / $diff; 
                  */
                              
                              $max_w = 200;
                              $max_h = 200;
                              
                              if($width <= $max_w && $height <= $max_h){ // if it fits
                         $modheight = $height; 
                                     $modwidth = $width;
                              }else{ // Then resize
                                    $diff = ($width > $height) ? ($width/$max_w) :  ($height/$max_h); // Check which is bigger, and fit it to that max value. This will prevent stretching (80x800)
                        $modheight = $height / $diff; 
                                    $modwidth = $width / $diff;
                              }
                              
                              // End 
                              
                              $tn = imagecreatetruecolor($modwidth, $modheight) ; 
                  $image = imagecreatefromjpeg($file) ; 
                  imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ; 
                              imagejpeg($tn, $save, 100) ; 
    
                  $imagepath = $imagename;
                  $save = "images/mini/" . $imagepath; //This is the new file you saving
                  $file = "images/" . $imagepath; //This is the original file
    
                  list($width, $height) = getimagesize($file) ; 
    
                  $modwidth = 80; 
    
                  $diff = $width / $modwidth;
    
                  $modheight = $height / $diff; 
                  $tn = imagecreatetruecolor($modwidth, $modheight) ; 
                  $image = imagecreatefromjpeg($file) ; 
                  imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ;  
    
                  imagejpeg($tn, $save, 100) ; 
                              
                              
                              $imagepath = $imagename;
                  $save = "images/tiny/" . $imagepath; //This is the new file you saving
                  $file = "images/" . $imagepath; //This is the original file
    
                  list($width, $height) = getimagesize($file) ; 
    
                  $modwidth = 40; 
    
                  $diff = $width / $modwidth;
    
                  $modheight = $height / $diff; 
                  $tn = imagecreatetruecolor($modwidth, $modheight) ; 
                  $image = imagecreatefromjpeg($file) ; 
                  imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ; 
    
                  imagejpeg($tn, $save, 100) ; 
                              $sql = "UPDATE `users` SET image = '".$id.".".$file_ext."' WHERE ID=$id";
    mysql_query($sql) or die(mysql_error());
                              
                echo "Large image: <img src='images/thumbs/".$imagepath."'><br>"; 
                echo "MINI: <img src='images/mini/".$imagepath."'>"; 
                            echo "TINY: <img src='images/tiny/".$imagepath."'><br>";  
    
              }
            }
    ?>

     

    Extension: jpg is not allowed! --- this is what i get though :S strange

     

    how is this wrong?>??

     

    $allowed_ext = "|jpg|png|gif|jpeg|svg|bmp|";

                                    if (!strpos($allowed_ext, "|".$file_ext."|")) die("Extension: $file_ext is not allowed!");       

  9. i have a few questions...  below is my current code for resizing my images

     

    <?php
    error_reporting(E_ALL); 
    session_start();
    require_once '../settings.php';
    include "../info.php"; // sets username/id ect
    ?><form action="<?php echo $_server['php-self'];  ?>" method="post" enctype="multipart/form-data" id="something" class="uniForm">
            <input name="new_image" id="new_image" size="30" type="file" class="fileUpload" />
            <button name="submit" type="submit" class="submitButton">Upload/Resize Image</button>
    </form>
    <?php
            if(isset($_POST['submit'])){
              if (isset ($_FILES['new_image'])){
                  			  $file_name = $_FILES['new_image']['name'];
    		   	$getExt = explode ('.', $file_name);
                   	$file_ext = $getExt[count($getExt)-1];
    			$imagename = "$id.$file_ext";
    
                  $source = $_FILES['new_image']['tmp_name'];
                  $target = "images/$id.$file_ext";
    		  
                  move_uploaded_file($source, $target);
    
                  $imagepath = $imagename;
                  $save = "images/thumbs/" . $imagepath; //This is the new file you saving
                  $file = "images/" . $imagepath; //This is the original file
    
                  list($width, $height) = getimagesize($file) ; 
    
                  $modwidth = 200; 
    
                  $diff = $width / $modwidth;
    
                  $modheight = $height / $diff; 
                  $tn = imagecreatetruecolor($modwidth, $modheight) ; 
                  $image = imagecreatefromjpeg($file) ; 
                  imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ; 
    		  imagejpeg($tn, $save, 100) ; 
    
                  $imagepath = $imagename;
                  $save = "images/mini/" . $imagepath; //This is the new file you saving
                  $file = "images/" . $imagepath; //This is the original file
    
                  list($width, $height) = getimagesize($file) ; 
    
                  $modwidth = 80; 
    
                  $diff = $width / $modwidth;
    
                  $modheight = $height / $diff; 
                  $tn = imagecreatetruecolor($modwidth, $modheight) ; 
                  $image = imagecreatefromjpeg($file) ; 
                  imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ;  
    
                  imagejpeg($tn, $save, 100) ; 
    		  
    		  
    		  $imagepath = $imagename;
                  $save = "images/tiny/" . $imagepath; //This is the new file you saving
                  $file = "images/" . $imagepath; //This is the original file
    
                  list($width, $height) = getimagesize($file) ; 
    
                  $modwidth = 40; 
    
                  $diff = $width / $modwidth;
    
                  $modheight = $height / $diff; 
                  $tn = imagecreatetruecolor($modwidth, $modheight) ; 
                  $image = imagecreatefromjpeg($file) ; 
                  imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ; 
    
                  imagejpeg($tn, $save, 100) ; 
    		  $sql = "UPDATE `users` SET image = '".$id.".".$file_ext."' WHERE ID=$id";
    mysql_query($sql) or die(mysql_error());
    		  
                echo "Large image: <img src='images/thumbs/".$imagepath."'><br>"; 
                echo "MINI: <img src='images/mini/".$imagepath."'>"; 
    		echo "TINY: <img src='images/tiny/".$imagepath."'><br>";  
    
              }
            }
    ?>

     

    my first question would be what would be the best size to use for a profile picture/avator ??  at the moment is have $modwidth = 200; but if i have a long picture then it looks too big..if you upload a picure nearly in all perportions then it looks great... is there anyway to make it more perpotionate or anything?

     

    my second question would be how could i stop anything but images beeing uploaded?

  10. where have i made an error here??

     

    <?php echo("
    			<img src='http://www.runningprofiles.com/members/images/thumbs/<?php echo $getuserimage['image'];?>' border=\"1\" align=\"middle\" /> $result[by_user] wants to be friends with you. <br/>
    			<a href='newfriends.php?friends=accept&user=$result[by_user]'>Accept</a> or <a href='newfriends.php?friends=delete&user=$result[by_user]'>Delete</a><br/>
    		");?>

  11. ok i came up with an idea... i have made it so the input into the db looks like this

     

    <select name="distance" onchange="setDistance(this.value)">
    				<option value="#|Distance">Select the distance</option>
    				<option value='withoutMinutes|C:100m' >100m</option>
                        <option value='withoutMinutes|E:200m'>200m</option>
                        <option value='withoutMinutes|F:400m'>400m</option>
                        <option value='withoutHours|H:800m'>800m</option>
                        <option value='withoutHours|I:1500m'>1500m</option>
                        <option value='withoutHours|J:3000m'>3000m</option>
                        <option value='withoutHours|L:5000m'>5000m</option>
                        <option value='withoutHours|N:10,000m'>10,000m</option>
                        <option value='withoutHours|M:5k Road'>5k Road</option>
                        <option value='withoutHours|O:10k Road'>10k Road</option>
                        <option value='withHours|P:H Marathon'>H Marathon</option>
                         <option value='withHours|Q:Marathon'>Marathon</option>
                          <option value='withoutHours|K:3k S/Chase'>3k S/Chase</option>
                           <option value='withoutMinutes|D:110m Hurdles'>110m Hurdles</option>
                            <option value='withoutMinutes|G:400m Hurdles'>400m Hurdles</option>
                              <option value='withoutMinutes|A:60m (I)'>60m (I)</option>
                                <option value='withoutMinutes|2B:60m Hurdles'>60m Hurdles</option>
    			</select>

     

    so when i run an my script it should show reults in dec order..

     

    a

    b

    c

    d

    e

    ect

     

    so i ran the script

     

    <?php
    $result = mysql_query("SELECT * FROM pb where uid='".$getuser['ID']."' Order by pb DESC") or die(mysql_error());
    $num2 = mysql_num_rows($result);
    
    echo "<table class=\"profilepbs\" width=195 align=\"center\" cellpadding=\"0\" cellspacing=\"0\">
       <tr><td width=105 ><div align=\"center\">Distance</div></td><td width=125><div align=\"center\">Pb</div></td></tr>
       <tr>
         <td height=\"1\" colspan=\"2\" bgcolor=\"#000000\"></td>
         <td height=\"1\" colspan=\"2\" bgcolor=\"#000000\"></td>
       </tr>
       ";
    while ( $row = mysql_fetch_array($result) ) {echo "<tr><td bgcolor=\"#FFFFFF\"><center>" . $row["distance"] . "</center></td><td bgcolor=\"#FFFFFF\"><center>" . $row["pb"] . "</center></td></tr>";
      }
      if($num2 < 1)
        {echo "<tr><td bgcolor=\"#FFFFFF\" ><center> N/A 
        </center></td><td bgcolor=\"#FFFFFF\"><center> N/A 
        </center></td></tr>";}
    echo "</table>
    <p>";
    ?>

     

    the confusing thing is this is my output

    123.jpg

     

    why is J 1st :S

     

    also i cant rember but whats the function so i can get rid of the 1st 2 thing so A:100m will become 100m

  12. ok i used this

     

    <?php if ($username != $profilesname)  {echo '<div align=\"center\"><a href=include/friendrequest.php?username='.$profilename.' class="popup">Add to frinds list</a></div>';}?>

     

    then i included a file <script type="text/javascript" src="http://www.runningprofiles.com/popup.js"></script>

     

    on this is

    var newWin = null;
    function popUp(strURL, strType, strHeight, strWidth) {
    if (newWin != null && !newWin.closed)
       newWin.close();
    var strOptions="";
    if (strType=="console")
       strOptions="resizable,height="+
         strHeight+",width="+strWidth;
    if (strType=="fixed")
       strOptions="status,height="+
         strHeight+",width="+strWidth;
    if (strType=="elastic")
       strOptions="toolbar,menubar,scrollbars,"+
         "resizable,location,height="+
         strHeight+",width="+strWidth;
    newWin = window.open(strURL, 'newWin', strOptions);
    newWin.focus();
    }
    $("a.popup").click(function{window.open($(this).attribute("href")); return false;} // jquery
    
    
    // non jquery solution.
    function popUps()
    {
    var links = document.getElementsByTagName('a');
    for(var i = 0; i < links.length; i++)
    {
      if (links[i].className && links[i].className == 'popup')
      {
       links[i].onclick = function () {
        window.open(this.href);
        return false;
      }
    }
    }
    
    window.onload = popUps;

     

    but no pop up happens...just a normal page redirect

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