HowdeeDoodee Posted July 16, 2007 Share Posted July 16, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/60262-solved-need-help-changing-for_each-with-generated-hyperlink/ Share on other sites More sharing options...
sasa Posted July 16, 2007 Share Posted July 16, 2007 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>'; //}; ?> Quote Link to comment https://forums.phpfreaks.com/topic/60262-solved-need-help-changing-for_each-with-generated-hyperlink/#findComment-299751 Share on other sites More sharing options...
HowdeeDoodee Posted July 16, 2007 Author Share Posted July 16, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/60262-solved-need-help-changing-for_each-with-generated-hyperlink/#findComment-299797 Share on other sites More sharing options...
sasa Posted July 16, 2007 Share Posted July 16, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/60262-solved-need-help-changing-for_each-with-generated-hyperlink/#findComment-299807 Share on other sites More sharing options...
HowdeeDoodee Posted July 16, 2007 Author Share Posted July 16, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/60262-solved-need-help-changing-for_each-with-generated-hyperlink/#findComment-299908 Share on other sites More sharing options...
rlindauer Posted July 16, 2007 Share Posted July 16, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/60262-solved-need-help-changing-for_each-with-generated-hyperlink/#findComment-299934 Share on other sites More sharing options...
HowdeeDoodee Posted July 17, 2007 Author Share Posted July 17, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/60262-solved-need-help-changing-for_each-with-generated-hyperlink/#findComment-299941 Share on other sites More sharing options...
dbillings Posted July 17, 2007 Share Posted July 17, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/60262-solved-need-help-changing-for_each-with-generated-hyperlink/#findComment-299942 Share on other sites More sharing options...
HowdeeDoodee Posted July 17, 2007 Author Share Posted July 17, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/60262-solved-need-help-changing-for_each-with-generated-hyperlink/#findComment-299948 Share on other sites More sharing options...
dbillings Posted July 17, 2007 Share Posted July 17, 2007 First you need to figure out how they will select multiple versus at once which is what you are essentially doing with multiple values for the lookup variable. Quote Link to comment https://forums.phpfreaks.com/topic/60262-solved-need-help-changing-for_each-with-generated-hyperlink/#findComment-299955 Share on other sites More sharing options...
dbillings Posted July 17, 2007 Share Posted July 17, 2007 Are you familiar with regular expressions? Quote Link to comment https://forums.phpfreaks.com/topic/60262-solved-need-help-changing-for_each-with-generated-hyperlink/#findComment-299957 Share on other sites More sharing options...
dbillings Posted July 17, 2007 Share Posted July 17, 2007 Post a bigger chunk of code and we can make it happen. Are you using a mysql database? Quote Link to comment https://forums.phpfreaks.com/topic/60262-solved-need-help-changing-for_each-with-generated-hyperlink/#findComment-299969 Share on other sites More sharing options...
rlindauer Posted July 17, 2007 Share Posted July 17, 2007 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) Quote Link to comment https://forums.phpfreaks.com/topic/60262-solved-need-help-changing-for_each-with-generated-hyperlink/#findComment-299980 Share on other sites More sharing options...
HowdeeDoodee Posted July 17, 2007 Author Share Posted July 17, 2007 Thank you rlindauer, it is working now. I know this has never happened to anyone here before but I uploaded the file to one directory but used another by mistake. Thank you again. Quote Link to comment https://forums.phpfreaks.com/topic/60262-solved-need-help-changing-for_each-with-generated-hyperlink/#findComment-299989 Share on other sites More sharing options...
rlindauer Posted July 17, 2007 Share Posted July 17, 2007 Ah, hehe. Yeah, I have done that before. Definitely a bang-head-on-desk moment. I am glad it is working now. Quote Link to comment https://forums.phpfreaks.com/topic/60262-solved-need-help-changing-for_each-with-generated-hyperlink/#findComment-299990 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.