php / mysql statement not working for URL
am 25.02.2007 08:22:27 von ron
Hi all,
I use php / mysql for keeping and generating simple lists. I can't for
the life of me echo out a URL.
Here are my examples:
echo "
";
echo stripslashes($row["location_url1"]);
echo " | ";
This URL echoes out fine but isn't a link as there is no tag. Was
happy that it was read into my db and came out OK.
echo "";
echo "Here's Your
Link;
echo " | ";
I've tried about 25 combinations of quotes and can see the the syntax
highlighting change. Right now I think there is an extra set of quotes
but it doesn't work either way...
Any help would be greatly appreciated,
TIA
ron
Re: php / mysql statement not working for URL
am 25.02.2007 17:53:03 von ron
On Sun, 25 Feb 2007 12:17:18 +0100, "J.O. Aho"
wrote:
>Ron wrote:
>> I figured it out:
>>
>> o "";
>> echo "Click
>> here";
>> echo " | ";
>>
>> forgot a couple of those pesky dots. :)
>>
>> Is there a better way of doing this?
>
>"Click here" is quite non informing and proper html wants options to be
>quoted (even if single quotes are accepted by standard, there are
>browsers that has problem with it and it's better to double quote)
>
>echo "
>href=\"".stripslashes($row["location_url2"])."\".>".stripsl ashes($row["location_url1"])."\n";
>
>I do think adding the new line at the end of each line html that is
>echoed is a really good thing to do, as you this way will easier see
>things when you look at the html-source in the browser.
>
>I'm not sure if you need stripslashes(), as those character that may
>need that aren't allowed in an url, then you could use
>
>echo <<
>
>
> |
>EOL;
>
>There ain't any point in using the width attribute in the td-tag, as you
>are already using CSS and you can set the width in the CSS.
Good morning,
Thanks for the response.
I agree, the "click here" was poor. It was late. Actually this will
turn into a variable based on the URL As I can't just name the column
and be done. Like if I linked to mapquest and Yahoo but then for a
particular record used a map from National Geographic. Whatever. and
with permission of course.
Your concatenation above might work but my output is a 5 column table
so the td statements should be separate, IMO.
I tried to add the newline to the end but could never make it work.
Good idea and will work on it more.
The use of a table in this case I think is appropriate as it is
tabular and just a habit to put percents. Better than pixels. :) But
for kicks would you define the css element like td.col1, td.col2,
td.col3, abd so on??? I ws looking as CSS.org and was getting lost.
Thanks!
Re: php / mysql statement not working for URL
am 25.02.2007 18:09:42 von Shion
Ron wrote:
> On Sun, 25 Feb 2007 12:17:18 +0100, "J.O. Aho"
>> echo "
>> href=\"".stripslashes($row["location_url2"])."\".>".stripsla shes($row["location_url1"])."\n";
>>
>> I do think adding the new line at the end of each line html that is
>> echoed is a really good thing to do, as you this way will easier see
>> things when you look at the html-source in the browser.
>>
>> I'm not sure if you need stripslashes(), as those character that may
>> need that aren't allowed in an url, then you could use
>>
>> echo <<
>>
>>
>> |
>> EOL;
>>
>> There ain't any point in using the width attribute in the td-tag, as you
>> are already using CSS and you can set the width in the CSS.
> Your concatenation above might work but my output is a 5 column table
> so the td statements should be separate, IMO.
You can use it on whole pages, in a project I have been playing with, all
static stuff has been made in this way and all dynamic are just variables in
the static stuff, IMHO this makes things a lot easier to read, but of course
it's a question about taste.
> I tried to add the newline to the end but could never make it work.
> Good idea and will work on it more.
echo '\n'; //this outputs a string of 2 characters, \ and n
echo "\n"; //this outputs a newline (1 character)
Even if those two lines looks like the same, they aren't, using single quotes
you always get exactly that out, while double quotes allows things to be "parsed".
> The use of a table in this case I think is appropriate as it is
> tabular and just a habit to put percents. Better than pixels. :) But
> for kicks would you define the css element like td.col1, td.col2,
> td.col3, abd so on??? I ws looking as CSS.org and was getting lost.
css is a bit difficult, at least in the beginning, and I'm quite new on this too.
if you use id="something" then the setting looks something like:
#something td {
margin: 0.2em;
}
if you use class="anything" then the setting looks something like:
td.anything {
margin: 0.3em;
}
You can combine these (id="something" class="anything"):
#something td.anything {
margin: 0.3em;
}
You can first begins with a general td that has all the settings that all (or
most) has in common, then for those that needs some changes you create their
own classes.
td {
margin: 0.2em;
width: 10%;
}
td.anything {
width: 15%;
}
The rule that is last in the css file, will have higher priority over a rule
thats been defined before.
Keeping all in mind, you may not need special rules for each column in your table.
--
//Aho