PHP - Adding Count In Include File
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 Similar TutorialsThis topic has been moved to HTML Help. http://www.phpfreaks.com/forums/index.php?topic=352099.0 Hi I have currently written some code which uses of the Twitter API and extracts the information required to display my most current tweet on my website. This is all working perfectly but at the minute it is only displaying one tweet and I would like it to display as many as the variable $limit is set to. I have tried numerous count with while loops but just cannot seem to get my head around the logic of it. Here is the code im currently using which displays one tweet. <?php $username = "my_twitter_username"; $limit = "2"; $twitter_url = "http://twitter.com/statuses/user_timeline/$username.xml?count=$limit"; $buffer = file_get_contents($twitter_url); $xml = new SimpleXMLElement($buffer); $status_item = $xml -> status; $status_id = $xml -> status -> id; $user_item = $xml -> status -> user; $user_id = $xml -> status -> user -> screen_name; $description = $status_item -> text; $status_time = $status_item -> created_at; $status_img = $user_item -> profile_image_url; $description = preg_replace("#(^|[\n ])([\w]+?://[\w]+[^ \"\n\r\t< ]*)#", "\\1<a href=\"\\2\" target=\"_blank\">\\2</a>", $description); $description = preg_replace("#(^|[\n ])((www|ftp)\.[^ \"\t\n\r< ]*)#", "\\1<a href=\"http://\\2\" target=\"_blank\">\\2</a>", $description); $description = preg_replace("/@(\w+)/", "<a href=\"http://www.twitter.com/\\1\" target=\"_blank\">@\\1</a>", $description); $description = preg_replace("/#(\w+)/", "<a href=\"http://search.twitter.com/search?q=%23\\1\" target=\"_blank\">#\\1</a>", $description); echo " <div class='tweet-wrapper'> <div class='tweet-img'> <a href='http://www.twitter.com/la__academia' target='_BLANK'><img src='$status_img' alt='La Academia Twitter' style='width:30px height:30px;' /></a> </div><!-- tweet-img --> <div class='tweet-text'> <p class='tweet-p'>$description</p> <p class='tweet-time'>$status_time . <a href='http://twitter.com/?status=@$user_id%20&in_reply_to_status_id=$status_id&in_reply_to=$user_id' target='_BLANK' class='tweet-reply'>Reply</a></p> </div><!-- tweet-text --> <div class='cleaner'></div> </div><!-- tweet-wrapper --> "; ?> Thanks for any help. SOLVED Hey Guys. I am trying to include a file. The file path gets returns from an objects method. When a run is_file() on the returned data it returns true, but does not include it!!! Can anyone please help me solve this!!
class StoreInitialization { public function loadConfigFile(){ $config_file="../store/demo/store_configuration.php"; return $config_file; }Client Code $store_config_file = $store_initialization->loadConfigFile(); require($store_config_file); I have a php file that generates a string that I need to use in a .js (javascript)file. Being that php developers sometimes using javascript with php, Im hoping someone can help me with this, cause i dont know any javascript. Code: [Select] //This is the varible inside the .js file var suggestionText = "I need to be able to include my string generated by the php file here..."; 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 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! I want to include a php file after an succesfully login. Let's suposed that I have a login form on index.php. If the login was ok I want to include a php file with some content instead of the login form. Something like: Code: [Select] <? if($_POST['ok']){ require('content.php'); } else { //login form } ?> It's ok to include in the code the name of the file that you have on server ? From security point of view. Thanks Hello, Im trying to pass a variable to a newly created page using GET. Code: [Select] $query = mysql_query("SELECT DISTINCT subtype FROM business WHERE type ='Restaurant' ORDER BY name"); echo mysql_error(); while($ntx=mysql_fetch_row($query)) $nt[] = $ntx[0]; $i = -1; foreach($nt as $value) {$i++; echo "<a href='" . str_replace(' ','_',$nt[$i]) . ".php?title=$title'>" . $nt[$i] . "</a>" . "<br/>"; $FileName = str_replace(' ','_',$nt[$i]) . ".php"; $FileHandle = fopen($FileName, 'w') or die("cant open file"); $pageContents = file_get_contents("header.php"); fwrite($FileHandle,"$pageContents");} fclose($FileHandle); header.php Code: [Select] <head> <?php $title = $_GET['Title']; ?> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <p>HEADER UPDATED!</p> <p>TESTING - the heading below should read (title goes here in capital letters)</p> <?php <h1>$title</h1> ?> //This is line 12 </body> </html> Im getting the error; Parse error: syntax error, unexpected '<' in D:\Hosting\3753557\html\1pw\mexican.php on line 12 I suspect that I have my syntax muddled in header.php? Is there a better way to pass variables to a newly created page? (fopen). Many thanks for any ideas. www.desmond-otoole.co.uk/secure/securefunctions.php /bank/admin/index.php what should I do in the index.php file to access securefunctions.php
require("../secure/SecureFunctions.php"); Nothing seems to work
I just get a stupid google chrome page saying Can I include a class file in the same page that I use an instance of the same class with my action attribute with my form. Here's the code Code: [Select] <?php include 'Resources/User.php';?> <html> <head> <title></title> <link href="stylesheets/styles.css" rel="stylesheet" type="text/css"/> </head> <body> <form action = "Resources/testClass.php" method="post" enctype="multipart/form-data"> <label>First Name: </label> <input type="text" name="fname" id="fname" size="25" maxlength="25"/> <label>Last Name: </label> <input type="text" name="lname" id="lname" size="25" maxlength="25"/> <label>Email: </label> <input type="text" name="email" id="email" size="25" maxlength="40"/> <label>Username: </label> <input type="text" name="username" id="username" size="25" maxlength="32"/> <label>Password: </label> <input type="password" name="password" id="password" size="25" maxlength="32"/> <label>Re-enter Password: </label> <input type="password" name="conf_pass" id="conf_pass" size="25" maxlength="32"/> <br /><br /> <input type="submit" name="submit" id="submit" value="Register"/> <input type="reset" name="reset" id="reset" value="Reset"/> </form> </body> </html> hi php freaks, Is there a way to parse an include file through the php engine and then place the contents into a variable? Code: [Select] $x = include ($myfile); Hi all, I'm at a dead-end here. I have a php file that I can query to return an array containing a bunch of data about a job listing. I include and query it by calling it like so within another file on my site. Quick Notes: The original file is in a different directory on my site than the page it's being included in. I have tried returning the array at the end of the script. I can print_r the array on the page I'm including the script on (so the URL path is correct). If I go to this URL directly and print_r on the array, I see the entire array as expected. Also, if I include the file on page 2 like I did above with print_r on the array in the original file, I see the array printed out on page 2. Code: [Select] include 'http://www.example.com/php/job-details.php?job=jobname&city=thecity'; However, if I do not print_r on the array in the original file and just include it on page 2, I cannot do anything with it and the array variable isn't found. Is this a case of variable scope? I'm so frustrated... Here is the code I have in my original file: Code: [Select] <? include('functions.php'); $jobtitlematch = $_GET["job"]; $jobcitymatch = $_GET["city"]; //echo $jobtitlematch; //echo $jobcitymatch; $url = 'http://somesite.com/something'; $xml = simplexml_load_file($url); foreach($xml->job as $job) { $jobtitle = makeURL((string)$job->title); $jobcity = makeURL((string)$job->region); if ($jobtitle == $jobtitlematch && $jobcity == $jobcitymatch) { $jobdata[] = array( Title => ((string)$job->title), URL_Title => makeURL((string)$job->title), Location => ((string)$job->region), URL_Location => makeURL((string)$job->region), Department => ((string)$job->department), URL_Department => makeURL((string)$job->department), Overview => ((string)$job->joboverview), Responsibilities => ((string)$job->responsibilities), Qualifications => ((string)$job->qualifications), Keywords => ((string)$job->metakeywords) ); } return $jobdata; //I have also tried return global $jobdata; } print_r($jobdata); ?> Thanks in advance for any help you can provide... I'm really embarrassed asking this.. I have two files. config.php & program.php config.php<php $max_columns = 3; ?> program.php<?php include ('config.php'); echo $max_columns; ?> I can't get the script to echo anything. I have tried... $max_columns = '3'; $max_columns = "3"; include_once include ("config.php"); include ('/path/to/file/config.php'); require .....etc. etc. Any thoughts? PLEASE, I'm going nuts here. Thanks for you patience with what must be a very trivial question for you guys Here is a section of php file A include_once(dirname(__FILE__) . '/PhpfileB.php') $VALID_RATING_IDS = $Ratethese Here is all of php file B $Ratethese = "array("1", "2",);" I need the var $VALID_RATING_IDS to = $Ratethese from file B I am trying to include an array from php file B in php file A. Is this possible? How can i accomplish this? My catalog uses a template file to list product details. One part of it is responsible for putting these details into nifty little tabs: <?php $template = '{magictabs style=black_rounded, tabwidth=110px}'; $template .= 'Technical Specifications'; $template .= '::'; $template .= '<table colspan="3"><tr><td>'; $template .= $details; $template .= '</td></tr></table>'; $template .= '||||'; ?> I don't want it to output $details, I want it to output a separate script instead. How do I include this separate file as a variable? I want this: <?php include('specs.php'); ?> to replace the $details variable. How do I include a file that is located two directories above the file that I want to include the file into? My absolute hosting path is /home/content/52/8840652/html if this would be of any use. I'm not quite sure about the PHP include functions. Any help would be greatly appreciated, Thanks! In my code include_once "http://myserver.com/someFile.php" does not work but include_once "/someFile.php" works I NEED to be able to full URL. Anyone know what PHP setting I need to change to get this working for me? Thanks |