Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mysql query not working??

Status
Not open for further replies.

martinb7

Programmer
Joined
Jan 5, 2003
Messages
235
Location
GB
hi, I am geting news out of a db and putting it on a webpage. the table structure:

uid | show | title | news | subBy | subDate

::code::

Code:
 <?php

include (&quot;config.php&quot;);

$conn = mysql_connect($host, $user, $pass);
mysql_select_db($db, $conn);
$queryNewsMain = mysql_query(&quot;SELECT * FROM wnews where show= '1' ORDER by subDate DESC&quot;) or die(mysql_error());

while ($r = mysql_fetch_array($queryNewsMain)) {
  		$title = $r[&quot;title&quot;];
		$news = $r[&quot;news&quot;];
		$dp = $r[&quot;subDate&quot;];
		$sb = $r[&quot;subBy&quot;];
		

	echo(&quot;<font size=2>
<table width=400 border=0 cellspacing=0 cellpadding=0>
  <tr> 
    <td background=$midtop>
<div align=center><font color=$txtcolor size=2><b>-</b> $title <b>-</b></font></div></td>
  </tr>
  <tr> 
    <td background=$mid> 
      <div align=center><font color=$txtcolor size=2>$news</font></div></td>
  </tr>
  <tr> 
    <td background=$midbot>
<div align=center><font color=$txtcolor size=2>Submitted: $dp by $sb</font></div></td>
  </tr>
</table></font>&quot;).&quot;<br><br>&quot;;
}
echo(&quot;<font size=2><a href=archive.php>News Archive</a></font>&quot;);
?>

the query doesn't like the show = '1' bit.

what im trying to do is: if in the table its got 1 in the show colum, it will show the post else if its got '0' it wont.

Any ideas??

^^ link 4 query thats wrong ^^

thanx

Martin


also,is there a better way of listing data out of a db other than the while() loop? or anyother ways of using the while loop?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top