"Phillip B. Bruce" wrote:
> Hi,
>
> Look at the code below first:
>
> <?php
> 2
> 3 include "include_fns.php";
> 4 include "header_news.php";
> 5
> 6 $conn = db_connect();
> 7
> 8 $pages_sql = "select * from pages order by code";
> 9 $pages_result = mysql_query($pages_sql, $conn);
> 10
> 11 while ($pages = mysql_fetch_array($pages_result)) {
> 12
> 13 $story_sql = "select * from stories
> 14 where page = '$pages[code]'
> 15 and published is not null
> 16 order by published desc";
> 17 $story_result = mysql_query($story_sql, $conn);
> 18 if (mysql_num_rows($story_result)) {
> 19 $story = mysql_fetch_array($story_result);
> 20 print "<TABLE border=\"1\" width=685>";
> 21 print "<TR>";
> 22 print "<TD width=\"50%\">";
> 23 print "<H3>$pages[description]</H3>";
> 24 print $story[headline];
> 25 print "</TD>";
> 26 print "<TD ALIGN=RIGHT>";
> 27 print " ";
> 28 print "</TD>";
> 29 print "</TR>";
> 30 print "</TABLE>";
> 31 }
> 32 }
> 33
> 34 include "footer_news.php";
> 35 ?>
>
> My problem is that I want to do the following:
>
> ==========================================
>
> |
> |
> =========================================
> |
> | |
> ==========================================
> |
> | |
> =========================================
>
> So I thought a neat trick would be to before line 22 the following:
>
> if ( $pages[code]="intro")
> print "<TD >";
> else
> print "<TD width=\"50%\">";
>
> The objective would be to have a whole row by like I describe above.
> The thing is I don't want to write the same routine just for that
> one row
> and by that I mean put in another mysql call to the database.
>
> Suggestion?
>
> --
> ************************************************************
> *** Phillip B. Bruce ***
> *** http://pbbruce.home.mindspring.com ***
> *** [EMAIL PROTECTED] ***
> *** ***
> *** "Have you ever noticed? Anybody going slower than ***
> *** you is an idiot, and anyone going faster than you ***
> *** is a maniac." - George Carlin ***
> ************************************************************
Hi,
Group I've solved this problem myself and for those interested here is
what I did to resolve it.
<?php
include "include_fns.php";
include "header_news.php";
$conn = db_connect();
$pages_sql = "select * from pages order by code";
$pages_result = mysql_query($pages_sql, $conn);
while ($pages = mysql_fetch_array($pages_result)) {
$story_sql = "select * from stories
where page = '$pages[code]'
and published is not null
order by published desc";
$story_result = mysql_query($story_sql, $conn);
if (mysql_num_rows($story_result)) {
$story = mysql_fetch_array($story_result);
print "<TABLE border=\"1\" width=685>";
if ( $pages[code] == "Intro" ){
print "<TR>";
print "<TD>";
print "<H3>$pages[description]</H3>";
print $story[headline];
print "</TD>";
print "</TR>";
}
else {
print "<TR>";
print "<TD width=\"50%\">";
print "<H3>$pages[description]</H3>";
print $story[headline];
print "</TD>";
print "<TD ALIGN=RIGHT>";
print "<H3>$pages[description]</H3>";
print $story[headline];
print "</TD>";
print "</TR>";
}
print "</TABLE>";
}
}
include "footer_news.php";
?>
My orginal problem was that I was using lower case intro and not Intro
what I put into
the database. Which was a stupid oversite on my part. Now this cose will
only create
a <TD></TD> when it sees Intro and not a pair of <TD></TD>. I'm truly
starting to
like php a lot.
--
************************************************************
*** Phillip B. Bruce ***
*** http://pbbruce.home.mindspring.com ***
*** [EMAIL PROTECTED] ***
*** ***
*** "Have you ever noticed? Anybody going slower than ***
*** you is an idiot, and anyone going faster than you ***
*** is a maniac." - George Carlin ***
************************************************************
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]