mikulucky 25 Junior Poster in Training

As a web developer, you do not need to know about the actual coding of the backend of a website. However you must be fluent in especially jQuery json, it really helps to know back end scripting, such as php and so on.

However the most important aspect is to know all the bugs with each version of each browser compared to the html and css. I can't stress that point the most.

mikulucky 25 Junior Poster in Training

Hi

Yeah this can be really horrible at times!!!!

This is a snippet, I would recommend changing this into a function of some sort, just returning true or false.

$regex = "((https?|ftp)\:\/\/)?"; // SCHEME 
    $regex .= "([a-z0-9+!*(),;?&=\$_.-]+(\:[a-z0-9+!*(),;?&=\$_.-]+)?@)?"; // User and Pass 
    $regex .= "([a-z0-9-.]*)\.([a-z]{2,3})"; // Host or IP 
    $regex .= "(\:[0-9]{2,5})?"; // Port 
    $regex .= "(\/([a-z0-9+\$_-]\.?)+)*\/?"; // Path 
    $regex .= "(\?[a-z+&\$_.-][a-z0-9;:@&%=+\/\$_.-]*)?"; // GET Query 
    $regex .= "(#[a-z_.-][a-z0-9+\$_.-]*)?"; // Anchor 

    
    $url = 'http://www.domain.dk/seo/friendly/url';
    
       if(preg_match("/^$regex$/", $url)) 
       { 
               print 'true'; 
       }
klemme commented: Provided a great snippet for validating URLS! +3
mikulucky 25 Junior Poster in Training

If they have to login, then you can store that user in a session. If you want an overview of all the people online, you may want to store that in the database.

What pritaeas means is when you user logs in, then there would be an extra column in your table for your users called for example active. When the user logs in then your log in script will update this field to 1, then when the user logs out it could change it to a 0.

Even better would to be to have another column as well as the above which has an expire time, so when the user logs in it is set to active, and the expire time is set to the same as the death of the cookie. This means that you can have another script that checks this table updating all the statuses of the users who are marked as active however the expire time has passed.

Well that is a bit more detail, but all credit goes to @pritaeas for solution.

pritaeas commented: Thanks for explaining ;) +14
mikulucky 25 Junior Poster in Training

Yeah I realise that yOur a student. But you don't seem to grasp the basics. And you should not need help at every step. You should solve problems yourself, the major part of being a programmer is to problem solve. Not to ask for help as soon as your stuck.

mikulucky 25 Junior Poster in Training

I understand your point of view, but I wasn't referring to start learning programming using Assembly. When I said at the beginning of your career, I meant a first job. Also, I personally think that knowing a little bit about hardware can help become a better programmer.

Oh sorry for miss reading your post, yeah learning hardware can help, importantly memory management.

dheaven commented: People gotta know a little bit about hardware :) +1
mikulucky 25 Junior Poster in Training

All you would have to do is like your doing already, if you have a value that states the users type, then if not admin then echo something with a link. Or if the user account as you are only searching for admin users, then if the user is not found based on the credentials that have been passed to you then have a common redirect. Stating that your login failed, please try again.

mikulucky 25 Junior Poster in Training

Ok the code needs to be tidied up. Instead of using loads of "echo statements", mixed with variables use printf like below. Only use echo for constant strings that you don't want to change. However you should not really mix php with html, or other sorts of design, as it can get really messy and easily break a page.

$result = mysql_query ("SELECT * FROM cal WHERE data = '(2012-01-01)' " ) ;
$events = mysql_num_rows($result) ;

if ( $events )
{
   echo "<td class = 'date_has_event'> <div class='events'> <ul> " ;
   	
   while ( $row = mysql_fetch_array ( $result ) )
   {
      printf("<li><span class='title'>%s</span><span class='desc'>%s</span></li>",$row['title'],$row ['event'] ) ;		   				   
   }
	   
    echo " </ul> </div>  </td>";
	
} else {
	
    echo "<td></td>";

}

As for your second question no your not able to do this, however if there was a way to do this, I would not recommend it, as it looks like it could get really messy. You want your code to be as clear as possible incase you need to go back to it in years to come.

Well I hope that this helps. :)

mikulucky 25 Junior Poster in Training

I don't understand the %s bit, when executed there is nothing %s, could you explain?

The '%s' means that this is a placeholder for a string, which is later filled in with the value stated later. So the first '%s' would be filled in with '$row' while the second with '$row'.

The line of code that I gave you has to be placed within the WHILE loop. So:

if (isset($_POST['search_now'])) 
{
    $result = mysql_query("SELECT * FROM bands WHERE BandName LIKE '%$BandName%'");  


    while($row = mysql_fetch_array($result)) 
    { 
        $page = sprintf( "<a href='http://www.website.com/%s'>%s</a>" , $row['PageName']  , $row['BandName']  ) ;
        echo 'Band Name:  '; 
        echo $row['BandName'] ." " . $row['Genre']; 
        echo $page;  
        echo "<br />";
    }
}

This is because you wish to create a link, however in your first example, you was trying to populate the link with data that you did not have yet, as it was before the query to the database was run.

One more thing I would tidy the code up a bit more, having each command on a new line. Well I hope that this helps :)

mikulucky 25 Junior Poster in Training

Have you specified that they are in a group, they only allow for single selection if they are part of a group.

For example

<input type="radio" name="group1" value="PersonA">
<input type="radio" name="group1" value="PersonB">
<input type="radio" name="group1" value="PersonC">
mikulucky 25 Junior Poster in Training

Hope this helps, can be turned into a function easily.

$startAmount = 0;
$endAmount = 100000;

for ($i = $startAmount; $i <= $endAmount; $i++) 
{
    if($i % 2 != 1) 
    {
      continue;
    }
 
    $d = 3; 
    $x = sqrt($i); 

    while ($i % $d != 0 && $d < $x) 
    {
        $d += 2; 
    }

    if((($i % $d == 0 && $i != $d) * 1) == 0) 
    {
        echo $i.' '; 
    }
 }
cereal commented: great solution +7
mikulucky 25 Junior Poster in Training

In php, I can do more design of my website.

I also think PHP would be the best option, It is easy to learn, and allows fast development. It does not have downtime when deploying, I have a dev server and live server, so its just a matter of svn. However the draw back of PHP is that it can get really messy really easily. If speed is your main goal, then I would go for servlets and JSP.

As for using PHP for design on your website, I might have read your post wrong. But you should really sperate the logic from the design. PHP should be at least a 3 tier system, Database -> PHP -> Template, because as I said PHP gets messy, mix php with content and HTML, well its like alphabet soup.

peter_budo commented: Little contradiction there, but finally someone posting more then "me too love PHP" +0
warlord902 commented: Nice reply +0
mikulucky 25 Junior Poster in Training

Apache is installed on all macs. Do the following:

  1. Open a terminal
  2. type "cd /etc/apache2/"
  3. type "sudo pico httpd.conf", enter your password when requested
  4. find the line #LoadModule php5_module libexec/apache2/libphp5.so and remove the '#'
  5. save the file
  6. then go to system preferences, sharing and turn on 'Web Sharing' or turn it off and on if all ready on
  7. put the .php file in your sites folder.

In the web browser go to the following:

127.0.0.1/~YOUUSERNAME/nameOfYourFile.php