Jump to content

justlukeyou

Members
  • Posts

    957
  • Joined

  • Last visited

Posts posted by justlukeyou

  1. Hi,

     

    I have been using a code which displays different content depending whether I am logged in or not. However I am trying to add code but I just cant seem to get the code layout (there is a word for it) to work correctly.

     

    The code below displays this:

     

    " . $success["success"] . "
    "; ?>
    " method="post">
    

    I have spent around 4 hours trying to get it to work but I cant get the code to sit inside the code which displays the content based on whether someone is logged in or not.

     

     

    		 <?php
    	     if ($_SESSION['userLoggedIn'])
    {
      echo '
         logged in
      ';
    } else { echo 
    '
    
    <div class="content-container1">
    		<div class="content-container2">
    	<div class="section-navigation">
    			</div>
    						<div class="content">	
    			
    			<div class="submitinfocell">
    
    
    		<div class="updateerrorcell">
    		 <?php if($success["success"]) print "<div class="valid">" . $success["success"] . "</div>"; ?> 
    	</div>		
    		</div>	
    			
    			<div class="submiteventarea">
    	<div class="submiteventbox">
    	
    	<form class="form_id"  class="appnitro"  action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post"> 
    			<ul >	 
    	
    
  2. If I manually enter the dates into DATE I can get the calculation to work which I am really please about. However I cant get the jQuery to insert a value into DATE.

     

    				<?php
    $startdate = $row['eventstart'];
    $enddate = $row['eventend'];
    
    
    		 
    		 $days = (strtotime($enddate) - strtotime($startdate)) / (60 * 60 * 24);
    print $days;
    
    ?>
    
  3. Thanks,

     

    However the jQuery does insert the date into the table when I set the column value as DATE.

     

    When I set the cell as TEXT it will insert the date, but not when I select DATE.

     

    When I insert the value when the table is set at DATE it only inserts 0000-00-00 into the table.

  4. I am using the jQuery code to insert a US format date format into a table.

     

    However I have two frustrating problems. Firstly I can only insert the value as text so I cant use it to calcualte with. I have tried the five date and time values in MyAdmin but each time I run the jQuery code it inserts the value as zeroes.

     

    $startdate = $row['eventstart'];
    $enddate = $row['eventend'];
    
    $numberofdays = $startdate - $enddate;
    
    I also found this but it states that the date format is english but the jQuery datepicker is in an American format.

     

    Any suggestions please on what I need to insert a date format instead of text. From there I should be able to calculate the number of days.

     

    http://php.net/manual/en/function.strtotime.php

     

    echo $numberofdays;		 
    $days = (strtotime($$startdate) - strtotime($enddate)) / (60 * 60 * 24);
    print $days;
    

    http://jqueryui.com/datepicker/

  5. Brillant thanks,

     

    It was actually much easier than I thought it was, however I am having problems creating two datepickers on the same page. I am trying to use datepicker and datepicker1 for the start and end date. However what configuration I try doesn't seem to work.

     

    Can you advise how to use two functions on the same page?

     

    <script>
    $(function() {
    $( "#datepicker" ).datepicker();
    });
    $(function() {
    $( "#datepicker1" ).datepicker1();
    });
    </script>
    <script>
    $(function() {
    $( "#datepicker" ).datepicker();
    $( "#datepicker1" ).datepicker1();
    });
    </script>
  6. Actually the first "datepicker" works, do i need set a unique datepicker for each time I want to use it?

     

    <p>Date: <input type="text" id="datepicker" /></p>
    <p>Start: <input type="text" name="startdate" id="datepicker" /></p>
    <p>End: <input type="text" name="enddate" id="datepicker" /></p>
    
  7. Hi,

     

    Do I put this inside a form with a submit button.

     

    Would I mark them startdate and endate?

     

    <p>Date: <input type="text" id="datepicker" /></p>
    
    
    <p>Date: <input type="text" name="startdate" id="datepicker" /></p>
    
    <p>Date: <input type="text" name="enddate" id="datepicker" /></p>
    
  8. Hi,

     

    I can use the jQuery code on a page but I cant insert the selected date into a table.

     

    I am struggling to see how I can add a submit button to this code. Is this designed to be used with PHP?

     

     

    <html lang="en">
    <head>
    <meta charset="utf-8" />
    <title>jQuery UI Datepicker - Default functionality</title>
    <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css" />
    <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
    <script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script>
    <link rel="stylesheet" href="/resources/demos/style.css" />
    <script>
    $(function() {
    $( "#datepicker" ).datepicker();
    });
    </script>
    </head>
    <body>
    <p>Date: <input type="text" id="datepicker" /></p>
    </body>
    </html>
    
  9. Hi,

     

    I asked someone what I should do to solve this BEFORE I came on here and they said to use a multi-dimensional array, that is why I asked on here how to do a multi-dimensional array.

     

    Unless Im wrong no one has explained why I should not use a multi-dimensional array and instead use data normalisation.

  10. Hi,

     

    I got this code to work but there is no data normalisation so should I be using it?

    	<?php
    //Create a function. The advantage is that it is reusable is reusable
    //This can be stored in a seperate file if required i.e. functions.php
    //It can be included in the main file using includes('functions.php); and reused in other pages.
    
    if (isset($_GET['skill'])) { //Checks if the url parameter exist
    	$skill = $_GET['skill'];
    	$skills = getSkill($skill); //This passes the url parameter to the function
    }
    
    function getSkill($skill) {
    	$sql = "SELECT * FROM users WHERE skill1 = '$skill' OR skill2 = '$skill' OR skill3 = '$skill'";
    	//Selects records from the database where skill1 or skill2 or skill3 match the url parameter
    	$result = mysql_query($sql) or die(mysql_error());
    	
    	while ($row = mysql_fetch_assoc($result)) {
    			$skills[] = $row;
    			//Builds an array of the results
    		}
    	return $skills;
    	//Returns the array
    	}
    	foreach ($skills as $skill)
    ?>
    
  11. So I need to place all the skills from the 3 columns into one column along with the users id. Perform a query against this single column and perform a join query?

     

    I would also have to set up a method to update both the original 3 columns and this single column.

     

    If I have 3 columns simultaneously inserted into one column will that work. Is it possible to insert 3 into 1 simultaneously.

     

    I am confused why someone else suggested I use multi-dimensional array. That suggests I dont need to set up another table.

  12. Hi,

     

    Im totally confused now. I cant see where you are saying $id = $_SESSION['userid'];

     

    Is that the one thing I need to do instead of declaring it beforehand?

        <?php
        $query = $pdo->query("SELECT * FROM users WHERE id = {$id}")->fetch();
        $query->bindParam(':id', $id);	// You bind the required parameters for your query
        $query->execute(); // This sends the query to the SQL server
         
        $user = $query->fetch(PDO::FETCH_ASSOC); // Specify the PDO::FETCH_ASSOC to fetch the data as an associative array (not required)
         
        echo '<pre>'; // I always PRE before I print an array which makes it more readable in the browser
        print_r($user); // This contains your fetched row from the sql server
         
        ?>
    
  13. Hi,

     

    I tried to use this but I cant seem to full the fetch. To tell it that $id is from the the userID session.

        <?php
        $query = $pdo->query("SELECT * FROM users WHERE id = {$id}")->fetch(intval($_SESSION['userID'])); // You first PREPARE the query
        $query->bindParam(':id', $id );	// You bind the required parameters for your query
        $query->execute(); // This sends the query to the SQL server
         
        $user = $query->fetch(PDO::FETCH_ASSOC); // Specify the PDO::FETCH_ASSOC to fetch the data as an associative array (not required)
         
    	echo $id;
         echo $user['firstname']; 
        ?>		
    
  14. Bloody hell, this code actually works!!!

     

    I wrote it here, didn't think it would work.

     

    I just had to swap the two sets of images. See Jessica, I am learning!

     <?php
    $query = mysql_query("SELECT * FROM follow WHERE user_id = '". $profileid ."' AND follow_user_id= '". $followerid ."'"); 
    $duplicatefollow = null;
    if (mysql_num_rows($query) > 0) 
    { 
    echo '<img src="/images/successfulfollow.png.png" />'; 
    } 
    else
    {
    echo '<input name="followbutton" CLASS="submitbutton" type="submit" />'; 
    }
    ?> 
    
  15. Hi,

     

    I have a social networking button which is an image. However when someone clicks the button to follow someone I want to replace the follow button with a standard image.

    <input name="followbutton" CLASS="submitbutton" type="submit" />
    
    $query = mysql_query("SELECT * FROM follow WHERE user_id = '". $profileid ."' AND follow_user_id= '". $followerid ."'"); 
    $duplicatefollow = null;
    if (mysql_num_rows($query) > 0) 
    { 
    echo ' <input name="followbutton" CLASS="submitbutton" type="submit" />'; 
    } 
    else
    {
    echo '<img src="/images/successfulfollow.png" />
    }
    
    Any suggestions please?
  16. I (finally) have a script which uploads images and then displays the uploaded image once the image is uploaded.

     

    However I want to display the current images first to make the page look more presentable. However to do this page has to be loaded twice. I asked on one forum and they suggested I use javascript however I thought that one alternative is to post the images uploaded to a page that runs the code and returns it to the image upload page. Enabling me to display the newly uploaded images straight away.

     

    Is this possible, if so is their a certain process I should follow?

  17. Hi,

     

    The following reads the userID when I am logged in and echoes the firstname of the user. However with my MYSQL code I was running the query against the user ID so it took less code. Is the first set of code correct, I take it isn't?

        <?php
        $id = intval($_SESSION['userID'])  ;
        $query = $db->prepare('SELECT * FROM users WHERE id = :id'); // You first PREPARE the query
        $query->bindParam(':id', $id );	// You bind the required parameters for your query
        $query->execute(); // This sends the query to the SQL server
         
        $user = $query->fetch(PDO::FETCH_ASSOC); // Specify the PDO::FETCH_ASSOC to fetch the data as an associative array (not required)
         
    
         echo $user['firstname']; 
        ?>	
    
    $query = "SELECT * FROM users WHERE id = " . intval($_SESSION['userID']) . " LIMIT 1";
    if ($result = mysql_query($query)) {
    
  18. Thanks,

     

    So I do just need to deploy different syntax?

     

    Could MySQL be switched off one day so any site using MySQL will just error? If so that will make it incredibly difficult to correct it.

     

    It was hard enough planning how I wanted the site to appear.

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