Jump to content

Clinton

Members
  • Posts

    337
  • Joined

  • Last visited

Posts posted by Clinton

  1. Currently I have a query set to do a search based upon no TimeOut and for a particular location using the $tablename table. That looks like:

     

    $query = "SELECT * FROM $tablename WHERE TimeOut = '0000-00-00 00:00:00' AND Location = '$location'";
    

     

    This ^ works just fine.

     

    Now, one of the columns in $tablename is Position. In a different table ($tabletwo) I have a table that lists the same positions and an associated rank (a Manager would be 1, a Supervisor 2, Worker 3, etc.).

     

    So in both tables, the common denominator is the Position/Positions column.

     

    I would like to order the results based upon the column Position(s) using the rank established in $tabletwo (so individuals identified as Manager would be shown near the top instead of scattered throughout).

     

    I can't seem to figure this out. I tried:

     

    SELECT * FROM $tablename WHERE TimeOut = '0000-00-00 00:00:00' AND Location = '$location' as t1 LEFT JOIN $tabletwo AS t2 on t1.Position = t2.Positions ORDER BY t2.Rank
    

     

    amongst about a hundred other things and can't seem to get it to work.

     

    Any help would be appreciated.

     
     

  2. I seriously can't figure this out.

     

    Code:

    <?php
    session_start();
    if(!isset($_SESSION['me']))
    {  header("location:index.php");  }
    $action=$_POST["action"];
    $from=$_POST["name"];
    $message=$_POST["message"];
    $when=$_POST["when"];
    echo $action . "<p>";
    echo $from . "<p>";
    echo $message . "<p>";
    echo $when . "<p>";
    if ($action == "add") { 
    mysql_connect("localhost", "name", "name") or die(mysql_error());
    mysql_select_db("name") or die(mysql_error());
    mysql_query("INSERT INTO tweet(from,when,message)VALUES('$from','$when','$message')") or die(mysql_error());
    header("location:home.php");
    }  ?>
    

     

    Produces:

    add
    blah@gmail.com
    Mary had a little lamb its fleece was white as snow.
    2013-01-29 19:13:31
    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'from,when,message)VALUES('blah@gmail.com','2013-01-29 19:13:31','Mary ha' at line 1
    

     

    I'm beating my head. I can't fricken figure it out. Where's the error? Everything it's echoing is exactly what I'm putting into the system so the error isn't there. But where might it be?

     

    Any help appreciated. Thank you.

     

    CJA

  3. I posted something similar to this recently but the variable isn't defined, as it was in the last one.

     

    I have two tables. The 'user' table contains the id, first name, and last name of the individual. The 'uinfo' table contains other pertinent info about the user.

     

    I want the code to look at the 'uinfo' table where reviewed = 0 and gather all of the ID's (uid) of those members.

     

    Then, based off of those ID's I want it to gather their names from the other table and list them so I can click on them. I'm just not quite sure how to do that. :-\

     

    $sql="SELECT uid FROM uinfo WHERE reviewed='0'";
    $result=mysql_query($sql);
    while($row = mysql_fetch_array($result))
    {
    $uid = $row['uid'];
    
    $sql="SELECT FirstName, LastName FROM users WHERE id='$uid'";
    $result=mysql_query($sql);
    while($row = mysql_fetch_array($result))
    {
    $admin = $row['admin'];
    $FirstName = $row['FirstName'];
    $LastName = $row['LastName'];
    echo "<br><a href='blah.php?id=" . $uid . "'>" . $FirstName . " " . $LastName;
    }
    }
    

  4. First, the idea: I want to post announcements for all users and then allow them to "clear" them off of their announcement list.

     

    I have two tables.

     

    Table 1 (announce) holds announcements. It has the fields of id, date, and info.

     

    Table 2 (ackannounce) holds the fact that a user has "cleared/acknowledged" an announcement and contains the fields aid (announcement ID) and uid (user ID).

     

    Essentially I want the code to check the table 'ackannounce' and then display whatever announcements have NOT been "cleared/acknowledged" by the user.

     

    The code below, however, is not accomplishing that (all the variables are fine and populate appropriately).

     

    Any help in demistifying this for me would be greatly appreciated.

     

    <?
    $sql="SELECT * FROM ackannounce WHERE uid='$uid'";
    $result=mysql_query($sql); ?>
    <p>
    <center>
    <font color="green">
    <table width="85%" border="3" cellspacing="0" cellpadding="0">
    <?
    while($row = mysql_fetch_array($result))
    {
    $aid = $row['aid'];
    $sql2="SELECT * FROM announce WHERE NOT id = '$aid'";
    $result2=mysql_query($sql2);
    while($row = mysql_fetch_array($result2))
    {
    $id = $row['id'];
    $info = $row['info'];
    ?>
    <tr><td width="20%">Date: <? echo date("m-d-Y",strtotime($row['date']));?> </td><td><br><? echo $info; ?><br> <br><a href="ackannounce.php?aid=<?echo $id;?>&uid=<?echo $uid; ?>">Acknowledge/Clear</a><br> </td></tr>
    <? }} ?>
    </table>
    </font>
    </center>
    </p>
    

  5. Thanks, folks. I did what you suggested and it still didn't work.

     

    Then, I finally figured it out and I feel like putting my head through a wall.

     

    My editor was acting screwy so I took the long statement and typed it in a document, so I could see it properly. Well, instead of ' it uses . Oh how that little slant makes all the difference in the world and such a newb mistake. 8-\

  6. I've been racking my brain for about 2 hours... can't figure out why this isn't inserting into the database?

     

    I have verified that num_rows is coming back as 1 so it should be executing it accordingly. My webpage does echo "The End" so it's running through it correctly, it's just not running the INSERT INTO but not giving me a die error.

     

    It's the right table, the right everything... I just can't figure it out.

     

    if(mysql_num_rows($result)=='1'){
    while($row = mysql_fetch_array($result))
    {
    $uid = $row['id'];
    }
    $dob = $dobyear . "-" . $dobmonth . "-" . $dobday;
    $cred1expire = $year1 . "-" . $month1 . "-" . $day1;
    $cred2expire = $year2 . "-" . $month2 . "-" . $day2;
    $cred3expire = $year3 . "-" . $month3 . "-" . $day3;
    $cred4expire = $year4 . "-" . $month4 . "-" . $day4;
    $cred5expire = $year5 . "-" . $month5 . "-" . $day5;
    $homephone = preg_replace('/\D+/', '', $homephone);
    $cellphone = preg_replace('/\D+/', '', $cellphone);
    $dlnumber = preg_replace('/\D+/', '', $dlnumber);
    $dayphone = preg_replace('/\D+/', '', $dayphone);
    $evephone = preg_replace('/\D+/', '', $evephone);
    $oneyear = mktime(0,0,0,date("m"),date("d"),date("Y")+1); 
    $annual = date("Y-m-d", $oneyear);
    mysql_query("INSERT INTO uinfo (uid,address,city,county,zip,homephone,cellphone,carrier,texts,dob,dlnumber,dlstate,languages,ename,relationship,dayphone,evephone,employer,position,waddress,wcity,wcounty,wzip,emergency,memployer,choice1,choice2,choice3,interest,interestedposition,travel,distance,length,transport,cred1,cred1num,cred1state,cred1expire,cred2,cred2num,cred2state,cred2expire,cred3,cred3num,cred3state,cred3expire,cred4,cred4num,cred4state,cred4expire,cred5,cred5num,cred5state,cred5expire,hear,contract,annual) VALUES ('$uid’,'$address’,'$city’,'$county’,'$zip’,'$homephone’,‘$cellphone’,‘$carrier’,‘$texts’,‘$dob’,‘$dlnumber’,‘$dlstate’,‘$languages’,‘$ename’,‘$relationship’,‘$dayphone’,‘$evephone’,‘$employer’,‘$position’,‘$waddress’,‘$wcity’,‘$wcounty’,‘$wzip’,‘$emergency’,‘$memployer’,‘$choice1’,‘$choice2’,‘$choice3’,‘$interest’,‘$interestedposition’,‘$travel’,‘$distance’,‘$length’,‘$transport’,‘$cred1’,‘$cred1num’,‘$cred1state’,‘$cred1expire’,‘$cred2’,‘$cred2num’,‘$cred2state’,‘$cred2expire’,‘$cred3’,‘$cred3num’,‘$cred3state’,‘$cred3expire’,‘$cred4’,‘$cred4num’,‘$cred4state’,‘$cred4expire’,‘$cred5’,‘$cred5num’,‘$cred5state’,‘$cred5expire’,‘$hear’,‘$contract’,‘$annual’)" or die (mysql_error()));
    echo $homephone; ?> The End. <? } else { ?> There has been an error. Please consult your webmaster for assistance. <br> <? }} ?>
    

  7. Yes, I searched high and low through google and this site and have tried a couple of different things but nothing is working. I'm trying to imbed an image in an html email that is sent via php but for the life of me I cannot get it working. What am I doing wrong?

     

    <?php
    $to      = $_POST['email'];
    
    $subject = 'Test';
    
    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    $headers .= 'From: Test.com <support@test.com>' . "\r\n";
    
    $body = "
    
    $prefix $lname,<p>
    
    The rest of HTML Font goes here... blah blah blah...
    
    Sincerely,
    Me!
    Add image here!!!!
    ";
    
    $headers .= 'Content-type: image/png; name="images/logob.png" . \r\n';
    
    mail($to, $subject, $body, $headers);
    
    ?>
    

  8. The code below works on the first go around but not completely on the 2+ go around:

     

    <?php
    
    $sql = "SELECT * FROM apply WHERE did = '$id' ORDER BY rname";
    $rs = mysql_query($sql);
    $i=0;
    while($mrow = mysql_fetch_array($rs))
    {
    $query = mysql_query("SELECT jid FROM apply WHERE did = '$id'");
    $row = mysql_fetch_assoc($query);
    $jid = $row['jid'];
    
    $query = mysql_query("SELECT * FROM thelist WHERE id = '$jid'");
    $row = mysql_fetch_assoc($query);
    $jtitle = $row['jtitle'];  /// THIS ROW ///
    $cname = $row['cname']; /// AND THIS ROW DO NOT SHOW ON THE 2+ LOOPS ///
    
    extract($mrow);
    $applydate = date("Y-m-d", strtotime($applydate));
    $bground = "#33AA00";
    if (($i%2) == 0)
               $bground = "#0000BB";
               $i++;
    	 ?>
    
    <tr bgcolor="<?php echo $bground; ?>"> <td> <?php echo $applydate; ?> </td> <td> <?php echo $jtitle; ?> </td> <td> <?php echo $cname; ?> </td> <td> <?php echo $closingdate; ?> </td> <td> <?php echo $status; ?> </td> <td><a href="astatus.php?did1=<?php echo $did; ?>&del=yes&id1=<?php echo $id; ?>" onclick="return confirmDelete();"> Delete </a></td>
    				</td></tr>
    				<?php } ?>
    

     

    Any idea why this might be happening???

  9. Ok, I use this code to insert a record into the db...

     

    $result = mysql_query("INSERT INTO ply (did, rn, cltr, eid, jid, cdate) VALUES ('$did', '$rn', '$cltr', '$eid', '$jid', '$cdate')");
    

     

    Now, when this inserts it does an automatic auto-increment on an 'id' column that is not listed. Is there a way that I can turn right back around after this gets inserted and get the corresponding id number?

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