Forum Moderators: coopster
I would like to split this string into individual strings.
When it is entered into the db it is entered like this. widget, widget 1, widget 2, etc, etc.
So I would like it to be split at each comma if possible then linked to the corresponding widget page.
Does anyone know how to do this?
while ($i = mysql_fetch_array(mysql_query("select..."))){
$options = explode($i['field_name_here']);
foreach ($options as $option)
print "<a href=\"/folder/".trim($option).".php\"></a>";
while ($i = mysql_fetch_array(mysql_query("select..."))){
is that needed or could I just put
while ($i = $myrow['row']){
?
$options = explode($myrow['Zones']);
foreach ($options as $option)
print "<a href=\"/modules.php?name=Zone_Database&file=zone_detail&id=$myrow[id]/".trim($option)."\">".trim($option)."</a>";
and am getting two errors.
Wrong parameter count for explode()on line 49 which is the defining of options line and
Invalid argument supplied for foreach() on line 51 which is the foreach line.
Any ideas?
I will keep playing with it and look up both errors on php.net but if anyone has any feedback it would be greatly appreciated. Thanks
Dylan
This is my code after tampering with it.
$zone = $myrow['Zones'];
$options = explode(" ", $zone);
foreach ($options as $option)
print "<a href=\"modules.php?name=Zone_Database&file=zone_detail&id=".$myrow[id]."\">".($option)."</a>";
it is not fully operational but I am getting feedback now. But it is splitting everything into a link even if it is a word such as "Whale Hill" that turns to 2 links.
and I am not getting spaces after the commas but I am sure I can figure that out.
explode(",", $zone);
And if you want lose the extra space after the comma, just add it to the separator string.
explode(", ", $zone); //be sure there will always be a space!
Now I am trying to link to the related zones from the quest database.
This is the link I have
<a href=\"modules.php?name=Zone_Database&file=zone_detail&name=$option\">$option</a>
It looks perfect but I get
Sorry, such file doesn't exist...
When I click the link.
I recently changed the link structure from $id to $name, as soon as I did that I started getting this error.
Any ideas?
do {
print "<tr><td align=\"center\">";
echo '<b><a href="modules.php?name=$module_name&file=zone_detail&name=', $myrow['name'] ,'">', $myrow['name'] ,'</a></b>';
print "<br></td></tr>";
}
I need to link by name so that I can link from my quest database as well.
but I am still getting this "Sorry, such file doesn't exist..."
this is a link when clicked.
modules.php?name=$module_name&file=zone_detail&name=Broken%20Skull%20Rock
any suggestions.
if someone types in www.yoursite.com
then the main page of your site would be in
/usr/local/bin/php/home/eqoagui/public_html/
so the root relative path for the file you want to link to would be
/modules/Quest_Database/quest_detail.php
or
/modules/Quest_Database/index.php
why are you trying to link to modules.php? Which is the actual file, of these three, that you want the generated link to go to?
I would like the link to go from The index.php in the zone database and the item_detail.php in the item database to zone_detail.php$name=$zone
Now I looked at my address a minute ago and saw that there is?name=$module_name now if I have $name=$zone_name in there as well would?name and $name conflict, could that be causing my problems, because I have made many modules and this problem has never lasted this long.
Cheers Dylan
something I didn't notice before
echo '<b><a href="modules.php?name=$module_name&file=zone_detail&name=', $myrow['name'] ,'">', $myrow['name'] ,'</a></b>';
that won't resolve the variable $module_name because it is between single quotes. Just pop it out of the single quotes like so
echo '<b><a href="modules.php?name=',$module_name,'&file=zone_detail&name=', $myrow['name'] ,'">', $myrow['name'] ,'</a></b>';
If you're getting "No such file exists", then there is obviously a function that sends a 404 redirect if the data isn't on the up-and-up. Since you changed the link format, you upset the script because it's expecting id, not name.
I am now getting this error
"query 1: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'Cave' at line 1"
this is the address
"/modules.php?name=Zone_Database&file=zone_detail&zoneid=Bear%20Cave"
and this is the sql
$results = mysql_query("SELECT * FROM nuke_zones WHERE name=$zoneid",$link) or die ("query 1: " . mysql_error());
$myrow = mysql_fetch_array($results) or die ("query 2: " . mysql_error());