Jump to content

[SOLVED] Need Help Changing For_Each With Generated Hyperlink


HowdeeDoodee

Recommended Posts

I need help changing the following code.

 

<?php
$ref[0] = "gen 1:12";
$ref[1] = "exo 2:31";
foreach($ref as $value){
echo '<a href=www.findthepower.net/CP/BibleSuperSearch/bible_supersearch.php?submit=true&version=kjv&searchtype=All+Words&search=&wholeword=Whole+words+only.&table_display=true&lookup='.$value.'">'.$value.'</a>';
};
?>

 

 

I want $value to equal          gen 1:12 ; exo 2:31;

Currently $value from the code above equals only            exo 2:31;

 

 

and the generated hyperlinks should be like this...

 

<a href="http://www.findthepower.net/CP/BibleSuperSearch/bible_supersearch.php?submit=true&version=kjv&searchtype=All+Words&search=&wholeword=Whole+words+only.table_display=true&lookup=gen1:12;exo 2:31;"?>SEARCH</a>

 

But the generated hyperliks are clipped off at the end and appear separately (see below)

 

<a href="http://www.findthepower.net/CP/BibleSuperSearch/bible_supersearch.php?submit=true&version=kjv&searchtype=All+Words&search=&wholeword=Whole+words+only.table_display=true&lookup=gen" 1:12;?>gen 1:12;</a>
<a href="http://www.findthepower.net/CP/BibleSuperSearch/bible_supersearch.php?submit=true&version=kjv&searchtype=All+Words&search=&wholeword=Whole+words+only.&table_display=true&lookup=exo" 2:31;?>exo 2:31;</a></p>

 

Thank you in advance for any replies.

Link to comment
Share on other sites

try

<?php
$ref[0] = "gen 1:12";
$ref[1] = "exo 2:31";
//foreach($ref as $value){
$value = implode(';',$ref);
echo '<a href=www.findthepower.net/CP/BibleSuperSearch/bible_supersearch.php?submit=true&version=kjv&searchtype=All+Words&search=&wholeword=Whole+words+only.&table_display=true&lookup='.$value.'">'.$value.'</a>';
//};
?>

Link to comment
Share on other sites

Thank you sasa for the response.

 

The generated hyperlink is still not what I need. I need a hyperlink as follows.

 

<a href="http://www.findthepower.net/CP/BibleSuperSearch/bible_supersearch.php?submit=true&version=kjv&searchtype=All+Words&search=&wholeword=Whole+words+only.table_display=true&lookup=gen1:12;exo 2:31;"?>SEARCH</a>

 

The problem hyperlink generated by the code is below.

 

http://www.findthepower.net/CP/BibleSuperSearch/bible_supersearch.php?submit=true&version=kjv&searchtype=All+Words&search=&wholeword=Whole+words+only&table_display=true&lookup=gen

 

Can anyone help with the code to generate the hyperlink with

=gen1:12;exo 2:31;"?>SEARCH</a>

on the end of the hyperlink?

 

Thank you in advance for any replies.

Link to comment
Share on other sites

if you want to remove 1st space use

$value = str_replalace(' ', '', implode(';',$ref),1);

if you want to remove all spaces use

$value = str_replalace(' ', '', implode(';',$ref));

if you want to pass spaces use

$value = str_replalace(' ', '+', implode(';',$ref));

sorry i don't see spaces in ref array in first time

Link to comment
Share on other sites

Thank you sasa for the comment. Unfortunately, none of your suggestions put the proper ending on the generated html statement. I need the ending of the html hyperlink to be like

 

&lookup=gen 1:12;exo 2:31;"?>SEARCH</a>

 

The space in the hyperlink at the end is not an issue. I need the space but I also need for the end of the generated hyperlink to be derived from the $ref values like what I have show above. In actual practice, there can be over hundred $ref values. All of the $ref values must go at the end of the hyperlink.

 

Your suggestions also generated an extra directory name as shown below. There is only one directory labeled CP. For some reason, your suggestions generated /CP/CP.

 

Thank you again for the comments.

 

Here are your suggestions and the hyperlink the suggested code created.

 

$value = str_replace(' ', '+', implode(';',$ref));

 

http://www.findthepower.net/CP/CP/BibleSuperSearch/bible_supersearch.php?submit=true&version=kjv&searchtype=All+Words&search=&wholeword=Whole+words+only.&table_display=true&lookup=gen

 

$value = str_replace(' ', '+', implode(';',$ref));

 

http://www.findthepower.net/CP/CP/BibleSuperSearch/bible_supersearch.php?submit=true&version=kjv&searchtype=All+Words&search=&wholeword=Whole+words+only.&table_display=true&lookup=gen

 

$value = str_replace(' ', '+', implode(';',$ref));

 

http://www.findthepower.net/CP/CP/BibleSuperSearch/bible_supersearch.php?submit=true&version=kjv&searchtype=All+Words&search=&wholeword=Whole+words+only.&table_display=true&lookup=exo

Link to comment
Share on other sites

Have you tried urlencode to format the url?

 

 



$ref[0] = "gen 1:12";
$ref[1] = "exo 2:31";

$value = "";
foreach( $ref as $v )
{
$value .= "$v;";
}
echo '<a href="http://www.findthepower.net/CP/BibleSuperSearch/bible_supersearch.php?submit=true&version=kjv&searchtype=All+Words&search=&wholeword=Whole+words+only.&table_display=true&lookup='.urlencode($value).'">'.$value.'</a>';


 

 

You want the semi colon at the end of $value, so implode wouldn't have worked. You had the right idea by using a loop.

 

 

Link to comment
Share on other sites

Thank you rlindauer.

 

I tried your code but came up with the same result. Improper ending on the hyperlink and two CP directories. Do you have any other suggestions? Thank you again.

 

Here is the url generated.

 

http://www.findthepower.net/CP/CP/BibleSuperSearch/bible_supersearch.php?submit=true&version=kjv&searchtype=All+Words&search=&wholeword=Whole+words+only.&table_display=true&lookup=exo

Link to comment
Share on other sites

Biblical are we? Mind sharing the link to the site? mine is http://dennisbillings.com

 

if you want both elements of the array to be displayed you don't need a loop

 

<?php
$ref[0] = "gen 1:12";
$ref[1] = "exo 2:31";

echo "<a href=www.findthepower.net/CP/BibleSuperSearch/bible_supersearch.php?submit=true&version=kjv&searchtype=All+Words&search=&wholeword=Whole+words+only.&table_display=true&lookup=$ref[0];$ref[1];>$ref[0];$ref[1]</a>";
};
?>

 

I have a feeling your looking for something different but I'm not really clear on what.

Link to comment
Share on other sites

Thank you. No, I think will need a loop. I have groups of verses of indeterminant length throughout the site. I want to make a way for users to click on a single link or links within each record of the db and pull up the verses in an online bible program. If you go to the concordance part of the site in the url, you will see what I mean. Can you give me any suggestions. Thank you again.

Link to comment
Share on other sites

Thank you rlindauer.

 

I tried your code but came up with the same result. Improper ending on the hyperlink and two CP directories. Do you have any other suggestions? Thank you again.

 

Here is the url generated.

 

http://www.findthepower.net/CP/CP/BibleSuperSearch/bible_supersearch.php?submit=true&version=kjv&searchtype=All+Words&search=&wholeword=Whole+words+only.&table_display=true&lookup=exo

 

Strange, it worked perfect for me and I got the result exactly like you wanted it.

 

Did you add the urlencode to the value in the echo statement?

 

urlencode($value)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.