Jump to content

son.of.the.morning

Members
  • Posts

    292
  • Joined

  • Last visited

    Never

Posts posted by son.of.the.morning

  1. invoking the class

    $values = array("$title","$img","$post","$aurthor_id","$category_id","$date_posted");
    $fields = array('title,','img,','post,','aurthor_id,','category_id,','date_posted'); 
    $obj= new DatabaseInsert;
    $obj->DatabaseConnectionRequire();
    $obj->ArticleInsert($values,$fields,$table); 
    

     

    The Insert Class

    class DatabaseInsert {
    
    	function DatabaseConnectionRequire() {
    		include("../scrips/php/database.connection.class.php");
    		include("../scrips/php/database.settings.php");	
    		include("../scrips/php/database.connection.class.invoke.php");	
    
    	}
    
    	function ArticleInsert($values,$fields,$table) {
    
    		$values_imploded = implode("   ",$values);
    		$fields_imploded = implode("   ",$fields);
    		$i = "INSERT INTO $table ($fields_imploded) VALUES ($values_imploded)";
    		//mysql_query($i) or die (mysql_error());
    		//Uncomment ^ this to check the query for errors.
    
    		if (!(mysql_query($i))) {
    
    	    	echo "Sorry, something whent wrong there...";
    		}
    
    		else {
    			echo "<strong><p style='color:green;'>Content added sucessfully!!!</p></strong>";
    		}
    
    	}
    }
    
    

     

    The View point

    if(isset($_GET['id'])) {
    // Get the id and select it's corresponding record 
    $id = $_GET['id']; 
    $query = "SELECT * FROM blog_posts  INNER JOIN post_categories ON blog_posts.category_id=post_categories.id WHERE blog_posts.id = $id";
    $get_results = mysql_query($query) or die (mysql_error());
    $results = mysql_fetch_array($get_results);
    }
    
    <?php echo $results['post']; ?> // the main body of the article
    

     

  2. I would like to apply some addition functionality to a form which add news records into the database. Basicaly what i want is similar to what this forum does with the [ code ] [ /code ] but what i want for the user to be able to add [ quote ] [ /quote ] and when the post is viewed then that specific area of the acticle body will be formated diffrently. I hope this makes sence.

  3. Alright guys i have an idea on what am going to do here, although i am unsure that it's the best way to go about it.

     

    I am creating a blog and i need to count how many views an article gets in order to display the top 10 most viewed articles. Here is my plan...

     

    1. Add an additional field to my blog posts table called viewed

    2. On the view article page have an update method that adds one to the current number on the the coloum viewed

    3. When displaying the 10 most viewed articles query it by the heightest number and limet to 5

  4. this is helpful fo course but it's not what am trying to do. I dont want to show the relation between two tables even though they are. All i want to do if to be able to count how many records have the same content.

     

    for example if you have category_id which can have more then one record with the same id in. I want to be able to say how many records in the table have the same category id. Hope this makes sence

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