Jump to content

rahish

Members
  • Posts

    31
  • Joined

  • Last visited

    Never

Contact Methods

  • Website URL
    http://www.undesign.co.uk

Profile Information

  • Gender
    Not Telling

rahish's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks I had pages_id but the table field was page_id Bit of a schoolboy error there. Thanks for sorting it out. The mysql_error function is really useful, will try that in the future.
  2. Thanks I tried both but I am still getting a can't execute query error. This is what I am now using <?php include('../dbconnection.php'); $submit=$_GET['submit']; $id=$_GET['id']; $menu=$_GET['menu']; if ( $menu=='1' ) { $query=mysql_query("DELETE FROM menu WHERE id = '$id'") or die ("Couldn't execute query."); $query2=mysql_query("DELETE FROM pages WHERE pages_id = '$id'") or die ("Couldn't execute query."); echo "You have now deleted entry $id from the database and entry $id from the menu<br />"; echo " <a href='posts.php?id=$id'>Click here to go back</a>"; } else { $query=mysql_query("DELETE FROM pages WHERE page_id=$id") or die ("Couldn't execute query."); echo "You have now deleted entry $id from the database<br />"; echo " <a href='posts.php?id=$id'>Click here to go back</a>"; } ?>
  3. I am creating a very simple cms system and have a delete statement which is supposed to delete an item from a menu table and a page table which (has an identical id) when an admin user deletes the page There is an if statement that sends and integer "1" if the admin user has clicked the html checkbox on a form to ask for the page to be deleted from the menu as well as the page itself. I can't work out the syntax of the mysql statement to do this I am not sure if this is the right forum for this question. But here is the code I am using <?php include('../dbconnection.php'); $submit=$_GET['submit']; $id=$_GET['id']; $menu=$_GET['menu']; if ( $menu=='1' ) { $query=mysql_query("DELETE FROM menu, pages WHERE menu.id AND pages.page_id=$id") or die ("Couldn't execute query."); //$query = mysql_query("DELETE FROM menu WHERE id=$id") or die (mysql_error()); echo "You have now deleted entry $id from the database and entry $id from the menu<br />"; echo " <a href='posts.php?id=$id'>Click here to go back</a>"; } else { $query=mysql_query("DELETE FROM pages WHERE page_id=$id") or die ("Couldn't execute query."); echo "You have now deleted entry $id from the database<br />"; echo " <a href='posts.php?id=$id'>Click here to go back</a>"; } ?>
  4. I knew it would be an easy one, I need more practice. Thanks very much for that.
  5. This should be easy for someone. I am trying to populate a simple html list menu with urls and link text using an array and a for loop. I cannot work out what I am doing wrong but I know I am only guessing, I have got my for loops mixed up and it is duplicating the output. Here is the example <?php $menu_link = array (0 =>'index.php', 'info.php', 'contact.php'); $menu_text = array (0 =>'Home', 'Information', 'Contact'); ?> <h3> Menu Example</h3> <?php print_r($menu_link); print_r($menu_text); ?> <?php echo "<ul>"; for ($text=0; $text < sizeof($menu_text); $text++) { for ($i=0; $i < sizeof($menu_link); $i++) { echo "<li><a href='", $menu_link[$i], "'>$menu_text[$text] "; //$i, //echo " ",$menu_text[$text], "</li>"; } } echo "</a></li>"; echo "</ul>"; ?>
  6. Thanks for that, That removed the header error. It still didn't work but I noticed the reason why. Although as was suggested earlier in this post that <?php if ($_GET[style] == "") { $style="default"; } if ($_GET == "") { $page="home"; } ?> was needed It also needs <?php $style = $_GET['style']; $page= $_GET['page']; ?> Now it works, thanks a lot.
  7. Sorry, yes here it is <?php ob_start(); if ($styleCookie == "") { $style="default"; } else { $style=$styleCookie; } Header ("Location: template.php?page=home&style=$style"); ?>
  8. Thanks Because the tutorial says so, I am starting to think this tutorial was a bad idea. The code in index.php just redirects to template php with headers but also sets the css to default if no other variables are passed via the browser. Why does it come up with header errors when you go directly to template.php there is no header info in this page in the first place?
  9. Thanks Now I am getting Warning: Cannot modify header information - headers already sent by (output started at ******template.php:2) in ******template.php on line 3 There is a header redirect in an index.php file, I am wondering if this code should be in template.php <?php if ($styleCookie == "") { $style="default"; } else { $style=$styleCookie; } Header ("Location: template.php?page=home&style=$style"); ?>
  10. Thanks, I have done that but it didn't change anything. Is it that if ($style == "") { $style="default"; } if ($page == "") { $page="home"; } is overriding the $_GET part?
  11. Thanks, I am not getting an error at all, its just that when you try clicking on info in the list menu, it should send the variables to be picked up by template.php to load a different html file and change the style sheet. As I say this seems to work fine on localhost under xampp but on my web server on the link below it doesn't work. The variable in on the info link should send ?page=info&style=blue to template.php I echoed variables $style and $page to template.php and it still shows default and home. The page has a cookie applied also, could it be that it is not updating the information If you click on the link http://www.undesign.co.uk/computer_club/dynamic_web/PHP/alistapart_tutorials/managing_content_php/template.php?page=home&style=default You will see what I mean
  12. Hi I am trying to build a php template from the following tutorial http://www.alistapart.com/articles/phpcms All I want to do is send a variable to another page, something I have done countless times before. It works fine on my local server but I cannot get it to work on my web account. It may have something to do with the way & needs to be encoded but I have corrected that and the page validates as XHTML strict but the file still won't work. Can anyone work out what I am doing wrong? template.php has menu.php as a require and the content loads dynamically when you select a menu item from menu.php the variables are in the url on the menu link. here is template.php <?php setcookie ("styleCookie", $style, time()+40000000); ?> <?php if ($style == "") { $style="default"; } if ($page == "") { $page="home"; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Language" content="en-us" /> <title>New CMS Template - Alistapart Tutorial - Managing your content with PHP</title> <?php echo "<style type=\"text/css\" media=\"all\">@import \"$style.css\";> </style>"; ?> <?php echo "<link rel=\"alternate style sheet\" type=\"text/css\" href=\"default.css\" title=\"Default\" />"; ?> </head> <body> <?php $_GET['$style']; $_GET['$page'];?> <?php echo "$style";?> <?php echo "$page";?> <div class="body"> <?php //@require_once ("header.php");?> <div class="menu"> <?php @ require_once ("menu.php"); ?> </div> <?php @ require_once ("$page.html"); ?> </div> </body> </html> and here is menu.php <?php $home="Home"; $info="Information"; $contact="Contact Details"; $links="Links"; $default="default"; $blue ="blue"; ?> <ul> <li><?php echo "<a href=\"template.php?page=home&style=$default\">$home</a>"; ?></li> <li><?php echo "<a href=\"template.php?page=info&style=$blue\">$info</a>"; ?></li> <li><?php echo "$contact";?></li> <li><?php echo "$links";?></li> </ul> the css files just have a background colour defined and the home and info pages are home.html and info.html The link to the template.php which has the error is herehttp://www.undesign.co.uk/computer_club/dynamic_web/PHP/alistapart_tutorials/managing_content_php/template.php?page=home&style=default
  13. Thanks a lot, Got it working now I realised that the remainder would always work out and output a number as a remainder that corresponded to the id of each image, it was the fact that i had an array set up to cycle the images and I was trying to get the $id into $pictures some how. So I scrapped the array altogether and removed the for loop and used a standard fetch array and put the output of $number in the sql statement. <?php $wk_no = date("W"); //gives the current week $count_sql = 'SELECT * FROM main_week_pic';// query database $count_result = mysql_query($count_sql); // Get number of articles, assign value to variable $count = mysql_num_rows($count_result); echo "The database has this many rows: $count <br />"; echo "We are currently in week $wk_no<br />"; $number= $week_no%$count+3; echo "$number"; $query = ("SELECT * FROM main_week_pic where id = '$number'");// query database echo"<p class='imgcenter'><h3>Undesign of the Week</h3>"; $result = mysql_query($query) or die ("Couldn't execute query."); // Populate cells using a mysql_fetch_array script while ($row=mysql_fetch_array($result)) { $id=$row["id"]; $path=$row["path"]; $more=$row["more"]; echo '<img src = "'; echo $path; echo '"width="180">'; } ?>
×
×
  • 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.