PHP - Select Count From .txt File
Hello there,
This is the script i use right know, and i want it to become easier because i have so much categories that i want to show and it will take days to write all those categories.
<?php include 'extern/connect-.php'; //***************************************************************************** // categEGORY A //***************************************************************************** $result = mysql_query("select (select count(1) FROM videos WHERE title LIKE '%Accident%') as Accident , (select count(1) FROM videos WHERE title LIKE '%Acrobatic%') as Acrobatic, (select count(1) FROM videos WHERE title LIKE '%Adorable%') as Adorable , (select count(1) FROM videos WHERE title LIKE '%Adventure%') as Adventure, "); $row = mysql_fetch_assoc($result); foreach($row as $title => $total) { echo ' <div id="categ"> <div class="a"> <a href="search.php?search='. $title . '&submit= ">'. $title.' '. $total .'</a></div></div>'; } ?>So what i was thinking is if it is possible to make .txt file and to select from it like this here below, or if something else could help make the categories faster to write and get the best performance to load the webpage... some_file.txt Accident Acrobatic Adorable Adventure <?php include 'extern/connect-.php'; $something ='some_file.txt'; //***************************************************************************** // categEGORY A //***************************************************************************** $result = mysql_query("select (select count(1) FROM videos WHERE $something ......? , echo 'categories'; ?>Any help is Appreciated Thanks in Advance Similar TutorialsI'm trying to figure out how to implement SELECT COUNT into a php generated list. My script lists all the users in one table $data = mysql_query("SELECT * FROM YBK_Login") or die(mysql_error()); while($info = mysql_fetch_array( $data )) { Print "<tr>"; Print "<td>".$info['UID'] . " </td>"; Print "<td>"."#"."</td>"; Print "<td>".$info['ID'] . "</td> "; Print "<td>".$info['Allowed'] . "</td> "; Print "<td>".$info['pass'] . " </td>"; Print "<td>".$info['HR'] . " </td>"; } ?> And I want to use the count to count the number of entries each user has in a diffrent table. Like pull the $info['ID'] and check against posts in YBK_Ads with the column name UID Hi fellas, having a bit of trouble getting a count from the database where the field is not empty? $count= "SELECT COUNT(unid) FROM table"; $result2 = mysql_query($count) or die("Select Failed!"); $counter = mysql_fetch_array($result2); echo $counter[0]; From what i have read, this should get all the not null results from the field, but it gets all of them. Some are empty, the ones i want have various id numbers in them. Is there a way to get just the numbers where there is an id number present? Hey, having an odd issue, looking to show players whos within 25 ranks of them lower and higher, i'm unsure as to why the following code doesn't actually do it... would anyone care to explain... Code: [Select] <?php $score = $playerdata['score']; $sql = "SELECT * FROM `players` WHERE '$score' BETWEEN 25 AND 75 ORDER BY `score` DESC"; $query = mysql_query($sql) or die(mysql_error()); $i=0; while($players = mysql_fetch_array($query)) { $i++; ?> This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=313023.0 Hello there, Having a nightmare here. It feels like what I need to do is really easy but I just can't get it to work. I have a table called "groups2" that holds a unique id and the name of an activity. I already have a query that finds the users selected groups using a while loop but I also want to show how many other members are in that group by counting the number of times the activity comes up or the id comes up. I don't know whether I need 2 while loops nested or what but I get the error Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource on line 32 which is highlighted. Can anyone help. I am no expert at php and still learning so some advice or example code would be great. $result = mysql_query("SELECT * FROM groups2 WHERE L_ID = ". $_SESSION['member_ID'] .";"); $data = mysql_query("SELECT COUNT('name') AS num FROM groups2 WHERE name = " . $row['name'] . ""); $count = mysql_fetch_assoc($data); $numbers = $count['num']; while ( $row = mysql_fetch_assoc($result) ) { echo("<tr> <td><font face='Arial, Helvetica, sans-serif' size='3'><strong>" . $row["name"] . "</strong></font></td> </tr><tr> <td><font face='Arial, Helvetica, sans-serif' size='1' color='#0000FF'><strong>Members (" . $numbers . ")</strong></font></td> </tr><tr> <td><hr width=95%><br></td> </tr>"); } hi, I want to count the total number of multiple select that user has selected instead of getting the value the user has selected How should I go about doing the counting part? Code: [Select] <form action="1.php" method="post"> <select name="test[]" multiple="multiple"> <option value="one">one</option> <option value="two">two</option> <option value="three">three</option> <option value="four">four</option> <option value="five">five</option> </select> <input type="submit" value="Send" /> </form> <?php $test=$_POST['test']; if ($test){ foreach ($test as $t){echo 'You selected ',$t,'<br />';} } ?> $result = mysql_query("SELECT * FROM `friend_system` WHERE `friend_system_accepter` = '$myusername' "); echo mysql_num_rows($result);This displays the total rows in the table. $result = mysql_query("SELECT COUNT(friend_system_accepter) FROM `friend_system` WHERE `friend_system_accepter` = '$myusername' "); echo mysql_num_rows($result);This displays '1', which is incorrect. I want to echo out the number of rows where 'friend_system_accepter' = $myusername Thanks The code below is part of some validation code that I have, it is supposed to count the number of entries in the table 'test_selections' where 'userid' equals the user that is logged in and where the 'transfer_in' date is a date within the current month. I am getting an error saying "Error running query Unknown column '10' in 'where clause' ". Does anybody know why this could be? I am hoping that it is something to do with the snippet of code below so I don't need to post the whole lot!! Any help would be much appreciated. Code: [Select] $current_month = date("m"); $query = "SELECT COUNT(`userid`) as `transfers_count` FROM `test_selections` WHERE `userid` = '{$_SESSION['userid']}' AND Month(`transfer_in`) = `$current_month` GROUP BY `userid`"; This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=312721.0 This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=305934.0 Hi all I have a string in an include file for a javascript lightbox value. I need this value to increase by one every time it loops. Here's my code: $fetchproducts = mysql_query(" SELECT * FROM `products` "); while($returnedProduct = mysql_fetch_array($fetchproducts)) { include('product-cell.php'); } The string is called $lightboxcount in the product-cell.php file Can I fit a ++ into the code above? Many thanks for your help Pete I need to get the page count of a multi-tiff and pdf file using php. I've looked into imagick but i'm having a hard time getting it to work. i'm using windows 2k3 iis, and php 5.2.8. Any suggestions? Thanks.
Hi, I want to let users upload multiple images to my online picture book, so after they press submit, HOW do I count the total $_FILES[someName]['name'] uploaded. I want to allow users to type in html form the total uploads they want and this will then display that many desired upload forms. I'm going to try count($_FILES[][]) and go from there first... Any help much appreciated! is this possible? Hi guys, I need your help. I am trying to insert the rows in the mysql database as I input the values in the url bar which it would be like this: Code: [Select] www.mysite.com/testupdate.php?user=tester&pass=test&user1=tester&email=me@shitmail.com&ip=myisp However i have got a error which i don't know how to fix it. Error: Column count doesn't match value count at row 1 <?php session_start(); define('DB_HOST', 'localhost'); define('DB_USER', 'mydbusername'); define('DB_PASSWORD', 'mydbpassword'); define('DB_DATABASE', 'mydbname'); $errmsg_arr = array(); $errflag = false; $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } $db = mysql_select_db(DB_DATABASE); if(!$db) { die("Unable to select database"); } function clean($var){ return mysql_real_escape_string(strip_tags($var)); } $username = clean($_GET['user']); $password = clean($_GET['pass']); $adduser = clean($_GET['user1']); $email = clean($_GET['email']); $IP = clean($_GET['ip']); if($username == '') { $errmsg_arr[] = 'username is missing'; $errflag = true; } if($password == '') { $errmsg_arr[] = 'PASSWORD is missing'; $errflag = true; } if($errflag) { $_SESSION['ERRMSG_ARR'] = $errmsg_arr; echo implode('<br />',$errmsg_arr); } else { $sql = "INSERT INTO `members` (`username`,`email`,`IP`) VALUES ('$adduser','$email','$IP')"; if (!mysql_query($sql,$link)) { die('Error: ' . mysql_error()); } echo "The information have been updated."; } ?> Here's the name of the columns i have got in my database: Code: [Select] username IP I have input the correct columns names, so I can't correct the problem I am getting. Please can you help? This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=331562.0 Why am I getting this error when there are 3 Fields with 3 values? Column count doesn't match value count at row 1 Code: [Select] $sql5="INSERT INTO participants (participant_name, team_no, sport) VALUES ('".implode("','$_POST[team]'),('",$_POST['participant_name'])."','$_POST[team]','$sport')"; I use WYSIWYG Web Builder. They have a file upload option in their form wizard. But I don't want to upload the file. I only want the name of the selected file sent on submit. No matter what I try it keeps trying to send the file, or just sends a blank when I remove the var I've looked though the code and this is the only parts I can find that have anything to do with the file upload. There will be more than one select B1-File, B2-File, B3-File etc.... I put one here. I only want to get the file name that is selected not the file to be sent to the server. If someone knows of an easier way to use a file select/browse button and get the file name only and wouldn't mind sharing it. Thanks I have been searching for a solution and have not been able to find the one. Thanks Bob Code: [Select] function ValidateForm1(theForm) { var extension = theForm.FileUpload2.value.substr(theForm.FileUpload2.value.lastIndexOf('.')); if ((extension.toLowerCase() != ".avi") && (extension.toLowerCase() != ".doc") && (extension.toLowerCase() != ".gif") && (extension.toLowerCase() != ".jpg") && (extension.toLowerCase() != ".mov") && (extension.toLowerCase() != ".mp3") && (extension.toLowerCase() != ".mp4") && (extension.toLowerCase() != ".mpeg") && (extension.toLowerCase() != ".pdf") && (extension.toLowerCase() != ".qt") && (extension.toLowerCase() != ".rtf") && (extension != "")) { alert("The \"FileUpload2\" field contains an unapproved filename."); theForm.FileUpload2.focus(); return false; } return true; } <body> <div id="container"> <input type="file" id="FileUpload2" class="Heading 5 <h5>" style="position:absolute;left:455px;top:592px;width:238px;height:22px;z-index:42" name="B1-File"> </form> </div> </body> </html> Selected navigation on include file. Hi all I can't think how to do this or even if it's possible so I'm hoping someone can help. I have a simple example here to illustrate. http://www.ttmt.org.uk/three.php It's just four linked pages with a heading and a navigation. The navigation has an id="selected" in the <a> tag for that page that changes the color of that link to show you are on that page - very basic. I wanted the put the navigation on the pages with an include file. Code: [Select] <?php include("php/includes/nav.php"); ?> and have the code for the nav in nav.php nav.php Code: [Select] <ul id="nav"> <li><a href="index.php">Home</a></li> <li><a href="one.php">One</a></li> <li><a href="two.php">Two</a></li> <li><a href="three.php">Three</a></li> </ul> My problem is how can I add the id="selected" to the different links for the different pages if I'm including the navigation code? Hope this makes sense and someone can help. Any help would be greatly appreciated. |