Note that there are some explanatory texts on larger screens.

plurals
  1. POfill SQL empty database value with result from second table (PHP)
    text
    copied!<p>Ok, so i'm not sure if i'm going about this a completely horrid way. However, i'm basically trying to create a movie database for my room mates to show what content we have on our server and to easily check this out.</p> <p>I have created a database that is automatically updated using the xml feed from our plex server, however there is one small bit that has been bugging me all night.</p> <p>I'm trying to create a slider for recently added content, but when it comes to a "summary", films add there summaries to my "recent" table, where as tv episodes do not (not sure why plex's xml goes like this but im trying to work around it). the TV episodes have there summary in the "episodes" table.</p> <p>What i'm trying to do is loop through the recent table and if the "recent"->"Desc" field is empty, pull content from "episodes"->"Desc" instead (matching by show title)</p> <p>The code I have for this loop so far is:</p> <pre><code>&lt;?php $con=mysqli_connect("localhost","","","plex"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $recent = mysqli_query($con,"SELECT * FROM recent LIMIT 0, 6"); $shows = mysqli_query($con,"SELECT * FROM shows"); while($row = mysqli_fetch_array($recent)) { $art = $row['Art']; $title = $row['Title']; if (empty($row['Desc'])){ /* STUCK HERE*/ } else { $summary = $row['Desc']; } echo "&lt;img src='$art.jpg' alt='$summary' title='$title' /&gt;"; } mysqli_close($con); ?&gt; </code></pre> <p>And my tables look like:</p> <pre><code>**********episodes********************** **********recent************* **************************************** ***************************** *id**eptitle**showtitle**desc*thumb*art* *id**Title**Desc**thumb**art* * ** ** ** * * * * ** ** ** ** * </code></pre> <p>I will do my best to clarify on anything that isn't clear (it's late, you know :P)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload