Jump to content

Clinton

Members
  • Posts

    337
  • Joined

  • Last visited

Posts posted by Clinton

  1. I've got a table that lists office locations by city and state. Sometimes there are several offices in one city. Right now I am using the following code to pull up the citys

     

    City: <select name="city" onchange='this.form.submit()'>
    				<?php
    
        				$sql = "SELECT city FROM thelist WHERE state = '$state' ORDER BY city";
    
    				$rs = mysql_query($sql);
    
    				while($row = mysql_fetch_array($rs))
    				{
        				extract($row);
      					echo "<option value='$city'>$city</option>";
    				}
    
         				?>
                        </select>
    

     

    But if there is three offices in one city then it will echo out that same city 3 times in the drop down list. What's the best way to correct this so it only shows once?

  2. I didn't think it was that complicated but everytime I add another variable it seems to not work. This time it's the state variable. I added it and my query is pretending like it's not there and displaying the rest of the result. ANy ideas?

     

    $sql = "SELECT * FROM $tbl_name WHERE dtype = '$dtype' OR dtypewc = '$dtype' AND dmajorp = '$smajor' OR dmajorc1 = '$smajor' OR dmajorc2 = '$smajor' OR dmajorc3 = '$smajor' AND state = '$state' ORDER BY jpted LIMIT $start, $limit";
    

  3. Well regardless of cookie time if a browser is closed the sessions generally kill, at least most websites I have been on. Mine's not doing that and I prefer it that way. Other than that they could stay logged in for eternity, which is fine with me hence the unusually long time.

  4. I did the code below because I'm going to replace dtype = * with dtype = $variable and I wanted to get it to work... which it's not. Basically, I want to be able to narrow down the search by dtype AND the dmajors but if there is no specific dtype selected I want to show all of the dtypes. Make sense?

     

     <?php $query = "SELECT COUNT(*) as num FROM $tbl_name WHERE dtype = * AND dmajorp = '$smajor' OR dmajorc1 = '$smajor' OR dmajorc2 = '$smajor' OR dmajorc3 = '$smajor' ORDER BY jpted"; ?>

  5. Ok, when I click the logout button this gets executed and the session ends.

     

    if (isset($_COOKIE[session_name()])) {
        setcookie(session_name(), '', time()-42000, '/');
    

     

    However, if the browser closes, or even when the computer restarts, the session still remains if I do not logout. How do I fix this? Do I have to put the setcookie on every page...???

  6. Ok, Premiso... I did not enter anything into that line (dtypewc) so why did it "set"? How does something "set"? I looked up in the manual but it doesn't say how a variable set's.

     

     

    Thanks for the empty link btw.

  7. I have this...

     

    <?php if (isset($dtypewc))
    { ?>
    	<tr><td id='header'>
    	Will Consider a <?php echo $dtypewc; ?>.
    	</td></tr>
    <?php }	 ?>
    

     

    Now, my $dtypewc variable is empty but it's still returning the "Will Consider a"...

     

    Any ideas why?

     

    Thanks.

  8. I've been scouring the internet up and down and have found a lot of pieces about mysql, php, and pictures and have tried to put them together to form my code.... but... it's failing. So a couple of questions...

     

    I've got this on the page (we will call showimage.php) I want to show the picture:

     

    <h3><img src="getimage.php?name=<?php echo $username ?>" width=100 Height=125></h3>
    

     

    I've got this on the getimage.php page:

     

    <?php
    
    include 'connect/project.htm';
    
    $name = $_GET['name'];
    
    $result=mysql_query("SELECT clogo FROM employers WHERE username='$name'") or die(mysql_error());
    $row=mysql_fetch_object($result);
    Header( "Content-type: image/png");
    echo $row->content;
    ?>
    

     

    Now, the showimage.php page is just displaying a broken link.

     

    The getimage.php page is displaying the text "http://localhost/project/getimage.php?name=hunna03" as an image and not the actual image.

     

    So the questions...

     

    1) I am saving images as a BLOB in mysql. How do I know they are saving correctly? I can't find any way to see them in MySQL.

     

    2) What am I doing wrong with this code?

     

    Thanks.

  9. Let's say I've got three fields that keep track of a persons skills.

     

    These are Bobs skills...

     

    Field 1 is his primary skill, say a Carpenter.

    Field 2 is his secondary skill, say a Hair Dresser.

    Field 3 is his tertiary skill, say a Window Washer.

     

    These are Joes skills...

     

    Field 1 is his primary skill, say a Hair Dresser.

    Field 2 is his secondary skill, say a Carpenter.

    Field 3 is his tertiary skill, say a Window Washer.

     

    Now lets say I wanted to pull up all the people who are qualified to be a carpenter. How do I do this?

     

    Right now I've got:

     

    SELECT * FROM thelist WHERE pskill = 'carpentry'
    

     

    But this only lists the ones who have the primary skill of carpentry.

     

    If I do:

     

    SELECT * FROM thelist WHERE pskill = 'carpentry' AND sskill = 'carpentry' 
    

     

    then it leaves out anybody who just has the primary skill (or secondary if I include the third).

     

    How do I make it so it finds all carpenters in any of those three fields without excluding everyone if one doesn't have it?

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