PHP - How To Create Category Of Output Like Chapters
create_ckeditor.php
<?php session_start(); date_default_timezone_set('Asia/Manila'); if($_SESSION['login']['Ad_UserName']==""||$_SESSION['login']['Ad_ExWrite']=="0"){ @header("Location:error.php"); }elseif($_SESSION['login']['Ad_ExWrite']!="1"){ echo "<script type='text/javascript'>alert('You don\'t have rights to access this panel. Please contact the Global Administrator!')</script>"; echo '<script type="text/javascript">history.go(-1)</script>'; } ?> <?php if($_SESSION['login']['Ad_ExWrite']=="1"){include("create_ckeditor_script.php");}; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-gb" lang="en-gb" dir="ltr" id="minwidth" > <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>SRG Online Nursing Review</title> <script language="JavaScript" src="calendar_us.js"></script> <link rel="stylesheet" href="calendar.css"> <script type="text/javascript" src="js/calendar/calendar.js"></script> <link href="css/images/boss.ico" rel="shortcut icon" type="image/x-icon" /> <script type="text/javascript" src="js/tools.js"></script> <script type="text/javascript" src="js/validate.js"></script> <script type="text/javascript" src="js/deleteall.js"></script> <script type="text/javascript" src="js/clock.js"></script> <script type="text/javascript" src="js/popup/popup.js"></script> <link rel="stylesheet" type="text/css" href="css/main_import.css" /> <script type="text/javascript" src="js/menu.js"></script> </head> <body id="minwidth-body" onLoad="goforit()"> <?php include("includes/menu.html");?> <?php @include_once("class/class.php"); @$db=new DB(); @$db->connect(); $sql="SELECT * FROM tbl_coursecategory WHERE Course_IsAvailable=1 ORDER BY Course_Name ASC "; @$array=$db->get_as_array($sql); ?> <!--- menubar border STARTS ---> <div class="clr"></div> </div> <div id="content-box"> <div class="border"> <div class="padding"> <div id="toolbar-box"> <div class="t"> <div class="t"> <div class="t"></div> </div> </div> <div class="m"> <!--- ********************* title bar menu ********************* ---> <div class="toolbar" id="toolbar"> </div> <div class="header addexaminee48">Create Lecture</div> <div class="clr"></div> </div> <div class="b"> <div class="b"> <div class="b"></div> </div> </div> </div> <noscript></noscript> <div class="clr"> </div> </div> </div> </div> <div id="border"><div><div></div></div></div> <!--- Error Message---> <div class="m" style="margin-bottom:-10px;"> <?php if ($sw==1){ echo "<div class='errorMessage'><div class='error32'></div>"; echo "<div class='errorTxt'>"; echo "$msg</div></div><br />"; $sw=0; } ?> </div> <!--- End Error Message---> <!--- Menu Border Ends! ---> <!--- main Border STARTS ---> <div class="clr"></div> </div> <div id="content-box"> <div class="border"> <div class="padding"> <div id="toolbar-box"> <div class="t"> <div class="t"> <div class="t"></div> </div> </div> <div class="m" style="padding-left:20px; padding-right:20px;" > <br /><div style="font-size:12px"><b>Title of Lecture</b></div> <hr/><br /> <?php echo implode(file("http://localhost/SRG_MAIN/admin/ckeditor/_samples/srg.html")); ?> <?php include ("includes/menu_footer.html");?> </div> <div class="clr"></div> </div> <div class="b"> <div class="b"> <div class="b"></div> </div> </div> </div> <noscript></noscript> <div class="clr"> </div> </div> </div> </div> <div id="border-bottom"><div><div></div></div></div> <!--- main Border ENDS ---> <?php include("includes/footer.html");?> </body> <!--java script prompting sucessfully added!--> <?php if($_GET['popup']==1){ echo "<script type='text/javascript'>window.location='create_examinee.php';alert('Examinee Sucessfully Added!');</script>"; } ?> </html> create_ckeditor_script.php <?php @session_start(); @include_once("class/class.php"); @$db=new DB(); @$db->connect(); $sql="INSERT INTO tbl_lecture( orno, lecture ) VALUES( '$_POST[ORNo]', '$_POST[lecture]' )"; @$db->add_account($sql); @$db->close(); ?> I really need to change may table in database can someone guide mo how to enable a chapter or category each time i will save a content if i will save a content, it will only output continuously i wanted to make it per chapter or per category what do i need to do from here Similar TutorialsThis is more of an SEO question. I have a site with couple hundred categories within each city. I was wondering what the best approach is to do them? www.mysite.com/browse/apples?city=new-york www.mysite.com/browse/new-york?category=apples Which one is the better way to do it for seo purposes? If it's the first method, that would mean I would have to create couple hundred pages for those categories yes? I've a code that can create category if not existed the category & add this to the post. If category already exist then it will select the category. Here is my code snippet example : $mcptitle = 'Lenevo xiaoxin pad pro 2021'; //Geting Brand Name $brands = $mcptitle; $arr = explode(' ',trim($mcptitle)); $brand= $arr[0]; //Notice Brand name Detected //category Slug $catlink=sanitize_title($brand); //Finding category by name & geting id if($term = get_term_by( 'name', $brand, 'category' ) ){ $cat_id= $term->term_id; }else{ //creating category for not exists category $terms= wp_insert_term($brand, // the term 'category', // the taxonomy array( 'slug' => $catlink )); //geting new category id $cat_id= $terms['term_id']; //post start $post = array( 'post_author' => 1, 'post_content' => $content, 'post_status' => "publish", 'post_title' => $title, 'post_type' => "post", ); $post_id = wp_insert_post( $post, $wp_error ); //seting category wp_set_object_terms( $post_id, $cat_id, 'category' ); That works for create/add one category But I want to add multiple categories in it. Category array will be like this: $mcptitle = array("Volvo", "BMW", "Toyota"); Plz Can anyone help me about my thoughts. Thanks in advance. I do have a sql table named "module" and a parent module may have a sub module. Each parent module can have a maximum of 9 sub modules of three per <td>. This is how this "module" table looks like: +-----------+------------------+----------+------+--------+---------------------+ | module_id | name | page_url | icon | parent | created_date | +-----------+------------------+----------+------+--------+---------------------+ | 1 | User Modules | | NULL | NULL | 2021-07-21 11:46:16 | | 2 | Items | | NULL | 1 | 2021-07-21 11:46:16 | | 3 | Add New Item | | NULL | 2 | 2021-07-21 11:46:16 | | 4 | View Item | | NULL | 2 | 2021-07-21 11:46:16 | | 5 | Category | | NULL | 2 | 2021-07-21 11:46:16 | | 6 | Brand | | NULL | 2 | 2021-07-21 11:46:16 | | 7 | Unit | | NULL | 2 | 2021-07-21 11:46:16 | | 8 | Purchase | | NULL | 1 | 2021-07-21 11:46:16 | | 9 | Add New Purchase | | NULL | 8 | 2021-07-21 11:46:16 | | 10 | view Purchase | | NULL | 8 | 2021-07-21 11:46:16 | | 11 | Due Invoice | | NULL | 8 | 2021-07-21 11:46:16 | | 12 | Return | | NULL | 8 | 2021-07-21 11:46:16 | | 13 | Purchase Log | | NULL | 8 | 2021-07-21 11:46:16 | | 14 | Inventory | | NULL | 1 | 2021-07-21 11:46:16 | | 15 | Stock Transfer | | NULL | 14 | 2021-07-21 11:46:16 | | 16 | Stock Adjustment | | NULL | 14 | 2021-07-21 11:46:16 | | 17 | Batch Control | | NULL | 14 | 2021-07-21 11:46:16 | | 18 | Stock Take | | NULL | 14 | 2021-07-21 11:46:16 | +-----------+------------------+----------+------+--------+---------------------+ My desired HTML table layout looks somthing similar to this attach image.
I would like to know how we can do it in php, if is possible. Thank you. Edited July 23 by thara Hi, I need a quick tip. I want this script to produce an output of "Table created" if it succesfully creates a table. <?php $con = mysql_connect("localhost","****","****"); if (!$con) { die('Could not connect: ' . mysql_error()); } // Create table mysql_select_db("my_db", $con); $sql = "CREATE TABLE People ( FirstName varchar(15), LastName varchar(15), Age int )"; // Execute query mysql_query($sql,$con); mysql_close($con); ?> I tried to do it on my own, but I guess I'm still completely new to php I tried: <?php $con = mysql_connect("localhost","****","****"); if (!$con) { die('Could not connect: ' . mysql_error()); } // Create table if (mysql_select_db("my_db", $con)) { echo "Table created"; } else { echo "Error creating Table: " . mysql_error(); } $sql = "CREATE TABLE People ( FirstName varchar(15), LastName varchar(15), Age int )" // Execute query mysql_query($sql,$con); mysql_close($con); ?> It gave me an error with the last two lines mysql_query($sql,$con); mysql_close($con); I removed them and it really did give the output "Table created" yet it didn't create the table in the database. I'm having a feeling that I need to add an "if" statement, something of the sort. if (sql(CREATE TABLE Persons)) But I'm also getting the feeling something there is wrong, I still haven't tried it. Help? Hello, I have been searching and trying all sorts of ways to get my sub categories drop down to show the correct info after selecting a category from the main drop down but im getting stuck. It's pulling the categories and sub categories from the mysql database fine but no matter which main category i pick it keeps showing the same result in the sub category. My brother said i need to use some sort of onchange do this so the sub category list refreshs but everything i have tried doesn't work.. PLEASE could some one help. MANY MANY THANKS This is the category form Code: [Select] <select name="job_cats" style="width:165px"> <?PHP $query1 = "SELECT * FROM job_cats"; $result1 = mysql_query($query1) or die ("query 1 failed"); $count1 = mysql_num_rows($result1); for ($i = 0; $i < $count1; $i++) { $row1 = mysql_fetch_array($result1); $job_cats_title1 = $row1['title']; $job_cats_id1 = $row1['id']; echo '<option value="'.$job_cats_id1.'">'.$job_cats_title1.'</option>'; echo $job_cats_id1; } ?> </select> this would echo this in the main category list: cat1 cat2 cat3 cat4 this is the sub category form Code: [Select] <select name="job_sub_cats" style="width:165px"> <?PHP $query1 = "SELECT * FROM job_sub_cats WHERE job_cats_id = $job_cats_id1"; $result1 = mysql_query($query1) or die ("query 1 failed"); $count1 = mysql_num_rows($result1); for ($i = 0; $i < $count1; $i++) { $row1 = mysql_fetch_array($result1); $sub_cats_id1 = $row1['id']; $sub_cats_title1 = $row1['subTitle']; $cats_id1 = $row1['job_cats_id']; echo '<option value="'.$sub_cats_id1.'">'.$cats_id1.'</option>'; } ?> </select> this should echo this: 1 2 3 4 but it keeps echoing just the number 4. THANKS PLEASE HELP ricky In this output table, I would like to be able to click on any number in the ama row, add .html to that value and then execute the link. Example: If the ama number in row 3 is 890543, add .html to the number = 890543.html, then click on it to link to that web page. <?php // Connect to database ========================================= include("connect_db.php"); $table1='passwords'; $table2='airplanes'; // send query =================================================== $result = mysql_query("SELECT * FROM $table2") or die(mysql_error()); if (!$result) { die("Query to show fields from table failed"); } echo "<table border='10' cellpadding='3' cellspacing='2'>"; echo "<p>View All Airplanes</p>"; echo "<tr> <th>ID</th> <th>AMA #</th> <th>Model Name</th> <th>Model MFG</th><th>Wingspan</th><th>Engine</th><th>Decibels</th></tr>"; // keeps getting the next row until there are no more to get ================ while($row = mysql_fetch_array( $result )) { // Print out the contents of each row into a table ========================== echo "<tr><td>"; echo $row['id']; echo "</td><td>"; echo $row['ama']; // Append .html to this number echo "</td><td>"; echo $row['model_name']; echo "</td><td>"; echo $row['model_mfg']; echo "</td><td>"; echo $row['wingspan']; echo "</td><td>"; echo $row['engine']; echo "</td><td>"; echo $row['decibels']; echo "</td></tr>"; } echo "</table>"; ?> I am wanting to create a basic product listing page for a product category called "Belts". My latest attempt was this, but I got an error: PHP Code: Code: [Select] $query = "select * from products"; $result = mysql_query($query); while($row=mysql_fetch_assoc($result)) { print ".$row['name'] where category = 'Belts'.$row['colour'] where category = 'Belts'"; } Quote PHP Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING This is what my MySQL table looks like: http://i54.tinypic.com/2j1si8w.png I image what I am trying to do will print "Somename Black, ProductName2 Brown"? I'm not really interested in styling at the moment, I just want to see the PHP-MySQL work at the most basic level. I am unsure what the error cosde means. Can anyone see a fault in my code? Well I have a script that executes a scan on a system set to run infinitely, and I need it to echo out a message each time it loops through, but I don't want it to echo out the message with the next loop message below it, and the next one below that etc... I've tried using the flush(); function and been messing around with that with no luck. For security reasons I don't want to release any of the processing code, but here is the basic construction of the script: <?PHP ***PROCESSING AND SCAN CODE*** ***PROCESSING AND SCAN CODE*** ***PROCESSING AND SCAN CODE*** ***PROCESSING AND SCAN CODE*** $RepeatIt = -1; for($g=1; $g!=$RepeatIt+1; $g++) { ***PROCESSING AND SCAN CODE*** ***PROCESSING AND SCAN CODE*** ***PROCESSING AND SCAN CODE*** ***PROCESSING AND SCAN CODE*** $ScanMessage = ":.:.: SCANNING THE HITLIST FOR MOBSTER: ".$MobName." (SCAN #$g) :.:.:"."<br/><br/>"; echo $ScanMessage; ***PROCESSING AND SCAN CODE*** ***PROCESSING AND SCAN CODE*** ***PROCESSING AND SCAN CODE*** ***PROCESSING AND SCAN CODE*** } ?> At the moment it's returning: :.:.: SCANNING THE HITLIST FOR MOBSTER: DEUS EX DESTROYER (SCAN #1) :.:.: :.:.: SCANNING THE HITLIST FOR MOBSTER: DEUS EX DESTROYER (SCAN #2) :.:.: :.:.: SCANNING THE HITLIST FOR MOBSTER: DEUS EX DESTROYER (SCAN #3) :.:.: :.:.: SCANNING THE HITLIST FOR MOBSTER: DEUS EX DESTROYER (SCAN #4) :.:.: So what I want it to do is just delete the scanning message and replace it with the next scan message so while running this script you would see just the number increment on the same line. Any suggestions? Thanks. I have the following result that I am getting from a source. Code: [Select] SimpleXMLElement Object ( [CategoryID] => 1 [Name] => Other [Order] => 0 [link] => http://www.link.com?sub=1 ) SimpleXMLElement Object ( [CategoryID] => 1233916011 [Name] => ceramic [Order] => 1 [ChildCategory] => SimpleXMLElement Object ( [CategoryID] => 1234016011 [Name] => dish [Order] => 1 ) [link] => http://www.link.com?sub=13476 ) SimpleXMLElement Object ( [CategoryID] => 1233917011 [Name] => laminate [Order] => 2 [link] => http://www.link.com?sub=98247 ) I need to get it into a database with the following structure Code: [Select] id categoryID cName cOrder clink cparent By using Code: [Select] foreach($this->resp->Store->CustomCategories->CustomCategory as $cat) { $sub = $cat->CategoryID; $ord = $cat->Order; $linkto = "$stlink?fsub=$fsub"; $nm = htmlspecialchars($cat->Name); $par=$cat->ChildCategory->Order; $query = "INSERT INTO Cat (categoryID,cName,cOrder,clink,cparent) VALUES ('$sub','$nm','$ord','$linkto','$par')"; $result = @mysql_query ($query); // Run the query. } I can get Code: [Select] id categoryID cName cOrder clink cparent 1 1 Other 0 http://www.link.com?sub=1 0 2 1233916011 ceramic 1 http://www.link.com?sub=13476 0 2 1233917011 laminate 2 http://www.link.com?sub=98247 0 But I need to get the ChildCategory in there w/ cparent like Code: [Select] id categoryID cName cOrder clink cparent 1 1 Other 0 http://www.link.com?sub=1 0 2 1233916011 ceramic 1 http://www.link.com?sub=13476 0 3 1234016011 dish 1 1 <--- like this 4 1233917011 laminate 2 http://www.link.com?sub=98247 0 any help appreciated... An array of "categories" is given: $categories = array( array("id" => 1, "title" => "Pants", "children" => array( array("id" => 2, "title" => "Boots", "children" => array( array("id" => 3, "title" => "Leather"), array("id" => 4, "title" => "Textile"), ), ), array("id" => 5, "title" => "Sneakers"), ), ), array( "id" => 6, "title" => "Sort", "children" => array( array( "id" => 7, "title" => "Balls", ), ), ), );
I need to write a function searchCategory ($categories, $id) that returns the name of the category by the category ID. Hope I am in the right area. I am working on a project which is sort of a business directory. I have a category table, a sub-category table then the actual account table. So a user clicks on the category, then selects the sub-category to view information of accounts in that category, and then be able to click to see the full profile. Here's where I am getting stuck. A user may be listed in more than one sub. As an example, let's say a parent is Cars, then subs might be New, Used, Parts, etc. Now a particular user might be listed under all three subs. How can I link them? I have my cat/sub linked via parent/child id's. However, how can I get the user to be linked to multiple subs? Would I need to create a separate table to do similar to parent/child of the categories? If so, then how would I insert the multiple id's into the table? I assume at this point that I would use drop downs for the subs. I am having a real hard time wrapping my head around this so any help is greatly appreciated. So I am having some difficulties with a category system. I want my code to search the database an unlimited amount of times to the very last directory and then display it in tree view on my screen. I'm having some trouble because I am having to specify how many depths the code will search. How can I get it to do this on it's own? Currently my code does this... <?php // Establish SQL Connection. $mysqli = mysqli_connect( $sql['host'], $sql['user'], $sql['pass'], $sql['db'] ) or die( "DARN"); $query = $mysqli->query( "SELECT * FROM folders ORDER BY name ASC" ); $num_rows = $query->num_rows; echo "Found <b>" . $num_rows . "</b> row(s) in the database!<br>"; while ( $row = mysqli_fetch_array( $query ) ) { // DO NOT REMOVE $id = $row['id']; $name = $row['name']; $parent = $row['parent']; /***************************************************************************************************/ if ( $parent == 0 ) { echo $id . " " . $name . " " . $parent . "<br>"; $query2 = $mysqli->query( "SELECT * FROM folders WHERE parent = " . $id . " ORDER BY name ASC" ); while ( $row2 = mysqli_fetch_array( $query2 ) ) { echo " " . $row2['name'] . "<br>"; } } } ?>I know it's messy, doing the best I can. DB looks a little like this... +----+---------+--------+ Hey i want to make category pages with php. so i have embeded youtube videos on my website and i want to make a category so that every embeded link that is named under that category goes on the new web page i am making. so lets say i have a category in my table that is called "Call of duty black ops" would the code be something like this ? ( and yes i want it to be ordered by date aswell ) Code: [Select] $query = "SELECT * FROM `G4V_Videos`.`Category`.`Call of duty black ops` ORDER BY `Date added` DESC LIMIT 24"; $result = mysql_query($query); thanks guys! I need some help with the category part on a old project . The problem what I have at this moment that, when I click on the category all categories are showing up on the category.php page itself. What whI wanne have when I click Uncategorised that in the category.php page only post are showing that have been made in Uncategorised category function get_posts() { $sql = "SELECT `blog`.`post_id` AS `id`, `blog`.`post_title` AS `title`, LEFT(`blog`.`post_body`, 512) AS `preview`, `blog`.`post_user` AS `user`, `blog_categories`.`id` AS `category_id`, `blog_categories`.`name` AS `category_name`, DATE_FORMAT(`blog`.`post_date`, '%d-%m-%Y %H:%i') AS `date`, `blog_comments`.`total_comments`, DATE_FORMAT(`blog_comments`.`last_comment`, '%d-%m-%Y %H:%i') AS `last_comment` FROM `blog` INNER JOIN `blog_categories` ON `blog_categories`.`id` = `blog`.`cat_id` LEFT JOIN ( SELECT `post_id`, COUNT(`comment_id`) AS `total_comments`, MAX(`comment_date`) AS `last_comment` FROM `blog_comments` GROUP BY `post_id` ) AS `blog_comments` ON `blog`.`post_id` = `blog_comments`.`post_id` ORDER BY `blog`.`post_date` DESC"; $posts = mysql_query($sql); $rows = array(); while (($row = mysql_fetch_assoc($posts)) !== false) { $rows[]= array( 'id' => $row['id'], 'title' => $row['title'], 'preview' => $row['preview'], 'user' => $row['user'], 'date' => $row['date'], 'category_id' => $row['category_id'], 'category_name' => $row['category_name'], 'total_comments' => ($row['total_comments'] === null) ? 0 : $row['total_comments'], 'last_comments' => ($row['last_comment'] === null) ? 'never' : $row['last_comment'] ); } return $rows; } function get_post($pid) { $pid = (int)$pid; $sql = "SELECT `post_title` AS `title`, `post_body` AS `body`, `post_user` AS `user`, `blog_categories`.`id` AS `category_id`, `blog_categories`.`name` AS `category_name`, DATE_FORMAT(`post_date`, '%d-%m-%Y %H:%i') AS `date` FROM `blog` INNER JOIN `blog_categories` ON `blog_categories`.`id` = `blog`.`cat_id` WHERE `post_id` = '$pid'"; $post = mysql_query($sql); $post = mysql_fetch_assoc($post); $post['blog_comments'] = get_comments($pid); return $post; }
The old way was like this if ( isset($cat_id)) { $cat_id = (int) $cat_id; $query .= " WHERE `blog_categories`.`id` = $cat_id"; } Database blog_categories id | name | ----------- 4 Uncategorised 1 Youtube blog post_id | cat_id | post_title | post_body | post_user | post_date ----------------------------------------------------------------------------------- 4 | 1 | Youtube | Youtube link | Admin | 2020-09-13 16:10:53 Web server Apache/2.2.21 (Win64) PHP/5.3.10 MySQL-client versie: mysqlnd 5.0.8-dev - 20102224 - $Revision: 321634 $ PHP uitbreiding: mysqli Documentatie phpMyAdmin Versie informatie: 3.4.10.1, meest recente versie: 5.0.2 I hope someone can help me with this problem Hi all. This seems like a pretty basic function but I can't work it out. I'm developing a WordPress site and want to list posts (products) by category. I'm using Advanced Custom Fields and have set up the taxonomy of 'category'. I just want to produce a heading for that category and then list all of the posts with that category assigned. Please see below functions.php excerpt and section-archive.php excerpt. Can anyone please help??? Massive good karma if you can. ----------------------- functions.php -------------------------------------- //Assign Category to Products
function taxonomy ()
$args = array (
}; ?> ------------------------- section-archive.php ------------------------------------------------ <?php if(have_posts()):while(have_posts()): the_post();?>
****** if product category= this ***** Category heading ****** Posts ******* Else ****** if product category= this2 ***** Category heading ****** Posts **** etc
<div class="prod-listing">
I'm not sure why but I copied the correct syntax from the wp codex page for it to display the date and title which it displays the titles for the categories however it only displays the date for the headlines category and don't know why. Any answers? <?php get_header(); ?> <div id="left"> <div id="col1"> <img id="lp" src="../images/lp.jpg" alt="Latest Promo"> <img class="newslogos" src="../images/headlines.jpg" alt="DW Headlines"> <div class="mininews"> <?php //The Query query_posts('category_name=headlines'); //The Loop while (have_posts()) : the_post(); ?> <h3 class="date"><?php the_date(); ?></h3> <h4 class="title"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h4> <?php endwhile; //Reset Query wp_reset_query(); ?> </div> <!-- End of main news div (headlines) --> <img class="newslogos" src="../images/rumors.jpg" alt="DW Rumors"> <div class="mininews"> <?php //The Query query_posts('category_name=rumors'); //The Loop while (have_posts()) : the_post(); ?> <h3 class="date"><?php the_date(); ?></h3> <h4 class="title"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h4> <?php endwhile; //Reset Query wp_reset_query(); ?> </div> <!-- End of main news div (rumors) --> <img class="newslogos" src="../images/columns.jpg" alt="DW Columns"> <div class="mininews"> <?php //The Query query_posts('category_name=columns'); //The Loop while (have_posts()) : the_post(); ?> <h3 class="date"><?php the_date(); ?></h3> <h4 class="title"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h4> <?php endwhile; //Reset Query wp_reset_query(); ?> </div> <!-- End of main news div (columns) --> </div> <!-- End of col1 --> </div> <!-- End of left --> <div id="right"> </div> <?php get_footer(); ?> I have created a form which allows people to add data to a database. However, I want to replicate the form across several pages and give each page a category. For example, if I have a website based on sport. I have a page which enters information into the baseball category, a page which enters information into the ice hockey category, a page which enters information into the soccer category etc. Can someone advise how I would do this? Hi, I have been working on a directory/cms script (first large script to build from scratch). I am stuck on a small part of it where is shows users a list of the listings they have put in the directory. Below is the code that generates the table that shows the list of listings which is pulled from the 'listings' table in my database. Code: [Select] <?php ### List of listings user has posted ### if(isset($_SESSION['userlogged'])) { $user_id = $_SESSION['userlogged']; $sqlCommand = "SELECT listing_id, cat_id, listing_title, listing_date, showing FROM listings WHERE showing='0' AND user_id='$user_id' ORDER BY listing_id ASC"; $query = mysql_query($sqlCommand,$con) or die (mysql_error()); $ListingDisplay = ''; while ($row = mysql_fetch_array($query)) { $listing_id = $row["listing_id"]; $cat_id = $row['cat_id']; if ($cat_id == '1') { $cat_name = "Carpenters"; } if ($cat_id == '2') { $cat_name = "Stone Masons"; } if ($cat_id == '3') { $cat_name = "Plumbers"; } if ($cat_id == '4') { $cat_name = "Landscapers"; } $listing_title = $row["listing_title"]; $listing_date = $row["listing_date"]; $ListingDisplay .= ' <tr class="listingaccount"> <td><a href="edit_listing.php?lid=' . $listing_id . '">' . $listing_id . '</a></td> <td>' . $cat_name . '</td> <td>' . $listing_title . '</td> <td>' . $listing_date . '</td> <td><a class="hoverBtn" href="edit_listing.php?lid=' . $listing_id . '"><img src="images/btnedit.png" border="0"></a></td> <td><a class="hoverBtn" href="remove_listing.php?lid=' . $listing_id . '"><img src="images/btndelete.png" border="0"></a></td> </tr>'; } mysql_free_result($query); ?> <table width="680" border="0" align="right" cellpadding="0" cellspacing="0"> <tr> <td colspan="2"><h2>My Listings</h2></td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td><a href="account_add_listing.php">Add New Listing</a></td> <td> </td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td colspan="2" valign="top"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td>Listing Code</td> <td>Category</td> <td>Title</td> <td>Date Entered</td> <td> </td> </tr> <?php echo $ListingDisplay; ?> </table> </td> </tr> </table> <?php } ?> That all works just fine, but I would like to be able to generate the categories automatically. I am thinking some sort of array, but im not quite sure how to go about it and was hoping maybe someone could give me a starting point I could work from. My categories table is like this: -------------------------- | cat_id | cat_name | -------------------------- Many thanks Eoin Hi friends, I have two mysql db tables, photos and album, I would like to list photos by album how do i do that ? CREATE TABLE `album` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `album_name` varchar(95) NOT NULL, `album_desc` text NOT NULL, PRIMARY KEY (`id`) ); CREATE TABLE `photos` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `album_id` int(11) NOT NULL, `thumb_name` varchar(255) NOT NULL, `photo_name` varchar(250) NOT NULL, PRIMARY KEY (`id`) ) Hi Guys (& Ladies of course) I'm having a problem trying to add post category to the H1 title, I have managed to butcher my theme so that the single post now removes the H1 from the title in the header & instead adds it to the post title. But what I'd like to do now is keep the H1 blog title on all pages including home page, but I'd like to ammend the title with the addition of the post category, as follows; currently shows "Top Rated Gadgets" on all pages. would like it to show "Top Rated (category name)" when viewing a single post. So if the category of the post was Asus Laptops it would show "Top Rated Asus Laptops" instead of the usual "Top Rated Gadgets" The closest I have got to it so far is with Code: [Select] <?php the_category(', '); ?> but this returns a hyperlink ! Is there any method I can use that will simply return the category name as plain text..? Any help would be much appreciated Thanks |