Jump to content

BigTime

Members
  • Posts

    60
  • Joined

  • Last visited

Posts posted by BigTime

  1. I would like to do a join I think?  Not sure if Im going about this the right way, and unsure how to format the query.

    In one table I have a field called name - I'd like to call all of them - then query another table for any results that exist with that name,
    and if so show them all grouped together, and if not, then show the name in RED (or whatever).

    This is basically have they submitted or not.

    so table1:
    name

    Select DISTINCT name from table1 ORDER by name ASC

    then table2:
    id (not the same as the first table)
    user (which will match name)
    week
    description

    SELECT * from table2 WHERE (user='$name' AND week='$week')


    Then visible results loop looks somthing like:

    WEEK 1

    NAME1 DESCRIPTION ID
    NAME1 DESCRIPTION ID
    NAME1 DESCRIPTION ID

    NAME2 DESCRIPTION ID
    NAME2 DESCRIPTION ID
    NAME2 DESCRIPTION ID

    NAME3 DESCRIPTION ID
    NAME3 DESCRIPTION ID

    NAME4 NO SUBMISSION FOUND

    NAME5 DESCRIPTION ID
    NAME5 DESCRIPTION ID

    Do I need to do the first query and then a foreach loop?

  2. Or define new variables from array results?

     

    I dont need to loop my form 4 times I just want to know if what Im looking for is WITHIN the array in order to move to my next step

     

    If it is in the array - Check something else is set, YES show form, NO show choices

    If it is not in array - Show form

     

    The while loop makes it want to loop as many times as my results are - so 4 results, 4 loops.

     

    Im sure Im using the wrong method here.

     

    Hoping someone smart out there understands what Im trying to do :)

  3. I have a form that needs to require certain parameters be set prior to showing it.

     

    I query one column to find the conditions in which it might be required

     

    the result set into an array

     

    if a currently set parameter is found within this array then check for second parameter being set

     

    if its set = show the form

    if its not set = offer choices to set so we can show the form

     

    My problem is in the damn while loop

     

    How can I take the data that comes out of the initial $results query and store them for use OUTSIDE a while loop?

     

    Thanks in adcance for any help

     

    # setup SQL statement
    $SQL = " SELECT DISTINCT column FROM table WHERE condition='$condition' AND condition2 != '' ";
    
    # execute SQL statement
    $result = mysql_db_query($db, $SQL, $cid);
    
    # check for errors
    if (!$result) { echo( mysql_error()); }
    
    $check = mysql_num_rows($result);
    
     #We have a split needed so print it
     if($check>'1') {
       while ($data=mysql_fetch_array($result)){
       $columnresults=$data[column];
      $columnarray = array($columnresults);
    
      #If our current division selected is in this array then show AND REQUIRE the split choice to show the form
       $this = $_GET['this'];
       if (in_array($this, $columnarray))
       {
     if (!$that || $that=='')
     {
     echo (" THERE IS NO THAT WE NEED TO PROVIDE OPTIONS TO SET IT FIRST <BR>");
     }
    
     elseif ($that || $that != '')
     {
     echo ("THAT IS SET SHOW THE FORM<BR>");
     }
       }
       else (!in_array($this, $columnarray)){
     echo ("I DONT NEED THAT I CAN JUST SHOW THE FORM<BR>");
       }
      }
     }
    

  4. Database one: schedules

    Database two: schedulesArchive

     

    I need to copy a table named foo from database one to database two and rename it to 2012_foo.

     

    $usr = "user";
    $pwd = "pass";
    $db = "schedules";
    $db2 = "schedulesArchive";
    $host = "localhost";
    # connect to database
    $cid = mysql_connect($host,$usr,$pwd);
    if (!$cid) { echo("ERROR: " . mysql_error() . "\n"); }
    
    $year=Date("Y");
    SQL = "CREATE TABLE $db2.$year_foo SELECT * FROM $db.foo";
    $result = mysql_db_query($db,$SQL,$cid);
    # check for error
    if (!$result) { echo("ERROR: " . mysql_error() . "\n$SQL\n"); }
    

     

    My problem is in the naming of the new table I want it to read schedulesArchive.2012_foo, but Im confused on how to get my statement to read the $year parameter inline in my query

     

    Thanks in advance

  5. Is this possible?

     

    I have a defined variable that I need to check against like:

     

    if ($_POST['home'] LIKE '$user%'){

      //SQL UPDATE

     

    $_POST['home'] might be something like Wellingfield Blue whereas user would always be just Wellingfield

     

    Thanks in advance

  6. Hi VanDerSaAr

     

    I use a math captcha locally that randomly spits out either text or the numeral for each place....

     

    I then also add ONE hidden (via CSS) form element titled something like URL or link and check to see if that field is empty prior to submission.

     

    Never get spam.

     

    Ive also employed Key Captcha with great success though its not local

     

     

  7. Im getting the error: Unknown column 'data2.name' in 'field list' in this SELECT query and I'm at a loss.... :shrug:

     

    The table exists the column exists, I can SQL query

     

    SELECT refreport.user, refreport.division, refreport.hometeam, refreport.awayteam, refreport.week, refreport.homeleague, refreport.homeconference, refreport.awayconference, data2.name, data2.email FROM refreport INNER JOIN data on data2.user=refreport.user WHERE gameid='$id'";

     

    Thanks in advance!

  8. you've got a problem in your <.div><./div> s

     

    When I do that I right click look at source and count them out open and closed because it can get complicated and only you know what div because you've got the css, but you are likely missing a <./div> just before you open the sidebar div ;)

  9. following up on smearny... Google around for math captcha and you will find a full code that randomizes that process into numbers and text.

     

    I haven't gotten a single piece of spam on a form I implemented with that in 3 years.

     

    Theres also a nifty picture puzzle captcha that works quite well also and is probably easier to implement called key captcha .

  10. requinix

     

    Thank you for the help

     

    for anyone finding this is via a search my working code implemented on my subsequent independent script (resizeit.php) as suggested was:

     

     

    $img_path = $img; 
    $max_width = 110;
    $max_height = 400;
    list($width, $height) = getimagesize($img_path);
    $ratioh = $max_height/$height;
    $ratiow = $max_width/$width;
    $ratio = min($ratioh, $ratiow);
    // New dimensions
    $mywidth = intval($ratio*$width);
    $myheight = intval($ratio*$height);
    
    // Resample
    $image_p = imagecreatetruecolor($mywidth, $myheight);
    $image = imagecreatefromjpeg($img_path);
    imagecopyresampled($image_p, $image, 0, 0, 0, 0, $mywidth, $myheight, $width, $height);
    
    // Output
    header('Content-Type: image/jpeg'); 
    imagejpeg($image_p, null, 100);
    
    echo $image_p;

     

    and in my div tag I called to (just passed the image I wanted via img=):

    background-image:url(<?php echo $CONFIG["full_url"].$CONFIG["upload_folder"];?>resizeit.php?img=<?php echo ReadDB($News["image"]); ?>);

     

    I used this as a workaround to implement curvycorners on images in a loop

  11. oops

     

    I half solved my issue

     

    I see its returning:

    <div class="theimg" style="display:block; width:110px; height:146px; background-image:url(Resource id #12); background-repeat: no-repeat;"/> </div>

     

    What is the proper way to set Resource id #12 output to screen so Im getting the resized image?

  12. Hi cdoggg94

     

    Im working on a similar issue.  Here is my working code to get current width height then return desired scaled height, maybe you can work with it.

     

    // Constraints
    $img_path = MY IMG PATH HERE; 
    $max_width = 110;
    $max_height = 400;
    list($width, $height) = getimagesize($img_path);
    $ratioh = $max_height/$height;
    $ratiow = $max_width/$width;
    $ratio = min($ratioh, $ratiow);
    // New dimensions
    $mywidth = intval($ratio*$width);
    $myheight = intval($ratio*$height);

     

    mywidth and myheight will return your scaled numbers then you can do what you want with them.

  13. Hi there

     

    I have an image in a directory, that I need to resize on the fly but has to be a background in a div with a max width.  I have to determine the correct height according to this max width.

     

    So I sucessfully I have accomplished this, but its not scaling its jsut giving me the top left corner according to my height width properties.

     

    Here is my working code to grab height and width:

    $img_path = $CONFIG["full_url"].$CONFIG["upload_folder"].ReadDB($News["image"]); 
    $max_width = 110;
    $max_height = 400;
    list($width, $height) = getimagesize($img_path);
    $ratioh = $max_height/$height;
    $ratiow = $max_width/$width;
    $ratio = min($ratioh, $ratiow);
    // New dimensions
    $mywidth = intval($ratio*$width);
    $myheight = intval($ratio*$height);

     

    Now using those I need to resize the image proper to get it centered up.  I dont really want to save the file I just want to display it.  Is this possible?

     

    My attempts have garnered a bunch of crazy characters on screen and not an image.

     

    Here is the code I added to the end:

     

    // Resample
    $image_p = imagecreatetruecolor($mywidth, $myheight);
    $image = imagecreatefromjpeg($filename);
    imagecopyresampled($image_p, $image, 0, 0, 0, 0, $mywidth, $myheight, $width, $height);
    
    // Output
    imagejpeg($image_p, null, 100);

     

     

    Then Im using it on the page like so:

    <div class="theimg" style="display:block; width:<?php echo $mywidth;?>px; height:<?php echo $myheight;?>px; background-image:url(<?php echo $image_p; ?>); background-repeat: no-repeat;"/> </div>

     

    and heres what I get :/

    x5pp5j.jpg

     

    What am I doing wrong??  The image is not displaying inside its rounded corner border and we have crazy crap on top.

     

    Thanks in advance

     

     

  14. thank you both for the help.  Im now able to reference and echo $team1 through $team8 throughout my document.

     

    Can anyone please point me to more information on $$VariableName?  why the two $$?

     

    My final code that worked:

        # setup SQL statement
        $SQL = " SELECT DISTINCT team, rank FROM table ORDER BY by rank ASC";
        # execute SQL statement
        $teamsquery = mysql_db_query($db, $SQL, $cid);
        # check for errors
        if (!$teamsquery) { echo( mysql_error()); }
    
    while($row=mysql_fetch_array($teamsquery)) {
    $team=$row["team"];
    $rank=$row["rank"];
    
    // create the name you wish to use as a variable
    $VariableName = "team"."$rank";
    // Assign a value (team name) to the new variable
    $$VariableName = "$team";
    }

     

     

  15. Hi Ryan

     

    # check for errors

    if (!$ratingsys) { echo("ERROR: " . mysql_error() . "\n$query_ratingsys\n");

     

    $query_ratingsys = "UPDATE news SET votes = votes +1 AND rating = rating +'$ratingget' WHERE id = '$id'";

     

    vote and rating you are trying to add to are not variables.

     

    Also, use a comma where the AND is

     

    Before I processed the update request I would define $votes, then add the +1 as $newvotes

    define $rating then add $ratingget as $newrating

     

    Then UPDATE news SET votes='$newvote',rating='$newrating' WHERE id = '$id'";

     

    but Im a not very efficient hack and there is probably a smarter way :P

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