Jump to content

Recommended Posts

Hi, I am in urgent need of some urgent help

 

I need to connect to my database and count the amount of posts by user id 1155 then display the number of posts

 

SELECT * FROM `vbpost` WHERE `userid` =1155 ;

 

I am really sorry to ask such an easy one but I am not confident with php and I need this quite quickly

 

also if anyone knows vbulletin 4, maybe you could include a query to put that number into a users post count ( saltedm8 )

 

table name webproca_vb

 

thank you

Link to comment
https://forums.phpfreaks.com/topic/239668-connect-to-database-and-count-tables/
Share on other sites

thanks tried

 

<?php
$con = mysql_connect("localhost","xxxxxxxx","xxxxxxxx");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

$go = 'SELECT count( webproca_vb ) as total FROM `vbpost` WHERE `userid` =1155' ;

$result = mysql_query($go);

echo $result ;

mysql_close($con);
?>

 

just getting a blank page, how can I see the result in number form ? thanks

You need to convert the result to a php array,

 

<?php
$con = mysql_connect("localhost","xxxxxxxx","xxxxxxxx");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

$go = 'SELECT count( webproca_vb ) as total FROM `vbpost` WHERE `userid` =1155' ;

$result = mysql_query($go);
// Note this line:
$row = mysql_fetch_assoc($result);

echo $row['total'];

mysql_close($con);
?>

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.