473,385 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Having trouble use "While"

Ajm113
161 100+
Ok I got my stuff to split, but how can I have the while work correctly so it will show all of the arrays correctly? Like if you where using Mysql to retrieve data. But this time it is retrieving all the page meta tags and displaying them in a list.

Here is my own Meta Tag I made that I am using for the script:
Expand|Select|Wrap|Line Numbers
  1. <META NAME="pages" CONTENT="Web Developer;http://www.bombinaid.com/Web-Developer">
Here is the script where I want all my page's meta tag to show in a list.

[PHP] $pages = $tags['pages'];
$pieces = explode(";", $pages);

$title = $pieces['0'];
$url2 = $pieces['1'];
while(each($pieces))
{
echo "<a href=\"";
echo $url2;
echo"\">";
echo $title;
echo"</a><br>";
}
[/PHP]
Thanks, Ajm113.
Aug 13 '07 #1
15 1619
pbmods
5,821 Expert 4TB
Heya, AJM.

What do you want your code to do? Give an example.
What is your code doing that you don't want it to do? Give an example.
What is your code *not* doing that it is supposed to? Give an example.
Aug 13 '07 #2
Ajm113
161 100+
I want my code to get all the meta tags that have the word "page" in the name area of the meta tag then retrieve the content field and separate the two areas that have a ";" in it then echo out the two areas so it will show in a url. So the user may click on it for the user to goto another page the site shows.

In the users website:
<meta name="page" content="Downloads;http://www.domain123.com/Downloads">
<meta name="page" content="Contact Us;http://www.domain123.com/Contact_Us">

Echo on my page using the while script that are made so it will echo the number of page meta tags and display them like so:

<a href="http://www.domain123.com/Downloads">Downloads</a>

<a href="http://www.domain123.com/Contact_Us">Contact Us</a>

Right now when I do have more then one page meta tag the script is echoing the second page meta tag two times and not showing the first one.

Here it is on action with the bug:
http://www.bombinaid.com/search.php?...binaid&orgin=1

Just click on the question mark after the url of my website on the results area.
Then look under Redirect Links in the popup window.
Aug 13 '07 #3
Atli
5,058 Expert 4TB
You should consider using the foreach loop.

Like so:
Expand|Select|Wrap|Line Numbers
  1. $pages = explode(";", $tags['pages']);
  2. foreach($pages as $page) {
  3.   $pieces = explode(",", $page);
  4.   echo '<a href="'. $pieces[0] .'">"'. $pieces[1] .'"</a><br />';
  5. }
  6.  
Aug 13 '07 #4
Ajm113
161 100+
Now all its doing is just showing two links with "" in them and I even added another pages meta tag to find a solution or problem, but it is still doing the same thing.

And yes I did take a look at the link, but it does not seem to help me.
Aug 14 '07 #5
pbmods
5,821 Expert 4TB
Heya, AJM.

Neat idea.

Ok. Starting from basics.

If a User's page has this in the head element:
Expand|Select|Wrap|Line Numbers
  1. <meta name="page" content="Downloads;http://www.domain123.com/Downloads">
  2. <meta name="page" content="Contact Us;http://www.domain123.com/Contact_Us">
  3.  
Are you saying that your script outputs this:
Expand|Select|Wrap|Line Numbers
  1. <a href="http://www.domain123.com/Contact_Us">Contact Us</a>
  2. <a href="http://www.domain123.com/Contact_Us">Contact Us</a>
  3.  
Perhaps the problem is outside the code snippet that you provided. Let's see where you calculate $tags['pages'].
Aug 14 '07 #6
Ajm113
161 100+
[PHP]$GetSite = $_GET['url'];


$tags = get_meta_tags($GetSite);

$author = $tags['author'];
$level = $tags['level'];
$description = $tags['description'];
$keywords = $tags['keywords'];


$fp = fopen( $GetSite, 'r' );

$content = "";


while( !feof( $fp ) ) {

$buffer = trim( fgets( $fp, 4096 ) );
$content .= $buffer;

}

$start = '<title>';
$end = '<\/title>';

preg_match( "/$start(.*)$end/s", $content, $match );
$title = $match[ 1 ];
[/PHP]

Thats about it right their for the exeption of where it echos the table with the content in the other meta tags.
Aug 14 '07 #7
pbmods
5,821 Expert 4TB
Heya, AJM.

Very nice.

And what does get_meta_tags() look like?
Aug 14 '07 #8
Ajm113
161 100+
Look here on this page for more information about that command.
Aug 14 '07 #9
pbmods
5,821 Expert 4TB
Wow. Somebody actually made ME go RTFM!

hah. Well look at that.

Ok, What does this look like:
Expand|Select|Wrap|Line Numbers
  1. print_r($tags['pages']);
  2.  
Aug 14 '07 #10
Ajm113
161 100+
It looks like this to me.
[PHP]print_r($tags['pages']);[/PHP]

Just kidding, it renders out like this:
Submit A Site;http://www.bombinaid.com/tellme.php
Aug 14 '07 #11
pbmods
5,821 Expert 4TB
Oh, ha ha.

How about a page that has multiple 'Page' meta tags? Humor me here; what is the output of print_r()?
Aug 14 '07 #12
Ajm113
161 100+
Submit A Site;http://www.bombinaid.com/tellme.php
It shows up like that.
Aug 14 '07 #13
pbmods
5,821 Expert 4TB
Interesting. So the get_meta_tags() function is not returning the proper values then?
Aug 14 '07 #14
Atli
5,058 Expert 4TB
Is it possible that only one Meta tag named 'pages' can exist, so only the last one is available in the PHP script?
Aug 14 '07 #15
Ajm113
161 100+
Yep, the source code of my home page says it all if you taken the time to look at the link and goto my site's result on that link I posted and clicked the question mark to see what it displays then.

Look at my site and open the source code in your browser and look under the meta tag area I have in their.
Aug 15 '07 #16

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Sybren Stuvel | last post by:
Hi there, Is it possible to use an assignment in a while-loop? I'd like to do something like "loop while there is still something to be read, and if there is, put it in this variable". I've been...
6
by: John Pass | last post by:
What is the difference between a While and Do While/Loop repetition structure. If they is no difference (as it seems) why do both exist?
9
by: morpheus | last post by:
Hi Group, When I run this: # include <stdio.h> int main(){ int c=0; while ( (c=getchar()) != EOF && c != ' ' && c != '\t' ) printf("foo"); if (c == '8') putchar(c);
1
by: DougFAI | last post by:
Hello there. Today, I was developing a college work software and then I saw thoe 2 types of while. My teacher asked me how does the "while(ifs)" (considering my ifstream was ifs) (that was the one...
3
by: archeryguru2000 | last post by:
Hello, I've been stumped for several weeks on this particlar program. At work here, we have 30 machines that we record scrap data on. I take this data and create spreadsheets (boring) that can be...
7
by: lukertin | last post by:
I have a 2-D array stored as an object, when i go to call up the array using my $testvar = @ {$self->Peptides}; it gives me the error Can't use string ("0") as an ARRAY ref while "strict...
2
by: zxo102 | last post by:
Hi, I would like to combine two python applications into a single one with two threadings. Both of them have a "while 1:" loop respectively. For example, one application is to monitoring serial...
2
by: recordlovelife | last post by:
So I am trying to display a title, date, and content of a wordpress blog. Word press provides nice drop in functions to get the job done with simple names like "the_title", and the "the_content" But...
1
by: robotlizz | last post by:
Hello - I am a brand new at Java and I am having a hard time with a program I have to turn in tomorrow. I can not get the 'Q' option to work and the loop goes on forever. I've tried to go over the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.