Posted: Thu Aug 31, 2006 7:16 pm
Before the second query, echo out $section_id. See what comes of it.
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
When you first created the thread has little baring on what I said.blade_922 wrote:lol 38 minutes? Look when i first posted this thread.
I highly suggest you do not break that rule, or any others, in the near future.[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:4. All users of any level are restricted to bumping (as defined here) any given thread within twenty-four (24) hours of its last post. Non-trivial posts are not considered bumping. A bump post found in violation will be deleted, and you may or may not recieve a warning. Persons bumping excessively be considered as spammers and dealt with accordingly.
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
you mean do thisCode: Select all
/* More than one, we need an array */
unset($sectionid);
echo $sectionid = array();
while ($row = mysql_fetch_array($system))
{
$sectionid[]['sectionid'] = $row['sectionid'];
}
}
elseCode: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]Code: Select all
tags when posting PHP. Seeing code in plain text is really unnerving and hard to read.Code: Select all
{
/* More than one, we need an array */
unset($sectionid);
$sectionid = array();
while ($row = mysql_fetch_array($system))
{
$sectionid[]['sectionid'] = $row['sectionid'];
}
}Code: Select all
<?php
foreach ($section_id as $value)
{
echo 'This section id is ' . $value . '!<br /><br />';
}
/* Or, to use a for loop */
$section_id_count = count($section_id);
for ($i = 0; $i < $section_id_count; $i++)
{
echo 'This section id is ' . $section_id[$i]['section_id'] . '!<br /><br />';
}
?>Code: Select all
<?php
/* Decalre this var here, though it may change */
$sectionid = 0;
/* Query for the section id(s) */
/* To make this a single section id, use a WHERE `sectionid` = something */
$system = mysql_query("select `sectionid` from `mos_content`") or die(mysql_error());
/* Check to see if there is a result */
if ($row_count = mysql_num_rows($system))
{
/* There is, so lets do some assigning */
/* But wait, is it one or many results? */
if ($row_count > 1)
{
/* More than one, we need an array */
unset($sectionid);
$sectionid = array();
while ($row = mysql_fetch_array($system))
{
$sectionid[]['sectionid'] = $row['sectionid'];
}
}
else
{
/* There is only one value, so set it */
while ($row = mysql_fetch_array($system))
{
$sectionid = $row['sectionid'];
}
}
}
/**
* At this point, section_id will either be set to an array
* or to a single value based on the result returned by
* the OR
*
* section_id will be the default value, 0
*
*/
$sql= mysql_query("Select * from mos_content");
if ( $sectionid==1)
{
echo '<td class="contentheading' . $params->get('pageclass_sfx') . '" width="90%" >';
}
elseif ( $sectionid==18)
{
echo '<td class="contentheadingps3' . $params->get('pageclass_sfx') . '" width="90%">';
} else {
echo '<td class="contentheading' . $params->get('pageclass_sfx') . '" width="90%">';
}
?>Code: Select all
<?php
$system = mysql_query("select * from mos_content") or die(mysql_error());
while ($donnee = mysql_fetch_array($system))
{
if ( 18 == $donnee['sectionid'] )
{
/* Do what you want in here if section id is 18 */
}
else
{
/* Otherwise, do something else in here */
}
}
?>Code: Select all
<?php
$system = mysql_query("select * from mos_content") or die(mysql_error());
while ($donnee = mysql_fetch_array($system))
{
if ( 1 == $donnee['sectionid'] )
{
echo '<td class="contentheading' . $params->get('pageclass_sfx') . '" width="90%" >';
}
else
{
echo '<td class="contentheadingps3' . $params->get('pageclass_sfx') . '" width="90%">';
}
}
?>Code: Select all
<?php
$system = mysql_query("select * from mos_content") or die(mysql_error());
$donnee = mysql_fetch_array($system);
if ( 1 == $donnee['sectionid'] )
{
echo '<td class="contentheading' . $params->get('pageclass_sfx') . '" width="90%" >';
}
else
{
echo '<td class="contentheadingps3' . $params->get('pageclass_sfx') . '" width="90%">';
}
?>Code: Select all
<?php
$system=mysql_query("select * from mos_content") or die(mysql_error());
while ($donnee = mysql_fetch_array($system))
{ $donnee= $donnee['sectionid']; }
for ($i=1; $i<=1; $i++)
{
if ( 1==$donnee['sectionid'] )
echo '<td class="contentheading' . $params->get('pageclass_sfx') . '" width="90%" >';
else
echo '<td class="contentheadingps3' . $params->get('pageclass_sfx') . '" width="90%">';
}
?>Code: Select all
<?php
/* Set the var $system equal to the resource ID of this query */
$system=mysql_query("select * from mos_content") or die(mysql_error());
/* Regardless of how many records there are in the result */
/* use the last record in the result */
while ($donnee = mysql_fetch_array($system))
{ $donnee= $donnee['sectionid']; }
/* Run a single iteration (one loop) */
for ($i=1; $i<=1; $i++)
{
/* See if the value of this non-existent array var is 1 */
if ( 1==$donnee['sectionid'] )
echo '<td class="contentheading' . $params->get('pageclass_sfx') . '" width="90%" >';
else
/* This line will always display because of the way your code runs */
echo '<td class="contentheadingps3' . $params->get('pageclass_sfx') . '" width="90%">';
}
?>