Jump to content

Recommended Posts

I have to create a page for which you can select 3 different layouts. I used includes to do this, eg 1head.php 2head.php etc. I used $_GET to retrieve the variables. Not to suprise it doesnt work. Please help me! error is on line 23 (include('includes/{$num}head.php');)

 

My code:

 

<!DOCTYPE html PUBLIC "-W3C//DTD XHTML 1.0 Strict//EN"http://www.w3.org/TR/xhtml1-strict.dtd">

<html>

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

<title> | Prac 7</title>

</head>

<body>

<center>

<div class="header">Prac 7</div>

<?php


$num=1

include('includes/{$num}head.php');
include('includes/{$num}left.php');




print '<td>


Select a layout:</br>


$num=$GET['num'];


<a href="index.php">Layout1</a></br>

<a href="index.php?num=2">Layout2</a></br>

<a href="index.php?num=3">Layout3</a>




</td>';




include('includes/{$num}right.php');
include('includes/{$num}foot.php');








?>

</div>

</center>

</body>

</html>

 

EDITED BY WILDTEEN88: Please use code tags (


) when posting code

Link to comment
https://forums.phpfreaks.com/topic/152656-solved-whats-wrong-here/
Share on other sites

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<link rel="stylesheet" href="styles.css" type="text/css"/>
<title> | Prac 7</title>
</head>
<body>

<div class="header">Prac 7</div>

<?php
$num = (isset($_GET['num']) && is_numeric($_GET['num'])) ? $_GET['num'] : 1;
include("includes/{$num}head.php");
include("includes/{$num}left.php");
?>


<p>
  Select a layout:</br>
  <a href="index.php">Layout1</a></br>
  <a href="index.php?num=2">Layout2</a></br>
  <a href="index.php?num=3">Layout3</a>
</p>

<?php
include('includes/{$num}right.php');
include('includes/{$num}foot.php');
?>

</body>
</html>

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<link rel="stylesheet" href="styles.css" type="text/css"/>
<title> | Prac 7</title>
</head>
<body>

<div class="header">Prac 7</div>

<?php
$num = (isset($_GET['num']) && is_numeric($_GET['num'])) ? $_GET['num'] : 1;
include("includes/{$num}head.php");
include("includes/{$num}left.php");
?>


<p>
  Select a layout:</br>
  <a href="index.php">Layout1</a></br>
  <a href="index.php?num=2">Layout2</a></br>
  <a href="index.php?num=3">Layout3</a>
</p>

<?php
include('includes/{$num}right.php');
include('includes/{$num}foot.php');
?>

</body>
</html>

 

Thx mate! :)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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