Jump to content

Condition Help.


nepzap2

Recommended Posts

I have a script that reads from a MYSQL database.

 

I want to be able to create a condition that checks to see if there is a url associated with a title of a publication. If there is then make the title a link, if not just print the title.

 

Here is what I had so far, But its not working. Any help is greatly appreciated.

 


<?php
					include 'db_config.php';


								 // Collects data from "test" table
								$data = mysql_query("SELECT * 
													from pubs
													WHERE pi LIKE '$name' AND label = 'S'
													ORDER by year DESC")
								or die(mysql_error());

								 // Print out the contents of the entry


									while($info = mysql_fetch_array($data)) {

										if($info['url'] = "") {

											print '<p>'.$info['author_1'].',  
												  ' .$info['author_2'].'. 
												  ' .$info['year'].'.  
												  ' .$info['title_secondary'].'
												  ' .$info['volume'].':  
												  ' .$info['pages'].'</p>';
										}

										else {

											print '<p>' .$info['author_1'].',  
										      ' .$info['author_2'].'. 
											  ' .$info['year'].'. 
											  <a rel="external" href="' .$info['url']. '">'.$info['title'].'</a>. 
											  ' .$info['title_secondary'].'
											  ' .$info['volume'].':  
											  ' .$info['pages'].'</p>';
											  
										}

									} 


					?>

Link to comment
https://forums.phpfreaks.com/topic/108997-condition-help/
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.