hai to all,

i am new to php , can u tel how to calculate a no of posts for a particular title . i have a table post project in database it has a 8 fields id , name ,title ,category,date ,description,cat id(category id),no of posts. and how to display the no of post in index page with particular category and title thank you,

$Qselect= mysql_query("select  * from tablename where tittle='$title(your titlename)' or title like '$title(your titlename)' ");
 $fetch=mysql_fetch_array($Qselect);
 echo $fetch['no of posts'];

try like this.

thanks for ur reply but it not working ..i have attached my code. plz verify it..

<?php 
mysql_connect("localhost","root","") or mysql_error();
mysql_select_db("free lancer") or mysql_error();

//display the category
$query=mysql_query("select DISTINCT `category`,`cid`,'title' from `projectdetails`");
while($fetch=mysql_fetch_array($query))
{
echo "<a href='index1.php?cat=$fetch[cid]'><font color='#003366'>$fetch[category]</font></a>";
echo "<br>";
}
?>
<?php
//$cat2=$_REQUEST['cat'];
$tit=$_REQUEST['title1'];
//$query3=mysql_query("SELECT * FROM `projectdetails` WHERE `cid`='$cat2' and `title`='$tit'");
//$count=mysql_num_rows($query3);
//echo $count;*/
   
 $Qselect= mysql_query("select * from projectdetails where title='$tit'");
  
      $fetch=mysql_fetch_array($Qselect);
  
      echo $fetch['bid']; 
	
?>
<form id="form1" name="form1" method="post" action="">
<table width="752" height="115" border="0">
    <tr>
      <td><span class="style8">USERNAME</span></td>
      <td><span class="style8">TITLE</span></td>
      <td><span class="style8">DESCRIPTION</font></td>
	  <td><span class="style8">DATE</font></td>
	  <td><span class="style8">NO OF BIDS</font></td>
    </tr>
  <?php 
  //$cat1=$_REQUEST['cat'];
 
  
  if(isset($_REQUEST['cat']))
  {
  $cat1=$_REQUEST['cat'];
  
  $query2=mysql_query("SELECT * FROM `projectdetails` where `cid`='$cat1' ");
   
  $s=1;
  // first <td> -display the user name:
  //second <td>-display the title from table 
  //third <td>-display the description
  //fourth <td>-date
  //fifth <td>no of posts(not working)
  //it will display the no post for a particular category for particular title 
   while($result2=mysql_fetch_array($query2))
	{
	 echo "<tr>
  
        <td name='name' id='name<?php echo $s;?>'><a href='view.php?name2=$result2[1]'><font color='#003366'> $result2[1]</font></a>
   </td> 
     
      <td name='title' id='title<?php echo $s;?>'><a href='index1.php?title1=$result2[4]'><font color='#003366'>$result2[4]</font></a></td>
   
      <td name='description' id='description<?php echo $s;?>'><label>$result2[5]
      </label></td>
	  
	  <td name='date' id='date<?php echo $s;?>'><label>$result2[6]/$result2[7]/$result2[8]
      </label></td>
	  
	  
	  
	  
	  <td name='bid' id='bid<?php echo $s;?>'><label>  $fetch[bid]
      </label></td>
	  
	  
	 </tr>";
	}
	$s++;
	}
		?>
	</table>
	<?php

if(isset($_REQUEST['title1']))
{
$title=$_REQUEST['title1'];
$query=mysql_query("select * from `projectdetails` where `title`='$title'");

$s=0;
while($result=mysql_fetch_array($query))
{

       echo "<table width='327' height='172' border='0'>
  <tr>
    <td width='189' ><span class='style1'>Project Title </span></td>
	<td width='129'>:</td>
    <td width='189' name='title' id='title'>$result[4]</td>
  </tr>
  <tr>
    <td><span class='style1'>Project Description</span> </td>
	<td >:</td>
    <td name='description'  id='description'>$result[5]</td>
  </tr>
</table>";
	   $s++;
	   }
	   
	   
}



?>
	
</form>

thank u,

what is the error you are getting from the above code.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.