The nuke codes man! We need the launch codes.
Anything that relates to your pagination would be of interest.
The code where it is implemented, and also the code that actually generates the pagination.
The nuke codes man! We need the launch codes.
Anything that relates to your pagination would be of interest.
The code where it is implemented, and also the code that actually generates the pagination.
file_get_contents does exactly what the function name says. It opens a file reads all of the content from the file and stores it into a variable etc for your later use.
If you want to use an additional php file within your index.php you want to use include/require (http://php.net/manual/en/function.include.php) There are also include_once and require_once variations but you can read the difference between them in the manual (http://www.php.net/manual/en/function.include-once.php)
The following code uses the SplFileObject [http://www.php.net/manual/en/class.splfileobject.php] from the SPL library. This ensures we never read the entire file into memory, only one line at a time. For small files it is okay to read it into an array, but it is best to get in the habit of working with files line by line unless absolutely necessary to read the whole thing.
Also SplFileObject allows us to parse CSV (Comma Separated Value) files in a single pass. In your case it appears your username and password are separated by a comma so this can be considered a CSV file.
The logic is the same the implementation is different. Also in my example there is a break; statement that stops execution of the foreach loop once a user has been found. This stops us from having to iterate over the n lines that might still exist in the file.
<?php
$user = $_POST['user'];
$pass = $_POST['pass'];
//Use an SplFileObject so we only ever work with 1 line of the file in memory at a time
$file = new SplFileObject( 'fileone.txt' );
//Set flag bitmask for DROP_NEWLINE, SKIP_EMPTY, READ_CSV
$file->setFlags( 15 );
//Because of the READ_CSV flag, $line is already an array of fields field[0], field[1] etc.
foreach( $file as $line ){
//If we find the user in the line, validate the password
if( $user == $line[0]){
if( $pass == $line[1] ){
echo 'Welcome '.$user.'!';
} else {
echo 'Incorrect Name and Password Combination.';
}
//This ends …
What is there not to get? Did you even read the rest of the thread? The op already stated clearly his number is supposedly in bytes. The problem isn't doing simple math the problem is doing simple math with ridiculous numbers.
The more I look at this, the more I have to wonder if your number is wrong.
1.797693134862316e+308 bytes would be 1.487016909281302219479708e+284 yottabytes.
1 bytes = 8.27180613 × 10-25 yottabyte
According to wikipedia the combined storage space of all harddrives in the world does not amount to 1 yottabyte.
<?php
//Start with the base string plus 15 decimal places
$str = '1797693134862316';
//Add 293 0's to the string e.g. (308 - 15)
for( $i=0; $i<293; $i++ ){
$str = $str . '0';
}
//Use bcmath to divide it by 1048576
var_dump( bcdiv( $str, '1048576', 2 ) );
and the result....
17144137714980278015136718750000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000.00
Assuming that really is in KB, although I would take a guess it is really in bits or something.
You need to install the ImageMagick binary library for windows. You can access this via the command line which is what a lot of legacy applications do.
If you want to use the imagick extension then you need the appropriate dll file.
Look at your phpinfo:
<?php
phpinfo();
Look for a line called: PHP Extension Build. Should look something like: API20090626,TS,VC6
Post that line plus your php version and I might be able to point you to the correct dll extension file, for the imagick extension.
your if statement has an extra ) after $row if($row['paid']) = "0000-00-00)"{
change to if($row['paid'] == "0000-00-00)"{
Your use of quotes is incorrect. In php anything wrapped in quotes is a string. If you put a number in quotes single or double it is considered a string. If you specifically want something to be a number, do not wrap it in quotes.
<?php
$a = 5;
$b = '5';
var_dump($a); //integer
var_dump($b); //string
When working with php you have two options for quoting strings, single and double quotes.
With double quotes, php will parse any variables included within the string.
<?php
$color = "blue";
echo "The sky is $color."; //The sky is blue.
With single quotes, php will not parse any variables included within the string.
<?php
$color = 'blue';
echo 'The sky is $color.'; //The sky is $color.
echo 'The sky is '.$color.'.'; //The sky is blue.
There is a slight performance gain, at a very micro level, to using single quotes over double quotes because the interpreter does not have to look for variables. But, the trade-off is you have to use concatenation to handle variables.
Also just a pet peeve, php does not require you to close your php tags. In fact with files that only contain php it is suggested you omit the closing tag to prevent any issues with blank lines following the closing tag.
That is an incorrect example
<?php
$a = 10;
$b = 5+5;
$c = '5+5';
var_dump($a);
var_dump($b);
var_dump($c);
var_dump($a == $b);
var_dump($a === $b);
var_dump($b === $c);
int 10
int 10
string '5+5' (length=3)
boolean true
boolean true
boolean false
http://www.php.net/manual/en/language.operators.comparison.php
Manual page breaks down just about anything you could possibly want to know.
Did you set the default value for that field to 1999-11-30?
When I create a table and set the default value for a DATE type column to be NULL I have no issues inserting a NULL value into the column. Even if you inserted incorrect data into the column, like a string or an integer it should default to 0000-00-00.
Putting a switch like this on a value is actually something that could be moved to your query.
e.g.
SELECT IF(dates.date < CURDATE(), 'paid', 'data') AS row_id FROM dates
In mysql NULL < CURDATE() will evaluate to false. 0000-00-00 < CURDATE() will evaluate to true.
In PHP:
strtotime(NULL) evaluates to false, making your statement if( false < time() ) which evaluates to true.
strtotime('0000-00-00') also evaluates to false so it follows the same as above.
strtotime('1999-11-30') evaluates to '943920000', making your statement if( 943920000 < time() ) evaluate to true.
So as you see any of those conditions will actually evaluate to true.
The current type shouldn't be an issue, I just wanted to make sure it was actually a date column type and not a varchar or unix timestamp stored as an integer.
When I look at that query and run one of a similar structure on my localhost I do get the expected results. I get all of 11 and 12. If you want only November or only December than update the query so it reflects WHERE MONTH(date) = 11
The other option you have is to use IN which can accept 1+ comma delimited values.
Gets all of november AND december
SELECT * FROM table WHERE MONTH(date) IN(11, 12)
Gets only Novemeber
SELECT * FROM table WHERE MONTH(date) IN(11)
Gets only odd months
SELECT * FROM table WHERE MONTH(date) IN(1, 3, 5, 7, 9, 11)
You can use the standard = operator, but IN provides you with some more flexibility to reuse the query for other purposes.
What you're asking is more of a MySQL (I'm assuming) question than directly related to php.
MySQL has a ton of date handling capabilities. Is the date column, which is not a reserved keyword (http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html), setup to be a Datetime, Date, Timestamp or Integer (unix timestamp) field?
Using php 5.2.2+ this is a piece of cake.
<?php
$date1 = new DateTime('2010-12-07');
$date2 = new DateTime('2010-12-07');
if( $date1 == $date2 ){
echo 'Dates are equal.';
}
http://www.php.net/manual/en/datetime.diff.php scroll down to example #2 for some examples.
You CANT use Image Magick without installing it. The extension DLL depends on the Image Magick dll(s) existing.
http://www.sk89q.com/2010/03/vc6-windows-binaries-for-imagick-2-3-0/
You will want to use the thread safe dll file.
However, you still MUST install Image Magick to be able to use the imagick extension.
http://www.imagemagick.org/script/binary-releases.php?ImageMagick=44d3pscnkdc8k41hbrlje3p1r2#windows
I'm not sure if I completely follow what you're asking but array_count_values will return a count of all unique values in your array. Returning an array of unique array items and their count.
First, you need to change $stateFrequency = array_count_values($values=1);
to $stateFrequency = array_count_values($values);
For your example array this would return:
Array
(
[1] => 4
[2] => 1
)
So if you want to know how many times 1 shows up in your array you can simply access it at $stateFrequency[1].
What version of PHP are you running, is it VC6 or VC9 compiled and is it Thread Safe (TS) or Not Thread Safe (NTS)?
You can find this information by displaying phpinfo() and looking for the lines Zend Extension Build & PHP Extension Build
<html>
<form action="get.php" method="GET">
<input type="text" name="myname"><br>
<input type="submit" value="click here">
</form>
</html>
<?php
$name = $_GET["myname"];
echo "Hello, $name";
?>
'myname' is not an index in the $_GET array prior to the form being submitted.
<html>
<form action="get.php" method="GET">
<input type="text" name="myname"><br>
<input type="submit" value="click here">
</form>
</html>
<?php
if( isset( $_GET["myname"] ) ){
$name = $_GET["myname"];
echo "Hello, $name";
}
?>
This simple if statement looks for $_GET to be defined before it tries to execute the code that displays the array item.
--
-- Table structure for table `Bible`
--
CREATE TABLE IF NOT EXISTS `Bible` (
`Book` int(11) NOT NULL,
`Chapter` int(11) NOT NULL,
`Verse` int(11) NOT NULL,
`Scripture` int(11) NOT NULL,
PRIMARY KEY (`Book`,`Chapter`,`Verse`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
--
-- Table structure for table `Scriptures`
--
CREATE TABLE IF NOT EXISTS `Scriptures` (
`Scripture` int(11) NOT NULL AUTO_INCREMENT,
`ScriptureText` text CHARACTER SET latin1 NOT NULL,
PRIMARY KEY (`Scripture`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
In this schema, Bible.Scripture is a Foreign Key to Scriptures.Scripture. I'm assuming Book, Chapter and Verse all join to other tables in your database already.
The primary key becomes a composite primary key of the columns Book, Chapter and Verse. So it doesn't matter if Chapter and Verse are not unique as long as the three columns combined are unique. This prevents inserting any duplicate records accidentally, which using just an auto-incrementing primary key does not.
Splitting it out into two tables is probably overkill considering you have a hard limit to how much data will actually be contained in the table, but it is an reasonable optimization for MyISAM tables. As per my last post the end result is the bible table can now be sorted in memory instead of on disk. You can read about the difference between fixed with and dynamic row formats here:
http://dev.mysql.com/doc/refman/5.0/en/static-format.html
http://dev.mysql.com/doc/refman/5.0/en/dynamic-format.html
-evstevemd
My suggestion was regarding the structure of your table.
The three columns Book, Chapter and Verse together make a perfect primary key eliminating the need to create a surrogate primary key (ID in your table).
My other suggestion, would be to split the actual scripture text out into a second table and join it to the Bible table. Reason being, mysql will use a dynamic row format when it encounters columns with a variable length, like TEXT or BLOB, so sort operations have to occur on disk instead of within memory. This is exponentially slower. Since your sort operations would most likely be against book, chapter or verse columns, this would drastically speed up your queries.
If you're going to build this to essentially sit on top of cPanel, there is an entire API for interacting with cPanel: http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/XmlApi
The easiest way to do this would be to have reseller access to cPanel and create the individual user accounts using sudomain.domain.com as their domain name. Set their account limits using the API and that should be that. cPanel will take care of the quotas and bandwidth, as well as account restrictions. Users can then log into cPanel and configure ftp accounts and email accounts up until the max you impose.
It has been a long time since I've setup an account using a subdomain as the account's domain and I don't recall if there are any limitations to this or not.
If you're using php 5.3+ there are some new classes that make this easier to accomplish.
<?php
//Define out start and end dates
$start = new DateTime('2011-01-01');
$end = new DateTime('2011-02-01');
//Define our holidays
//New Years Day
//Martin Luther King Day
$holidays = array(
'2011-01-01',
'2011-01-17',
);
//Create a DatePeriod with date intervals of 1 day between start and end dates
$period = new DatePeriod( $start, new DateInterval( 'P1D' ), $end );
//Holds valid DateTime objects of valid dates
$days = array();
//iterate over the period by day
foreach( $period as $day )
{
//If the day of the week is not a weekend
$dayOfWeek = $day->format( 'N' );
if( $dayOfWeek < 6 ){
//If the day of the week is not a pre-defined holiday
$format = $day->format( 'Y-m-d' );
if( false === in_array( $format, $holidays ) ){
//Add the valid day to our days array
//This could also just be a counter if that is all that is necessary
$days[] = $day;
}
}
}
var_dump( count( $days ) );
The hardest thing to accomplish outside of php 5.3 will be creating the dates 1 at a time and dealing with month wraps etc. But, it is not impossible. The more advanced and useful solution to this would be to use two Filter Iterators on the the DatePeriod class. http://www.php.net/manual/en/class.filteriterator.php or to extend the DatePeriod class and implement the filters within itself.
PHP > 5.2 Version
Replace
//Create a DatePeriod object using a 1 day …
Just a general observation, feel free to ignore the following.
In your table you're using a surrogate primary key, the auto-incrementing column. When you clearly have a natural and practical composite primary key in (book, chapter, verse) as they are always provided and the combination of three digits may not ever repeat.
The glaring issue I see with using a surrogate key in this scenario is that a record can be mistakenly added with duplicate information.
e.g.
ID, Book, Chapter, Verse, Scripture
1, 1, 1, 1, ...
2, 1, 1, 2, ...
3, 1, 1, 1, ...
By eliminating the ID column it becomes impossible to insert the third record with the duplicate information as the composite pk fails.
Book, Chapter, Verse, Scripture
1, 1, 1, ...
1, 1, 2, ...
1, 1, 1, ...
I know you already solved this, but you can also achieve this without having to do the addition in php.
mysql_query("UPDATE posts SET views = views + 1 WHERE id='$start'") or die(mysql_error());
In SQL assuming the current user has access to both databases:
SELECT
db1.table1.id AS `Id`,
db1.table1.total + db2.table1.total AS `Total`
FROM
db1.table1
LEFT JOIN
db2.table1 ON db1.table1.id = db2.table1.id
WHERE db1.table1.id = 1
If you are using the mysql driver, which you really shouldn't be unless you're on a very old version of mysql. You do not need to use mysql_select_db.
Open the connection to the server as you normally would and specify the full path to tables and fields using the database name. If the user can access both databases should return results just like anything else.
If you're using the mysqli driver, you again do not need to supply the default database. But if you don't you need to specify the full path to tables, db.table.col in every query just as with mysql.
Are you trying to join data from multiple tables in one database, or are you trying to join data across multiple tables in multiple databases?
I agree with everything ardav said.
If you really desire to build a social engine from scratch, define your requirements. Then you will need to spend a lot of time with domain modeling and data storage design before you even start writing code. You could hack and patch it together as you go, but updating it or making changes once you have deployed it will become a nightmare or impossible.
Model the interactions that occur and the objects that exist in your system. Based around those models design a database/datastore that best suites your current design. Don't just think about databases as SQL there are a lot of NoSQL engines that will make your life easier in certain aspects, Couch and Mongo being two popular ones,(http://en.wikipedia.org/wiki/NoSQL). Use existing systems, these don't have to be social networks, to gather ideas about how the system should be structured and how the pieces interact with one another.
Once you have a domain model that fulfills your requirements start building the system around your individual models. Domain Modeling and OOP Design go very hand in hand. If done correctly and to a good degree of detail your end result will be essentially a map that guides your development.
If you are building from scratch, use version control and develop good unit testing habits. The more you test the easier it will be to expand or refactor things as new requirements develop.
This is the 60K foot view, …
For a long time I was a fan of doing everything with unix timestamps, but there are, in most cases, limitations to these. One of the limitations would be the available range (Jan 1, 1970 - Jan 19, 2038). Its mostly a 32bit limitation and I would hope by 2038 most/all systems are in at least a 64bit environment which alleviates any issues. But, applications that work with dates in the future, like something that calculates end dates of 30 years mortgages or loans or something may run into issues long before we get close to 2038. http://en.wikipedia.org/wiki/Year_2038_problem
The newer DateTime objects in PHP 5.3 have overcome this issue and support unix timestamps before and after the prior range. Timestamps are easy to work with, simply adding and subtracting seconds to get what you want, but in my opinion using the database format for working with dates/datetimes is more effective.
Move your date transformations and calculations to the database server and it really provides you with a lot more flexibility. You can format the dates as you want to use them, do the comparisons, calculations etc right in your SQL without having to essentially pre/post-process all of your query results to convert the dates from one format to another using php.
This is opinion of course. It really is one of those topics where each person will have their own preferred method and no one method will be more correct than another.
@Full Spectrum
Its not an untyped language it is a loosely typed language. You can cast values to a particular type and do type comparisons if you want/need too.
@benjaminFowl87
Unit testing is a very powerful mechanism for development, but in my experience it is a different mindset than just sitting down and writing code. Generally you see unit testing talked about with TDD (Test Driven Development). In other words, you design your functionality, write a failing test, write code to pass the test and finally refactor the code to a certain standard level.
Unit testing really shines when you have a system that is heavily tested and then you are tasked with making changes to already existing classes/functions throughout the existing system. Because your tests all pass to start, you write new failing tests and then implement the code necessary to pass those tests. As long as your original tests still pass and your new tests pass, then you have added your additional functionality without breaking any existing code.
Where as without testing, its next to impossible to know for sure that everywhere that piece of code is used is still functional until a bug or issue is found.
Just my $0.02 hope it helps.
@andrewschools
I don't believe you are using the correct definition of stable sort.
By definition a stable sort, the sort is performed by key/index. Where when duplicate keys exist the relative order of their values is maintained. In PHP you can not have two array items with the same key.
e.g. If you have a data set like (letters denote that we have multiple instances of the same key for reference):
(1b, 1) (1a, 1) (1c, 1) (0a, 1) (0c, 1) (0b, 1)
it would sort to:
(0a, 1) (0c, 1) (0b, 1) (1b, 1) (1a, 1) (1c, 1)
In the data set your provided:
$array = array("item1"=>-1,"item3"=>-1,"item4"=>0,"item5"=>2,"item6"=>2,"item7"=>1,"item2"=>-1);
would stable sort to:
(item1, -1)(item2, -1)(item3, -1)(item4, 0)(item5, 2)(item6, 2)(item7, 1)
since you do not have any duplicate keys it would be sorted by key only.
What it appears you're asking for, is a sort by value while maintaining relative position of the keys so your result set would be:
(item1, -1)(item3, -1)(item2, -1)(item4, 0)(item7, 1)(item5, 2)(item6, 2)
Problem being something like asort() is resulting in:
array
'item2' => int -1
'item3' => int -1
'item1' => int -1
'item4' => int 0
'item7' => int 1
'item5' => int 2
'item6' => int 2
Where it is sorting by value, but not maintaining the correct order of the keys.
Am I correct in understanding the problem at this point? Essentially a stable sort using the value as the key and the key …
@ardav
It just screamed trigger to me...its Friday, I'm pulling out all the stops haha.
@CEVGames
Like I said that is not tested but it looks mostly correct as I typed it out. Hope it works out for you. If not plenty of other ways to skin a cat.
This to me sounds like something best handled by the database using a trigger.
Questions (Table):
QuestionId int
Question varchar
Answer varchar
DateActive datetime
Value tinyint default 100
QuestionUserAnswers (Table):
QuestionId int
UserId int
Answer varchar
Score tinyint (min 50, max 100)
With your trigger being something like this:
CREATE TRIGGER Trig_QuestionScore AFTER INSERT ON Questions
FOR EACH ROW BEGIN
IF Questions.`Value` > 50 THEN
UPDATE Questions SET Questions.`Value` = Questions.`Value` - 5;
END IF
END;
**This is NOT tested so use it just for the general concept.
But what you would do is when the user gets the question right, you would insert a record into the QuestionUserAnswers table. AFTER that insert occurs the trigger would fire automatically and look at the Questions table and subtract 5 from the Questions value unless the value was already at 50.
This only works on mysql > 5.0.2
http://dev.mysql.com/doc/refman/5.0/en/create-trigger.html
http://dev.mysql.com/doc/refman/5.0/en/trigger-syntax.html
http://dev.mysql.com/doc/refman/5.0/en/stored-program-restrictions.html
Glad to help
BaSk,
I have done just this. But, I use a command line tool called PDFTK (http://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/)
Essentially, I take a fillable pdf that has been designed. Collect information from the user via a web interface and create xfdf from it (http://partners.adobe.com/public/developer/en/xml/xfdf_2.0_draft.pdf). Once I have the generated xfdf I execute a command line call with php to pdftk that merges the fillable pdf with the xfdf resulting in a finished flattened pdf that contains the user's information.
PDFTK is free, but it has to be installed on the server to work. It also has a ton of other features that are really useful to be able to call from the command line.
You are missing something in your conditional statement:
if($_SESSION['userLevel']==1 $_SESSION['userLevel']==2){
should be (assuming its an OR condition):
if($_SESSION['userLevel']==1 || $_SESSION['userLevel']==2){
Wamp and PHP frameworks are not synonymous. Regardless whether you choose a to use a framework, you still need a web server installation, which is what Wamp is.
As for frameworks, my suggestion is to make some quick applications under several of the big name frameworks and get a feel for which you feel more comfortable in. Every framework has its positives and negatives and it really depends on the requirements of your project. For simple one off scripts the overhead of a framework is usually not justified.
I think this is going to depend more on how your array is actually structured. Post up and example of the array your iterating and a more detailed example of the result.
function showDepartment()
{
require_once('lib/model/classDepartment.php');
$dept = new department();
$departmentID = $dept->showAllDepartment();
if(isset($_POST['addDepartment'])) $this->addDepartment();
if(isset($_POST['updateDepartment'])) $this->updateDepartment();
if(isset($_POST['yesDeleteDepartment'])) $this->deleteDepartment();
if(isset($_POST['noDeleteDepartment'])) echo "<script language='javascript'>window.location='department.php';</script>";
require_once('lib/view/tpl.department.php');
}
Without knowing how the department class is setup, this is my best assumption.
It sounds like you're trying to read through a file line by line and then use the value of that line to perform a query.
Personally I prefer the SplFileObject assuming you're using php > 5.1.0
<?php
//Create SplFileObject instance of $filename
$file = new SplFileObject($filename);
//Set the drop new line flag so returned line value does not include \n etc.
$file->setFlags(SplFileObject::DROP_NEW_LINE);
//Foreach line in the file execute a query
foreach ($file as $line) {
mysql_query($line);
}
Can you please describe your use case a little more so we have a better idea of what you are trying to accomplish?
You can read through a file line by line using fgets, but if you are trying to detect if a character is an end of line character, which varies (\n \r\n etc.), you would use something like fseek to progress the file pointer 1 character at a time and fread to capture the next byte and test it for being an EOL character.
Then you probably want to look into using a 3rd party system for sending these bulk emails. There are lots of providers that supply this functionality, at a cost of course.
Are two I am familiar with, StreamSend being one i've done a lot of integration with.
In an nutshell they usually inject some kind of 1x1px tracking image to tell when the email has been opened. Rewrite the urls in the emails so that they go through a redirection script of some kind to track the number of users who clicked on a link. And, I'm assuming they're monitoring the mail queue and mail logs for undeliverables etc. Many of these services are designed to prevent you from getting blacklisted as well which bulk mailing will result in, real quick at times.
Just my $0.02 hope it helps.
In my opinion there are several reasons to use thumbnails over full sized images.
For starters the web is fast and your connection might be fast but there are still plenty of people who do not have fast connections.
Second, since in a default state browsers only allow you to load a few requests in parallel. So unless you're serving your images from multiple sub-domains one long loading image can holdup the entire page load.
Third, if you're loading a bunch of large images you're consuming bandwidth for each page load. Potentially a lot of bandwidth for each page load when a user may only look at a page of thumbnails and close it.
Fourth, even for thousands of images it takes minutes to create thumbnails, there are desktop apps, command line tools, and even php that can automate the process.
Just my $0.02
Edit: The problem is that you don't have the img tag wrapped with an a tag.
echo '<td><a class="mylink" href="http://',$row['website'],'">',$row['website'],'</a></td>';
echo '<td><a class="mylink" href="http://',$row['website'],'"><img width="75" src="',$row['url'],'"/></a></td>';
echo "<td><a class=\"mylink\" 'http://' href=\"http://" . $row['website'] . "\">" . $row['website'] . "</a></td>";
echo "<td><img width = '75' src=". $row['url'] . " /></td>";
For starters if you're going to be echoing HTML, single quotes will make your life much easier. You also have an unnecessary 'http://' in between your class and href attributes.
echo '<td><a class="mylink" href="http://',$row['website'],'">',$row['website'],'</a></td>';
echo '<td><img width="75" src="',$row['url'],'"/></td>';
Also unless you absolutely NEED to append the strings together, passing multiple strings and delimiting them with a comma will speed things up. This only works with echo and not print.
with the exception that http:// could be repeated multiple times within the url. in which case that would fail. It all depends on the use case. $url = 'http://www.site.com/url.php?url=http://www.google.com';
You would also probably want to use str_ireplace as the user supplied url could very well be Http:// HTTP:// hTtP:// etc.
Not sure what the environment limitations are, but SQLite3 has fulltext searching capabilities, but they are not enabled by default. Very Similar to mysql syntax it appears.
Assuming your table is a MyISAM and the particular column has a full-text index on it:
SELECT * FROM table WHERE MATCH (col1, col2, col3) AGAINST ('+Goa' IN BOOLEAN MODE);
http://dev.mysql.com/doc/refman/5.1/en/fulltext-boolean.html
***Apparently this does not REQUIRE a fulltext index, but will take a major performance hit
There are a lot of different ways to attack this: http://refactormycode.com/codes/598-remove-http-from-url-string has a whole variety of them. Some are good some are bad, my suggestion is to avoid regular expressions unless they're absolutely necessary.
<?php
/*
E.g:
$s = 'http://google.com';
echo remove_http($s);
output: google.com
*/
function remove_http($url = '')
{
array('http://', 'https://');
foreach ($list as $word)
if (strncasecmp($url, $word, strlen($word)) == 0)
return substr($url, strlen($word));
return $url;
}
Would probably be my choice from that link for how to do this accurately.
Your images are not clickable because there are no links around them.
They would need to be something like:
echo "<td><a href="someurl.com"><img width = '75' src='http://". $row['url'] . "' /></a></td>";