Jump to content

help with query


nepzap2

Recommended Posts

First I want to thank all of you for all your help.

 

I need a little help with this query, I'm trying to check if the column "active" in the sa_events table has any rows with the word yes to print otherwize print all the other rows that have the word no. My query prints the row with the word yes in the active column but when I delete it it does not print it doesn't print the row with the word no.

 

Any help is greatly appreciated.

 

Below is my code.

 

Thanks

 


<?php
		include 'zdb_config.php';

		$data = mysql_query("SELECT * 
							 FROM sa_events
							 WHERE sa_events.active = 'yes'")
		or die(mysql_error());

		while($info = mysql_fetch_array($data))


			if ($data) {
				print "<p style='line-height: 12px;'>" .$info['id']. "<br />" 
							.$info['title']. "<br />" 
							.$info['date_time']. "<br />"
							.$info['category']. "<br />"
							.$info['speaker']. "<br />"
							.$info['room']. "<br />"
							.$info['description']. "</p>"; 

			} else {

				$data = mysql_query("SELECT * 
									 FROM sa_events
									 WHERE sa_events.active = 'no'")
				or die(mysql_error());

				while($info = mysql_fetch_array($data))

				print "<p style='line-height: 12px;'>" .$info['id']. "<br />" 
							.$info['title']. "<br />" 
							.$info['date_time']. "<br />"
							.$info['category']. "<br />"
							.$info['speaker']. "<br />"
							.$info['room']. "<br />"
							.$info['description']. "</p>";
			}

	?>

Link to comment
https://forums.phpfreaks.com/topic/140856-help-with-query/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.