Search the Community
Showing results for tags 'ternary operator'.
After reading this book and practicing, I am creating a site that has more than one main logo, I want them to alternate when the page changes to another page or is refreshed. So I thought of using the ternary operator, but I can't get it to work. Since there is no while loop involved in my header page where this code will go, I guess that's why it doesn't work. I got it to work with php's shuffle function, but that doesn't create the effect I want exactly. Anyways here is where I am at with this, any help to get this working would be appreciated. <header> $imglogo1 = '<img src="i
grahamgr3 posted a topic in PHP for the Web: Visual QuickStart Guide (4th Edition)In chapter 10, in pagination, I am having trouble understanding why the background colors of the table will alternate based on the ternary operator used. I don't understand why $bg will change from #eeeeee to #ffffff. Before the ternary operator $bg is set to #eeeeee, and I don't see how that will change based on the code. Here is the code. $q = "SELECT last_name, first_name, DATE_FORMAT(registration_date, '%M %d, %Y') AS dr, user_id FROM users ORDER BY registration_date ASC LIMIT $start, $display"; $r = @mysqli_query ($dbc, $q); echo '<table align="center" cellspacing="0" cellpadding="