473,387 Members | 1,683 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,387 software developers and data experts.

creating a ul from php submitted links

I'm trying to make a ul from submitted websites. I've got the links to work, but can't figure out how to make them appear in a list. I'm writing this to a text file, not a database. Thanks and Happy New Year!




<?php
$text = (file("http://www.brewerthompson.com/classes/class/309/multiurl.txt"));
for($i = 0; $i < count($text); $i++)
{
$web = $text[$i];
}
?>

<li><a href="http://<?php echo $web;?>" target="_blank"><?php echo $web;?></a></li>
Dec 26 '06 #1
5 1374
ronverdonk
4,258 Expert 4TB
I'm trying to make a ul from submitted websites. I've got the links to work, but can't figure out how to make them appear in a list. I'm writing this to a text file, not a database. Thanks and Happy New Year!

<?php
$text = (file("http://www.brewerthompson.com/classes/class/309/multiurl.txt"));
for($i = 0; $i < count($text); $i++)
{
$web = $text[$i];
}
?>

<li><a href="http://<?php echo $web;?>" target="_blank"><?php echo $web;?></a></li>
You must start a list with the <ul>, <ol> or <dl> definitions (and close them of course). See the next code:[php]<?php
$text = (file("http://www.brewerthompson.com/classes/class/309/multiurl.txt"));
echo '<ul>'; <==== START THE LIST
for($i = 0; $i < count($text); $i++) {
$web = $text[$i];
}
?>
<li><a href="http://<?php echo $web;?>" target="_blank"><?php echo $web;?></a></li>
</ul> <==== END THE LIST[/php]
Ronald :cool:
Dec 27 '06 #2
Thanks Ronald. I've got the code working, but what it isn't doing is making a list. It's just replacing the preceeding item. (I have the file set to append) I'm new to php, so there is probably something very simple I'm missing. Would this be easier with a database? Seems like a simple enough idea. Here's the code:

----------------
<?php

$text = (file("http://www.brewerthompson.com/classes/class/309/multiurl.txt"));
echo '<ul>';

//start list


for($i = 0; $i < count($text); $i++)
{

$web = $text[$i];

}

?>


<li><a href="http://<?php echo $web;?>" target="_blank"><?php echo $web;?></a></li>
</ul>


</div><!--end left urls-->




You must start a list with the <ul>, <ol> or <dl> definitions (and close them of course). See the next code:[php]<?php
$text = (file("http://www.brewerthompson.com/classes/class/309/multiurl.txt"));
echo '<ul>'; <==== START THE LIST
for($i = 0; $i < count($text); $i++) {
$web = $text[$i];
}
?>
<li><a href="http://<?php echo $web;?>" target="_blank"><?php echo $web;?></a></li>
</ul> <==== END THE LIST[/php]
Ronald :cool:
Dec 27 '06 #3
ronverdonk
4,258 Expert 4TB
In order to concatenate all entries into the $web variable, you must specify
Expand|Select|Wrap|Line Numbers
  1. $web .= $text[$i]
If you want to make every $text[$i} item an <a>... link, you must NOT concatenate the $web variable, but place the current <a.. statement within the loop. SO if you want all extracted links in a clickable list of sites, you can use this code:
[php]<?php
$text = (file("http://www.brewerthompson.com/classes/class/309/multiurl.txt"));
echo '<ul>';
//start list
for($i = 0; $i < count($text); $i++) {
$name=trim($text[$i]); // remove newline chars and blanks
echo "<li><a href='http://".$name."' target='_blank'>".$name."</a></li>";
}
?>
</ul>
</div><!--end left urls-->[/php]

To be sure that it is an array you get back from your remote site, print out the $text array before you go into the loop. Like this
Expand|Select|Wrap|Line Numbers
  1. echo '<pre>'; print_r($text);
It will show you the exact content of that $text array (when it is not an array you will see that also).

Ronald :cool:
Dec 28 '06 #4
Thanks Ronald! I've got it now. This is one of the most helpful forums I've found! Have a great New Years!



[quote=ronverdonk]In order to concatenate all entries into the $web variable, you must specify
Expand|Select|Wrap|Line Numbers
  1. $web .= $text[$i]
If you want to make every $text[$i} item an <a>... link, you must NOT concatenate the $web variable, but place the current <a.. statement within the loop. SO...
Dec 28 '06 #5
ronverdonk
4,258 Expert 4TB
Glad we could help. Hope to see you again.

Ronald :cool:
Dec 29 '06 #6

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

Similar topics

2
by: tommy | last post by:
Newbie to the group.....hope you guys can help. I need to be able to have a button at the bottom of a form page (like the submit & reset buttons) to provide the user with a printer friendly...
2
by: clarket | last post by:
Hi, I have a html form where all the details are saved in a MySQL database that uses PHP to insert the data into the database. The problem I'm having is that if people dont submit the form...
6
by: Adam Tilghman | last post by:
Hi all, I have found that IE doesn't seem to respect the <SELECT> "multiple" attribute when set using DOM methods, although the attribute/property seems to exist and is updated properly. Those...
8
by: Jimbo | last post by:
Hello I am currently designing an internal ordering system for IT equipment. I am designing it in ASP.NET (vb) using Visual Studio 2003 and using Microsoft SQL Server I have got the system...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.