Jump to content

justlukeyou

Members
  • Posts

    957
  • Joined

  • Last visited

Posts posted by justlukeyou

  1. Gosh this is getting complicated. I have as per the following but it will only echo 1 result at time.

     

    I am trying to say only show the images which match the ID. This is the same number as the user_id.

     

    I have tried around 10 variations so it must the code that is wrong.

     

     

    
    <?php
    
    
    $query = mysql_query("SELECT user_id, logo FROM follow INNER JOIN users ON users.id = follow_user_id WHERE follow_user_id = $ID LIMIT 10");
    while($row = mysql_fetch_array($query)) {
    
      ?>	
    
      <?php echo $row['user_id']; ?>
    
    <?php echo $row['logo']; ?>
    
      	<?php
    	}
    	?>
    

  2. if you join 2 tables without specifying the join condition then you create a "cartesian join" which joins every record in table1 with every record in table2

     

    So if table1 has 10 records and table2 has 50 records you will get 500 (50x10) rows returned.

     

    In your case you get a row returned for every user

     

     

     

     

    I see. Thanks for the explanation.

     

    I found this example, but its very complicated. http://stackoverflow.com/questions/4521182/how-to-use-join-and-multiple-where-condition

     

    How would I add a join condition? I cant match the logo to anything. I can't say logo = ID.

     

    Do I need to say "join users where logo = null". To say I am not querying the logo and just querying the follow table.

     

    When I remove the join function it works but obviously does has no method of echoing the image.

  3. Hi,

     

    I am logged in as 403. In the table 'follow' I have user 403 following 355 once. So the code below should echo 403 once to say that the user I am logged in is following user 355.

     

    However the code below echoes 403 four times because I have 4 users in 'users' table.

     

    I'm struggling to understand why the number of rows in the users table affects the number of times it echoes the user_id is echoed.

     

    I want to display the user_id 403 once from table 'follow' and then join on the logo from table 'users'.

     

    The $ID comes from the users table.

     

    <?php
    
    $query = mysql_query("SELECT user_id, logo FROM follow, users WHERE follow_user_id = $ID LIMIT 10");
    while($row = mysql_fetch_array($query)) {
    
         ?>    
    
         <?php echo $row['user_id']; ?>
    
    <?php echo $row['logo']; ?>
    
             <?php
           }
           ?>
    
    

  4. Hi,

     

    This work..If I say its greater than zero.

     

    $organiserid = 0;
    
    $query = "SELECT * FROM eventjobs WHERE organiserid = " . intval($_SESSION['userID']) . " LIMIT 10";
    $result = mysql_query($query);
    $row = mysql_fetch_array($result);
    if ($organiserid > 0)
    {
     echo 'You have no events.  Create an event.';
    } else {
    {
    

  5. Hi,

     

    I haven't yet but when I just run a query it works fine.

     

    Do I need to say that the organiserid is at standard "0". So if ID 350 is entered then this is different so it will display everything?

     

    Or would I say its blank?

     

    So this would echo the eventname.

     

       <?php
    $query = "SELECT * FROM eventjobs WHERE organiserid = " . intval($_SESSION['userID']) . " LIMIT 10";
    if ($result = mysql_query($query)) {
    
                   $row = mysql_fetch_array($result);
           {
                   ?>
                          <div class="eventjoblistings">
                    <div class="boardeventfield">
                    <div class="boardeventfieldintro">
                       <div class="boardeventdatatitle">
                   <?php echo (!empty($row['eventname'])) ? $row['eventname'] : ''; ?>
    

  6. Hi,

     

    I have a code which displays the events that users have created. However if they have not created an event it shows the empty DIV cells. So I am trying to display a message "You have no events. Create an event." if the user has not created an events. I can get this to work if against the users login but I cant seem to be able to check with the cell is empty.

     

    I think I almost have it. Can anyone please advise how I complete it?

     

    So far it displays "You have no events. Create an event." Regardless of whether there is content in the database or not.

     

    <?php
    $query = "SELECT * FROM eventjobs WHERE organiserid = " . intval($_SESSION['userID']) . " LIMIT 10";
    if ($result = mysql_query($query)) 
    
    
       if (empty($organiserid))
    
    {
     echo 'You have no events.  Create an event.';
    
    
    
    
    
    } else {
    
    
    
                   $row = mysql_fetch_array($result);
    	{
                   ?>
    <div class="eventjoblistings">
    <div class="boardeventfield">
    <div class="boardeventfieldintro">
    			    <div class="boardeventdatatitle">
    			<?php echo (!empty($row['eventname'])) ? $row['eventname'] : ''; ?>
    			</div>
    			    <div class="boardeventdata">
    			<?php echo (!empty($row['eventdetails'])) ? $row['eventdetails'] : ''; ?>
    			</div>
    			    <div class="boardeventdatahalf">
    			<?php echo (!empty($row['eventlocation'])) ? $row['eventlocation'] : ''; ?>,
    			</div>
    			    <div class="boardeventdatahalf">
    			<?php echo (!empty($row['eventcountry'])) ? $row['eventcountry'] : ''; ?>
    			</div>
    			</div>
    							 <div class="boardeventfielddetails">
    			    <div class="boardeventdatasupplier">
    			<?php echo (!empty($row['supplier1'])) ? $row['supplier1'] : ''; ?>
    			</div>
    			    <div class="boardeventdata">
    			<?php echo (!empty($row['supplierdetails1'])) ? $row['supplierdetails1'] : ''; ?>
    </div>				
    			    <div class="boardeventdata">
    <?php echo (!empty($row['budget1'])) ? $row['budget1'] : ''; ?>
    </div>
    </div>
    											 <div class="boardeventfielddetails">
    			    <div class="boardeventdata">
    			<?php echo (!empty($row['supplier2'])) ? $row['supplier1'] : ''; ?>
    			</div>
    			<?php echo (!empty($row['details2'])) ? $row['details2'] : ''; ?>			
    <div class="boardeventdata">
    <?php echo (!empty($row['budget2'])) ? $row['budget2'] : ''; ?>
    </div>
    </div>
    </div>
    				</div>
    
    										<?php
    						        }
    } 
    }			
    
    							?>
    

     

     

     

     

  7. Hi,

     

    The search code is seperate to the forum. Im trying to find the simplest way to do it. Is there a standard way of producing search results from different tables?

     

     

     

    <form action="/test/searchoutput.php" method="post">
    <input type="text" name="keywords" size="20" placeholder='perform a search...' class="internalsearch" />
    </div>
    <div class="internalsearchimagecell">
    <input type="image"  value="Submit" src="/images/internalsearch.png" alt="Search" name="image" />
    </div>
    </form>
    

     

     

    <div class="searchresults">
    <div class="imagesearchresults">
    <a href="http://website.com"  rel="nofollow" >
    <a href="/profilepages/profile<?php echo ''.$result['usertypelink'].''; ?>.php?ID=<?php echo $row['id']; ?>"  rel="nofollow" >
    <img src="/test//images/<?php echo ''.$result['logo'].''; ?>" /></a>
    </div>
    <div class="datasearchresults">
    <div class="companysearchresults">
    <a href="/profilepages/profile<?php echo ''.$result['usertypelink'].''; ?>.php?ID=<?php echo $row['id']; ?>"  rel="nofollow" >
    <?php echo ''.$result['company'].''; ?>
    </a>
    </div>
    <div class="companysearchresults">
    <?php echo ''.$result['category'].''; ?> (<?php echo ''.$result['usertype'].''; ?>)
    </div>
    <div class="companysearchresults">
    <?php echo ''.$result['firstname'].''; ?> <?php echo ''.$result['surname'].''; ?>
    </div>
    <div class="companysearchresults"> 
    <?php echo ''.$result['town'].''; ?> | <?php echo ''.$result['country'].''; ?> | <?php echo ''.$result['postcode'].''; ?> 
    </div>
    </div>
    
    
    
    <?php
    }
       ?>
    </div>
    
    
    
    <?php
    } else {
    foreach($errors as $error) {
    echo $error, '</br>';
    }
    }
       ?>
    
    
    <?php
    function search_results ($keywords) {
    $returned_results = array();
    $where = "";
    
    $keywords = preg_split('/[\s]+/', $keywords);
    $total_keywords = count($keywords);
    
    foreach($keywords as $key=>$keyword) {
    $where .= "`firstname` LIKE '%$keyword%' OR `surname` LIKE '%$keyword%' OR `category` LIKE '%$keyword%' OR `company` LIKE '%$keyword%' OR `town` LIKE '%$keyword%' OR `country` LIKE '%$keyword%'";
    if ($key != ($total_keywords - 1)) {
    $where .= " AND ";
    
    }
    }
    
    $results = "SELECT `usertype`, `usertypelink`, `id`, `firstname`, `surname`, `category`, `company`, `logo`, `town`, `country`, `postcode` FROM `users` WHERE $where LIMIT 20";
    
    $results_num = ($results = mysql_query($results)) ? mysql_num_rows($results) : 0;
    
    if ($results_num === 0) {
    return false;
    }else{
    
    while ($results_row = mysql_fetch_assoc($results)) {
    
    $returned_results[] = array(
                       'usertype' => $results_row['usertype'],
    				'usertypelink' => $results_row['usertypelink'],
                       'id' => $results_row['id'],
                       'firstname' => $results_row['firstname'],
                       'surname' => $results_row['surname'],	
                       'category' => $results_row['category'],
                       'company' => $results_row['company'],	
                       'logo' => $results_row['logo'],	
                       'town' => $results_row['town'],	
                       'country' => $results_row['country'],	
                       'postcode' => $results_row['postcode'],						
    );
    
    }
    
    return $returned_results;
    
    }
    }
    ?>
    
    </div>		
    

  8. Hi,

     

    I have a search script which currently searches the details of users. However I am trying to add the option to search other tables. The problem is with the current code echoes the content into a set link.

     

    <a href="/profilepages/profile<?php echo ''.$result['usertypelink'].''; ?>.php?ID=<?php echo $row['id']; ?>
    

     

    The problem is that if I am searching other tables I need to use different links.

     

    Their are two options I can think of (probably both wrong)

     

    1. Use if statesments which sounds very complicated.

    2. Echo the link from the database!

     

    <a href="<?php echo ''.$result['searchlink'].'', ''.$result['usertypelink'].''; ?>.php?<?php echo $row['query']; ?>=<?php echo $row['id']; ?>
    

     

    Im unsure about both. Does any suggestions on what I can use?

  9. Does the job very nice. Could use more 'standard' design features such as mouseover background. The embossed text makes the site look old. Needs something in the top right hand corner. This site is has a great design but is also very affective.

     

    http://www.play.com/

     

    Your site has nice layout. Just needs 'modernising'. I like the photos as it make you look established. You could also add a photo of the staff smiling. Make it more personable so they get to know you. Build relationships with you directly so they trust you more. Beneath the text you could promote special offers or list hot products.

     

     

  10. Hi,

     

    I've been trying to learn CSS/HTML and PHP over the last six months to complete a site. It seems to appear fine across all the browsers IE9/IE8/Chrome and Firefox.

     

    I asked my mate to log in to my site. However he was using IE9 on a laptop and the login button would not load. I am quite shocked by this as it works fine when I have viewed it on IE9.

     

    Im gutted as a dont know how widespread this problem is. Any suggestions on what I can do to improve things?

     

    		  	<div class="registerinputright">
               <label for="loginSubmit"> </label>  
               <input type="hidden" name="loginSubmit" id="loginSubmit" value="true" />  
    						<div class="user-area">
    <input type="submit" value="Login" class="submit-button" /> 
    	</div>	   
    	   	</div>	
    
    	</ul>
           </form>
    

     

    .registerinputright{
      float:right;
      width:59%;
    font-family:Verdana, Geneva, sans-serif;
    font-size:100%;
    }
    
    .user-area {
    width: 74%;
    float: right;
    margin-top: 0px;
    }
    
    .user-area input, #contact-area textarea {
    padding: 5px;
    font-family: Helvetica, sans-serif;
    font-size: 140%;
    margin: 0px 0px 0px 0px;
    border: 2px solid #ddd;
    }
    
    
    .user-area textarea {
    height: 90px;
    
    }
    
    .user-area textarea:focus, 
    .user-area input:focus {
    border: 2px solid #6696F5;
    }
    
    
    .user-area input.submit-button {
    width: 100px;
    margin-top: 10px;
    }
    

  11. I have said this a number of times now. Saying that someone has a learning disability is just disgusting. This isn't a playground and there is no need to use language like that.

     

    I would like to take that little rat of a dog in your photo and turn it brown by shoving it deep up your ass. You continue to be rude at me and I might just be rude back.

  12. I told you what you are NOT doing that is causing the problem. Did you try to do it yet? That's what I mean by refusing to even try. You always just come back and ask for more more more.

     

    You claim you can do things in minutes yet none of it works correctly.

     

    I've spent around 5 to 6 hours just trying to complete this join query in the last two days. I think that constitutes as trying.

     

    How do I tell what to join on. The code looks like a typical join query. Because telling me what it is NOT doing doesn't help very much.

     

    Its a bit liking telling someone how not to drive. We could be here all day.

     

     

    The code I am using is also stuctured identical to how another member has suggest I use it where follow_user_id, logo, are together.

     

    Do I need to say what columns I want to put from users?

     

    $query = "SELECT follow_user_id, logo, company
                     FROM follow
                     JOIN users
                     WHERE user_id = {$row['id']}
                     ORDER BY follow_user_id ASC
                     LIMIT 10"
    

  13. Of course you don't, because you refuse to try to learn.

     

    Gosh you can be an obnoxious little madam sometimes. Im sorry but I think you should make it your New Years resolution to be less obnoxious.

     

    Like Ive said a number of times. I can now do things in minutes which used to take weeks. If I "refuse to learn" how can now do things in minutes which use to take weeks? That makes your point that I refuse to learn incorrect and some what rude.

     

    I have tried echoing all the terms to see if they match and they do. Just because I cant complete a join which to me looks to be in the same format as someone used doesn't mean I "refuse to learn".

     

    So can you plesae stop being so obnoxious.

  14. Hi,

     

    Im not totally sure what you mean. I am looking to take follow_user_id from follow and logo from users.

     

    The id (355) is in follows only once as user_id so Im confused how it would display all the rows in users.

     

    When I echo ($row['id']) it does display 355. But the code displays at user_id in follow.

     

     

    [code
    $query = mysql_query("SELECT follow_user_id, logo FROM follow JOIN users WHERE user_id = " . ($row['id']) . " ORDER BY user_id ASC LIMIT 10");
    while($row = mysql_fetch_array($query)) {
    [/code]

     

     

  15. Hi,

     

    I am finding something very odd with the join function. When I add the join function it echoes every row in the second table. However when I do not use the join function it correctly displays only one value.

     

    I dont have any of the same cell names between the two tables so I cant see where the confusion is coming from. Any suggestions please?

     

      <div class="followbuttonimagearea">
    <?php
    $query = mysql_query("SELECT follow_user_id, logo FROM follow JOIN users WHERE user_id = " . ($row['id']) . " ORDER BY user_id ASC LIMIT 10");
    while($row = mysql_fetch_array($query)) {     
      ?>	
    
    
    <div class="followimage">
    <a href="/test/profileinserttest.php?ID=<?php echo $row['follow_user_id']; ?>"><img src="/test/images/<?php echo $row['logo']; ?>" alt="<?php echo $row['company']; ?>" /></a>
    		 	</div>
    <?php
    }
      ?>
    

     

     

     

     

      <div class="followbuttonimagearea">
    	<?php
    $query = mysql_query("SELECT follow_user_id FROM follow WHERE user_id = " . ($row['id']) . " ORDER BY user_id ASC LIMIT 10");
    while($row = mysql_fetch_array($query)) {     
      ?>	
    
    
    <div class="followimage">
    <a href="/test/profileinserttest.php?ID=<?php echo $row['follow_user_id']; ?>"><img src="/test/images/<?php echo $row['logo']; ?>" alt="<?php echo $row['company']; ?>" /></a>
    		 	</div>
    <?php
    }
      ?>
    

  16. try quotes

     

    WHERE  activationcode = '$accountnumber'

     

    Cheers dude. Its another one of those codes that took 2 minutes to write but I just couldn't finish it off.

     

    I am now matching the activation code and inserting Y into a second column. I take it I can now adapt the login page to check if the Y is this column.

     

    If someone registers but forgets to click the activation link but tries to register again should I check if the email address already exists but if the Y doesn't exist to resend the activation link?

  17. Hi,

     

    When I echo activationcode it displays: 50e1fa5ad38e7

    When I echo accountnumber it displays: 50e1fa5ad38e7

    In the database is: 50e1fa5ad38e7

     

    This is the link that the created and sent via an email: activation.php?activationcode=50e1fa5ad38e7

     

    This is the error message. Notice that the first 4 characters (50e1) are removed. This is the error message I receive:

     

    "An error occurred 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 'fa5ad38e7' at line 4"

     

    Does anyone have any suggestions on how the activation code is shortened.

     

    <?php
    echo $row['activationcode'];
    ?>
    
    
    <?php     if(($activationcode) == ($row['activationcode'])) {
           $errors['activationcode'] = "Congratulations.  You have now successfully registered.";
       } 
    
    ?>
    
    
    
    
    
    <?php
    $accounty = ('Y'); 
    echo $activationcode;
    echo $accounty;
    
    $accountnumber = $activationcode;
    
    echo $accountnumber;
    
       if($error == "")
       {
           $sql = "
           UPDATE
               users
           SET accountconfirmed = '".$_GET['activationcode']."' 
    	WHERE  activationcode=$accountnumber";
    
           $result = mysql_query($sql) or die("An error occurred ".mysql_error());
    
       }
    
    
    			     $result = mysql_query($query); // remove the or die(mysql_error()) 
        if($result){
             $success['register'] = 'Congratulations. Your account has been activated!<br><br>';
    	  }
    
    
    
    ?> 
    

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