Jump to content

Recommended Posts

hey,

 

another daft question, I'm using this:

 

<?php
$dir_path = "/var/www/vhosts/website.co.uk/subdomains/demo/httpdocs/clients/$login"; 
$images = count(glob($dir_path . "*"));
?>

 

now,

<?php
include "scripts/connection.php"; 
if (!$con) 
{ 
  die( 'Could not connect: ' . mysql_error() ); 
   }
mysql_select_db($db, $con); 

$result = mysql_query("SELECT * FROM album WHERE active = 'yes'");
?>

 

how can i get it to count the files in each folder, ie

<?php 
$dir_path = "/var/www/vhosts/website.co.uk/subdomains/demo/httpdocs/clients/client1";
$dir_path = "/var/www/vhosts/website.co.uk/subdomains/demo/httpdocs/clients/client2";
$dir_path = "/var/www/vhosts/website.co.uk/subdomains/demo/httpdocs/clients/client3";
$dir_path = "/var/www/vhosts/website.co.uk/subdomains/demo/httpdocs/clients/client4";
$dir_path = "/var/www/vhosts/website.co.uk/subdomains/demo/httpdocs/clients/client5"; [/code

any ideas?

Link to comment
https://forums.phpfreaks.com/topic/66425-help-with-count/
Share on other sites

okies, i had a look, but cannot see anything that helps?

 

this is my code

      <?php 
include "scripts/connection.php"; 
if (!$con) 
{ 
  die( 'Could not connect: ' . mysql_error() ); 
   }
mysql_select_db($db, $con); 

$result = mysql_query("SELECT * FROM album WHERE active = 'yes'");

$dir_path = "/var/www/vhosts/website.co.uk/subdomains/demo/httpdocs/clients/". $row['login']; ""; 
$images = count(glob($dir_path . "*")); 

echo "<p><img src='images/heading/albumtracker.gif'></p><table border='1' bordercolor='cccccc' width='560' cellpadding='5' cellspacing='0'> 
<tr> 
<th align='center' bgcolor='#CCCCCC' class='main'><font color = '000000'>Album Title</font></th> 
<th align='center' width='50' bgcolor='#CCCCCC' class='main'><font color = '000000'>Images</font></th> 
<th align='center' width='50' bgcolor='#CCCCCC' class='main'><font color = '000000'>Creator</font></th> 
<th align='center' width='50' bgcolor='#CCCCCC' class='main'><font color = '000000'>Access</font></th>
<th colspan='2' align='center' bgcolor='#CCCCCC' class='main'><font color = '000000'>Management</font></th> 
</tr>"; 

while($row = mysql_fetch_array($result)) 
{ 
$groom_firstname = $row['groom_firstname']; 
$ceremony = $row['ceremony']; 

if ($ceremony == 'Wedding')
{
$editpage = 'editw.php';
}
elseif ($ceremony == 'Event')
{
$editpage = 'edite.php';
}
elseif ($ceremony =='Portrait')
{
$editpage = 'editp.php';
}
else
{
$editpage = 'editcp.php';
}
  echo "<tr>"; 
  
  if ($groom_firstname == 'X') 
{  
  echo "<td class='main'> The " . $row['ceremony'] . " of " . $row['bride_firstname'] . "</td>";
} 
  else
{
  echo "<td class='main'> The " . $row['ceremony'] . " of " . $row['bride_firstname'] . " " . $row['bride_surname'] . " and " . $row['groom_firstname'] . " " . $row['groom_surname'] . "</td>"; 
}

  echo "<td class='main' align='center'>$images</td>"; 
  echo "<td class='main' align='center'>" . $row['creator'] . "</td>";
  echo "<td class='main' align='center'>" . $row['counters'] . "</td>";
  echo "<td width='100' align='center'><form name='killlive' action='scripts/livestop.php' method='get'>
  		<input type='hidden' name='login' value='" . $row['login'] . "'><input type='submit' class='main' name='Submit' value='De-Activate' onclick='return CheckForm()' /></form></td>";
    echo "<td width='30'><form name='editdetails' action='editpage/";
  echo "$editpage" ;
  echo "' method='POST'><input type='hidden' name='login' value='" . $row['login'] . "'><input type='submit' class='main' name='Submit' value='Edit' /></form></td>";   
  echo "</tr>"; 

} 

echo "</table>"; 
?>

 

still just counts the actual folders in /clients - not the individual files within $login ....

Link to comment
https://forums.phpfreaks.com/topic/66425-help-with-count/#findComment-332518
Share on other sites

What im doing is in my database, say at the moment there are 3 records. client1, client2 and client3, my script creates a folder called the same as the login name ie, client1, client2 and client3. each of the folders could have an unknown amount of images in each folder, so my end result needs to be

 

client1 512 images

client2 21 images

client3 4578 images

 

at the moment, my page, shows the rows with all the info for the clients, but i cant seem to get it to show the number of individual images for each client

Link to comment
https://forums.phpfreaks.com/topic/66425-help-with-count/#findComment-332536
Share on other sites

Try changing...

 

$dir_path = "/var/www/vhosts/website.co.uk/subdomains/demo/httpdocs/clients/". $row['login']; ""; 
$images = count(glob($dir_path . "*"));

 

to...

 

$dir_path = "/var/www/vhosts/website.co.uk/subdomains/demo/httpdocs/clients/". $row['login']; ""; 
$images = count(glob($dir_path . "/*"));

Link to comment
https://forums.phpfreaks.com/topic/66425-help-with-count/#findComment-332542
Share on other sites

nope, still displaying 0

 

i wondered if i would be better doing it, when the album is set active, its runs a simple script to set active = yes,

 

<?php
//Get the data to update

 $login = $_GET['login'];

 //image details
$dir_path = "/var/www/vhosts/website.co.uk/subdomains/demo/httpdocs/clients/$login"; 
$image_no = count(glob($dir_path . "*"));

// Make Connection
include 'connection.php';
if (!$con)
 {
 die('Could not connect: ' . mysql_error() );
 }
 mysql_select_db($db, $con);

//Run the update query
$sql = "UPDATE album SET active = 'yes', image_no = '$image_no' WHERE login = '$login'";

 mysql_query( $sql , $con ) or die( "<strong>Query Error</strong>: " . mysql_error() . "<br><strong>Query</strong>: $sql<br><br>" ); ?>

 

the only issue is these is something wrong because the script is failing, must be a php error, but im lost.. and its late, and nearly time for sleep

Link to comment
https://forums.phpfreaks.com/topic/66425-help-with-count/#findComment-332562
Share on other sites

i just made a real simple script

 

<?php
$dir_path = "/var/www/vhosts/website.co.uk/subdomains/demo/httpdocs/clients/'$login'"; 
$images = count(glob($dir_path . "/*"));

echo $dir_path ;
echo $images ;
?>

 

i get

 

/var/www/vhosts/website.co.uk/subdomains/demo/httpdocs/clients/client1

0

Link to comment
https://forums.phpfreaks.com/topic/66425-help-with-count/#findComment-332576
Share on other sites

got it, i had 'login'

 

<?php
//Get the data to update

$login = $_GET['login'];

//image details
$dir_path = "/var/www/vhosts/website.co.uk/subdomains/demo/httpdocs/clients/$login"; 
$images = count(glob($dir_path . "/*"));

echo $dir_path ;
echo $images ;

// Make Connection
include 'connection.php';
if (!$con)
{
die('Could not connect: ' . mysql_error() );
}
mysql_select_db($db, $con);

//Run the update query
$sql = "UPDATE album SET active = 'yes', image_no = '$images' WHERE login = '$login'";

mysql_query( $sql , $con ) or die( "<strong>Query Error</strong>: " . mysql_error() . "<br><strong>Query</strong>: $sql<br><br>" ); 
?>

Link to comment
https://forums.phpfreaks.com/topic/66425-help-with-count/#findComment-332585
Share on other sites

aggghh,

 

the email script has fallen over now,

<?php

if (!$con) 
{ 
die( 'Could not connect: ' . mysql_error() ); 
}
mysql_select_db($db, $con); 

$result = mysql_query("SELECT * FROM album WHERE login = '$login'") or die(mysql_error());

while($row = mysql_fetch_array($result)) 
{ 
$email = $row['email']; 
$groom_firstname = $row['groom_firstname']; 
$groom_surname = $row['groom_surname']; 
$bride_firstname = $row['bride_firstname']; 
$bride_surname = $row['bride_surname']; 

if ($groom_firstname == 'X') 
{  
 $title = $row['bride_firstname'] . ;
} 
 else
{
 $title = $row['bride_firstname'] . '  and ' . $row['groom_firstname'] . ;
}
?><html><link href="http://demo.website.co.uk/styles.css" rel="stylesheet" type="text/css" />
<?php
$mime_boundary = "IW Photo".md5(time());

# -=-=-=- MAIL HEADERS

$to = "$email";
$subject = "Your album is now live";

$headers = "From: xxx<info@webiste.co.uk>\n";
$headers .= "Reply-To: xxx<info@webiste.co.uk>\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: multipart/alternative; boundary=\"$mime_boundary\"\n";

# -=-=-=- HTML EMAIL PART

$message .= "--$mime_boundary\n";
$message .= "Content-Type: text/html; charset=UTF-8\n";
$message .= "Content-Transfer-Encoding: 8bit\n\n";

$message .= "<html>\n";
$message .= "<body style=\"font-family:Verdana, Verdana, Geneva, sans-serif; font-size:8px; color:#666666;\">\n"; 
$message .= "<table width='800' border='0' align='center' cellpadding='0' cellspacing='0'><tr><td height='80' align='left' valign='top' background='http://demo.website.co.uk/images/top.jpg'><p> </p></td></tr><tr><td align='left' valign='top' background='http://demo.website.co.uk/images/middle.jpg'>";
$message .= "<table width='800' border='0' cellspacing='0' cellpadding='0'><tr><td width='20'> </td>";
$message .= "<td class='main'><p>Dear $title,";
$message .= "<p>We are pleased to announce that your album has been made live now.</p>";
$message .= "<p>Please click <a href='http://demo.website.co.uk/emailgallery.php?login=$login'>HERE</a> to view your album. </p>";
$message .= "<p>You can also now tell all your family and friends about your new album by clicking <a href='http://demo.website.co.uk/tellfriend.php?login=$login'>HERE.</a> </p></td><td width='20'> </td></tr></table></td></tr>";
$message .= "<tr><td align='left' valign='top' background='http://demo.website.co.uk/images/bottom.jpg'> </td></tr></table>";
$message .= "</body>\n";
$message .= "</html>\n";

# -=-=-=- FINAL BOUNDARY

$message .= "--$mime_boundary--\n\n";

# -=-=-=- SEND MAIL

$mail_sent = @mail( $to, $subject, $message, $headers );
}

//Close the connection
 mysql_close($con);

?>

 

its on the same script page as the count but its a php error. it must be...

Link to comment
https://forums.phpfreaks.com/topic/66425-help-with-count/#findComment-332587
Share on other sites

sorry, im just being daft now...

 

i knew it would have been a script error...

 

i'm just thinking about it, i still need my original problem sorted because, i need to know how many images are in each folder before i use the submit button, so, how do i get it to provide the amount of images in each folder using

 

<?php

//image details  - This is how it works on the other script... but that is where i specify $login but im not doing that now

$dir_path = "/var/www/vhosts/website.co.uk/subdomains/demo/httpdocs/clients/$login"; 
$images = count(glob($dir_path . "/*"));

//start connections
if (!$con) 
{ 
die( 'Could not connect: ' . mysql_error() ); 
}
mysql_select_db($db, $con); 

$result2 = mysql_query("SELECT * FROM album WHERE active = 'no'");

echo "<p><img src='images/heading/albumtrackerpend.gif'></p><table border='1' width='560' bordercolor='cccccc' cellpadding='5' cellspacing='0'> 
<tr> 
<th align='center' bgcolor='#CCCCCC' class='main'><font color = '000000'>Album Title</font></th> 
<th align='center' width='50' bgcolor='#CCCCCC' class='main'><font color = '000000'>Images</font></th> 
</tr>"; 

while($row = mysql_fetch_array($result2)) 
{ 
$groom_firstname = $row['groom_firstname'];
$ceremony = $row['ceremony']; 

echo "<tr>"; 

if ($groom_firstname == 'X') 
{
echo "<td class='main'> The " . $row['ceremony'] . " of " . $row['bride_firstname'] . "</td>";
} 
else
{
echo "<td class='main'> The " . $row['ceremony'] . " of " . $row['bride_firstname'] . " " . $row['bride_surname'] . " and " . $row['groom_firstname'] . " " . $row['groom_surname'] . "</td>"; 
}
echo "<td class='main' align='center'>$images</td>"; 
echo "<td class='main' align='center'>" . $row['creator'] . "</td>";

} 

echo "</table>"; 

mysql_close($con); 

?> 

Link to comment
https://forums.phpfreaks.com/topic/66425-help-with-count/#findComment-332604
Share on other sites

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.