Handy PHP
Earn More with LinkConnector
Forum
Welcome, Guest
Please Login or Register.    Lost Password?
Creating Your First Template Driven PHP Website Part 2
(1 viewing) 1 Guest
Go to bottom
TOPIC: Creating Your First Template Driven PHP Website Part 2
#232
vujsa
Moderator
Posts: 143
graph
User Offline Click here to see the profile of this user
Re:Creating Your First Template Driven PHP Website 4 Years, 5 Months ago Karma: 5
Well, I don't see any coding errors but your ordering is off.

You are performing a search for the value of $title but you haven't set the value for $title. Move all of the operations related to declaring a value for $title to the top. If it were me, I'd do it more like this:

CODE

<link href="css/template.css" rel="stylesheet" type="text/css" />

<?php require('include/connection.php');
require('include/functions.php');

// Get initial data and assign variables first.
$title = str_replace('-', ' ', $_GET['title']);

// Get secondary data from the database
$query="SELECT * FROM content WHERE title='$title'";
$result1=mysql_query($query);
mysql_close();

// Use all of the data obtained from various sources
$content_id=mysql_result($result1,$i,"content_id"«»);
$desc=mysql_result($result1,$i,"desc"«»);
$sef = stringForUrl($title);

// Finally, generate some output variables.
$site_title = "Made In Shropshire Demo Site";
$page_title = "$title";

$main .= "<a href=index.php?title=$sef>$title</a><hr>$desc";

// Last but not least, load the template that uses all of these
// variables.
require('include/template_includes.php');
?>


With a few exceptions, PHP reads and executes code from the top to the bottom so the order you place the various portions of your code is very important.

Also, I generally prefer to place the PHP code before everything else in a webpage wo allow the parser to get to work quicker. Of course mixed PHP/HTML or so called embedded PHP is placed where it is place!


As for the other "PHP" forums, many of those hard code PHP coders and developers have a hard time relating to new PHP users. Some times they feel that the question is beneath them so they don't bother and the ones that want to help frequently don't posses the knowledge needed to answer the question. Additionally, many people won't try to figure out what the person needs if they don't immediately understand the question. As a result, you really need to ask very detailed questions since coders tend to want to give very quick and easy answers.

I try to answer the question even if I don't fully understand with the hope that a better dialog will develop and I try to explain the answer so that the user will not just learn how to fix their problem but also learn how to adapt that skill to future projects. Kind of the give the man a fish and he eats for a day or teach the man to fish and he will eat for a lifetime kind of deal.

I hope this helps.
vujsa
 
Logged Logged
 
Do not post small or one line posts.
Do not post unsolicited links or any referal links.
Do not post copied content.
Do not use foul language.
Always be respectful to the other posters.
  The administrator has disabled public write access.
#233
amwd07
Fresh Boarder
Posts: 5
graphgraph
User Offline Click here to see the profile of this user
PHP Slideshow Gallery 4 Years, 5 Months ago Karma: 0
absolute genius really helped me with this one



another small issue this one not sure if you can help with or not?
I posted once again to forums no reply

what I am trying to acheive here is a scrolling gallery
works fine but there has to be 16 images set at 130px x 120px each

http://www.madeinshropshire.co.uk/demo/d...etails.php?mis_id=16

the problem is when the images uploaded are more than 130px width and there are more than or less than 16 images, what I am trying to ask is there a way to use the scroller so the scroller would know when it to the end of the images and instead of restarting just continue to bring in the content without jumping to the start?

here is the code in question below not sure if this is right place to ask this question future questions should I start new thread.

Also what is your hourly charge for freelance work and do you know much the spry framework from adobe? as I am using this on a few of my sites now


CODE
div#wn {
position:relative;
height:120px;
overflow:hidden;
  }

div#cnt { position:absolute; 
          width: 2080px;
  }

/* width of table = number of items * scroller width 
   Setting width on table and width and height on table cell needed
   for this example because images vary in size and don't fill scroller space
*/


<div id="cnt"> 
      <div align="left">
        <?php do { ?>
            <a href="images/makers/16/<?php echo $row_gallery['gallery_image']; ?>" rel="lightbox[roadtrip]" title="Caption Here ..."><img src="images/makers/16/tn/<?php echo $row_gallery['gallery_image']; ?>" width="130" height="120" hspace="0" vspace="1" border="0" onMouseOver="this.style.filter='progid:«»DXImageTransform.Microsoft.BasicImage(grayscale=1)'" onMouseout="this.style.filter=''"></a>
            <?php } while ($row_gallery = mysql_fetch_assoc($gallery)); ?></div>
    </div>
 
Logged Logged
  The administrator has disabled public write access.
Go to top
Wordtracker