Jump to content
Larry Ullman's Book Forums

chadwick37

Members
  • Content Count

    5
  • Joined

  • Last visited

Community Reputation

0 Neutral

About chadwick37

  • Rank
    Newbie
  1. I Is this really the answer? I will test it. If it is I am even more confused. This is the code I used from the book and it worked. So why would that parenthesis need to be moved? //Fetch and print all the records… $bg = '#eeeeee'; //Set the initial background color. while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) { $bg = ($bg=='#eeeeee' ? '#ffffff' : '#eeeeee'); //Switch the background color. echo '<tr bgcolor="' . $bg . '"> <td align="left"><a href="edit_user.php?id=' . $row['user_id'] . '">Edit</a></td> <td align="left"><a href="delete
  2. I had thought of that too so I tried defining $bg above it but it didn't make any difference.
  3. Here is a piece of the source, you can see what gets output in the table rows. Visually, all the cells are black. <table> <tr bgcolor="#ffffff"> <td>First Name</td><td>Second Name</td><td>Last Name 1</td><td>Last Name 2</td><td>Sponsor First Name</td><td>Sponsor Last Name </td> </tr> <tr bgcolor="#ffffff"> <td>Doris</td><td>Vicenta</td><td>Munguia</td><td>Garcia</td><td>Ore Creek</td><td>Community Church High School
  4. So I'm trying to apply some of the lessons in the book to a real world application so I am trying to apply the ternary operator just like it was used in the book but in a more complicated script. Here is the script and it isn't working. I think I might have a syntax issue but I can't figure it out. Any ideas? // Start result table printed to browser if ($_GET['rep1'] == TRUE) { $numberFields = mysql_num_fields($q); // Find out how many fields we are fetching if($numberFields) { // Check if we need to output anything for($i=0; $i<$numberFields; $i++) { $keys[] = mysql_field_name($q,
  5. I am trying to understand how this script works, particularly the email conditional. Here is the code I'm trying to get my head around: //Make the query: $q = "UPDATE users SET first_name='$fn', last_name='$ln', email='$e' WHERE user_id=$id LIMIT 1"; $r = @mysqli_query ($dbc, $q); if (mysqli_affected_rows($dbc) == 1) { // If it ran OK. //Print a message: echo '<p>The user has been edited.</p>'; } else { // If it did not run OK. echo '<p class="error">The user could not be edited due to a system error. We apologize for any inconvenience.</p>'; //Public message.
×
×
  • Create New...