forumnz Posted May 5, 2007 Share Posted May 5, 2007 Ok here is some of my script. I have just altered it so that if the row 'on' in the database 'mag' is '1' then it will echo... else it will echo... Problem is, it just doesn't echo anything at all. - Yes the db is set to 1 Thanks a bunch! <?php // Make a MySQL Connection mysql_connect("localhost", "photomagik", "***") or die(mysql_error()); mysql_select_db("photomagik_co_nz_-_soho") or die(mysql_error()); // Get all the data from the "example" table $result = mysql_query("SELECT * FROM mag WHERE id='1'") or die(mysql_error()); // keeps getting the next row until there are no more to get while($row = mysql_fetch_array( $result )) { // Print out the contents of each row into a table if ($on == 1) echo "<a href=" . $row['stg2'] . "><img src=" . $row['stg1'] . " class=float /><br /> <div align=center><p>" . $row['stg3'] . " </p></div></a>"; else echo ""; } ?> Link to comment https://forums.phpfreaks.com/topic/50074-solved-ifelse/ Share on other sites More sharing options...
genericnumber1 Posted May 5, 2007 Share Posted May 5, 2007 if it's from the database you would use $row['on'] not $on Link to comment https://forums.phpfreaks.com/topic/50074-solved-ifelse/#findComment-245767 Share on other sites More sharing options...
benjaminbeazy Posted May 5, 2007 Share Posted May 5, 2007 you're missing a close bracket at the end of your code... and an opening after if($on == 1) nevermind, my bad... though it is always a good idea to use braces for conditionals, just so you don't get lost Link to comment https://forums.phpfreaks.com/topic/50074-solved-ifelse/#findComment-245778 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.