PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
SidewinderX
Forum Contributor
Posts: 407 Joined: Fri Jul 16, 2004 9:04 pm
Location: NY
Post
by SidewinderX » Sat Oct 09, 2004 4:36 pm
hello i have a code ive been messing around for a bit, the code is suppose to generate a table and but the data in each one of the tebles rows as opposed to creating a new table for eack piece of data...i know it is doing this because the table is inside a loop, but there are so many it is confusing the heck out of me, so if someone could tell me the proper place to place what that would be awesome.
Here is the code:
Code: Select all
<?php
$result3 = $db->sql_query("SELECT title, custom_title, view FROM " . $prefix . "_modules WHERE active='1' AND title!='$def_module' AND inmenu='1' ORDER BY custom_title ASC");
while ($row3 = $db->sql_fetchrow($result3)) {
$m_title = stripslashes($row3['title']);
$custom_title = $row3['custom_title'];
$view = intval($row3['view']);
$m_title2 = ereg_replace("_", " ", $m_title);
if ($custom_title != "") {
$m_title2 = $custom_title;
}
if ($m_title != $main_module) {
if ((is_admin($admin) AND $view == 2) OR $view != 2) {
$content .= "<table border="0" width="100%">";
$content .= "<tr><td background="themes/OrangeT3mplate/images/button.jpg" height="10"><big>·</big></strong> <a href="modules.php?name=$m_title">$m_title2</a></td></tr>\n";
$content .= "</table>";
}
}
}
?>
The tables im talking about are on lines 13-15
Thanks,
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sat Oct 09, 2004 5:20 pm
uh.. move the table creation and termination outside the loop. not hard.
woo! 5000 posts!@!#$@
Last edited by
feyd on Sat Oct 09, 2004 5:34 pm, edited 1 time in total.
SidewinderX
Forum Contributor
Posts: 407 Joined: Fri Jul 16, 2004 9:04 pm
Location: NY
Post
by SidewinderX » Sat Oct 09, 2004 5:24 pm
but there are so many it is confusing the heck out of me
John Cartwright
Site Admin
Posts: 11470 Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:
Post
by John Cartwright » Sat Oct 09, 2004 5:26 pm
i'll give you a hint...
[php_man]while[/php_man] is the beginning of the loop
and content .= <table>
and content .= </table> parts should not be in it!!
i have faith in your ability!!!
mudkicker
Forum Contributor
Posts: 479 Joined: Wed Jul 09, 2003 6:11 pm
Location: Istanbul, TR
Contact:
Post
by mudkicker » Sat Oct 09, 2004 5:56 pm
out of subject i have a question in this code sidewinderx used in a if() AND & OR..
is it better to use && and || or AND and OR ???
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sat Oct 09, 2004 5:57 pm
pretty much, as long as it's consistent, it doesn't matter.
technically, the word versions have differing precedence from the symbol versions.
mudkicker
Forum Contributor
Posts: 479 Joined: Wed Jul 09, 2003 6:11 pm
Location: Istanbul, TR
Contact:
Post
by mudkicker » Sat Oct 09, 2004 6:00 pm
what do you mean by "differing precedence"
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sat Oct 09, 2004 6:01 pm
mudkicker
Forum Contributor
Posts: 479 Joined: Wed Jul 09, 2003 6:11 pm
Location: Istanbul, TR
Contact:
Post
by mudkicker » Sat Oct 09, 2004 6:06 pm
AND is not the same like &&
for example:
is not the same like
the first thing is
(a and b) or c
the second
a and (b or c)
'cause || has got a higher priority than and, but less than &&
of course, using always [ && and || ] or [ AND and OR ] would be okay, but than you should at least respect the following:
Code: Select all
<?php $a = $b && $c; ?>
<?php $a = $b AND $c; ?>
the first code will set $a to the result of the comparison $b with $c, both have to be true, while the second code line will set $a like $b and THAN - after that - compare the success of this with the value of $c
maybe usefull for some tricky coding and helpfull to prevent bugs
greetz, Warhog
that made everything clear, thanks.
m3mn0n
PHP Evangelist
Posts: 3548 Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada
Post
by m3mn0n » Sun Oct 10, 2004 12:07 am
feyd wrote: woo! 5000 posts!@!#$@
Congrats.
</off-topic>