jarv Posted May 29, 2013 Share Posted May 29, 2013 $sql2 = "SELECT * FROM pages INNER JOIN bgimages ON pages.BGimageID=bgimages.BGimageID"; $result2 = mysql_query($sql2); <?php while($row2 = mysql_fetch_array($result2)) { if($row2['pages.BGimageID'] == $row2['bgimages.BGimageID']){ echo '<input type="radio" name="BGimageID" value="'.$row2['BGimageID'].'" checked /><img src="../images/'.$row2['BGimage'].'" width="150" />'; } else { echo '<input type="radio" name="BGimageID" value="'.$row2['BGimageID'].'" /><img src="../images/'.$row2['BGimage'].'" width="150" />'; } } ?> Link to comment https://forums.phpfreaks.com/topic/278562-undefined-index-pagesbgimageid-and-bgimagesbgimageid/ Share on other sites More sharing options...
dannon Posted May 29, 2013 Share Posted May 29, 2013 There are no pages.BGimageID and bgimages.BGimageID keys in your $row2 array. You need to use mysql_fetch_assoc, instead of mysql_fetch_array. Link to comment https://forums.phpfreaks.com/topic/278562-undefined-index-pagesbgimageid-and-bgimagesbgimageid/#findComment-1433002 Share on other sites More sharing options...
jarv Posted May 29, 2013 Author Share Posted May 29, 2013 thanks, I just changed that and still get the same error?! Link to comment https://forums.phpfreaks.com/topic/278562-undefined-index-pagesbgimageid-and-bgimagesbgimageid/#findComment-1433007 Share on other sites More sharing options...
dannon Posted May 29, 2013 Share Posted May 29, 2013 Do print_r($row2) to check what you are receiving from the query. I don't think you need the 'pages.' and 'bgimages.' here: if($row2['pages.BGimageID'] == $row2['bgimages.BGimageID']){ Link to comment https://forums.phpfreaks.com/topic/278562-undefined-index-pagesbgimageid-and-bgimagesbgimageid/#findComment-1433008 Share on other sites More sharing options...
jarv Posted May 29, 2013 Author Share Posted May 29, 2013 print_r($row2) outputs an array of what is in the database I think the problem lies where I am trying to join the 2 tables I just want to check if BGimageID in Pages table is the same as BGimageID is the same as the one in bgimages table and if it is then CHECK the radio button Link to comment https://forums.phpfreaks.com/topic/278562-undefined-index-pagesbgimageid-and-bgimagesbgimageid/#findComment-1433010 Share on other sites More sharing options...
dannon Posted May 29, 2013 Share Posted May 29, 2013 Are pages.BGimageID and bgimages.BGimageID in your $row2 array? If not then you might not be joining the tables correctly. Link to comment https://forums.phpfreaks.com/topic/278562-undefined-index-pagesbgimageid-and-bgimagesbgimageid/#findComment-1433016 Share on other sites More sharing options...
jarv Posted May 29, 2013 Author Share Posted May 29, 2013 no, they are not there Link to comment https://forums.phpfreaks.com/topic/278562-undefined-index-pagesbgimageid-and-bgimagesbgimageid/#findComment-1433025 Share on other sites More sharing options...
jarv Posted May 29, 2013 Author Share Posted May 29, 2013 can anyone help me with the sql please? Link to comment https://forums.phpfreaks.com/topic/278562-undefined-index-pagesbgimageid-and-bgimagesbgimageid/#findComment-1433062 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.