This one is confusing me. I have two different mySQL tables I need to pull information from and I am creating a html dropdown table and trying to populate the value from a variable. It works the first time through the loop, but not after that. I get a warning (when viewing the html):
b>Warning</b>: array_combine() expects parameter 1 to be array, integer given in <b>/MY URL</b> on line <b>56</b><br />
<br />
Easier to just show the code, so here it is:
$UserID = "118";
$UndefinedEvents = array();
$EventDates = array();
$UserTimelines = array();
$query = "SELECT * FROM events WHERE UserID='$UserID' AND ParentEventID IS NULL";
$result = mysql_query($query);
$query2 = "SELECT * FROM timelines WHERE UserID='$UserID'";
$result2 = mysql_query($query2);
//Getting the Timeline names and their IDs
while($row = mysql_fetch_array($result2))
{
$UserTimelines[] = $row['TimeLineName'];
$TimelineID[] = $row['TimeLineID'];
}
//Getting and events that have a NULL value
while($row = mysql_fetch_array($result))
{
echo $row['UserID'] . " ".$row['EventName']. " " . $row['ParentEventID'];
$UndefinedEvents[] = $row['EventName'];
$EventDates[] = $row['StartDate'];
}
//Iterating through events with NULL value and telling user which events are NULL
foreach (array_combine($UndefinedEvents, $EventDates) as $event=>$dates){
echo "This Event does not have a Timeline associated with it: " .$event . " on ".$dates. '<br>';
echo "Choose a Timeline:<br>";
?>
<select>
//THIS IS LINE 56: Iterating through the timelines and creating a dropdown for the user to choose a timeline.
<?php foreach (array_combine($TimelineID, $UserTimelines) as $TimelineID=>$timeline){
echo "<option value=".$TimelineID."> ".$timeline. "</option>";
}
echo " </select><br><br>";
}
?>
<?php
mysql_close($con);
?>
Like I said, it works the first loop, and is properly putting the values in, but each loop after just creates the above warning.
In your second foreach, you are overwriting your
$TimelineIDvariable:Just use something else like: