Hi, i'm doing a website where the user can add his favourite bands in his profile. But not every band is in the DB, so if the band isn't in the DB it adds the name in the column.
this is what i have:
if(mysql_query("INSERT INTO bandas_fav(band_fav_id_user, band_fav_id_banda) VALUES('".$_GET['iduser']."', '".$bands_name['banda_id']."')"))
{
//Record was successfully inserted, respond result back to index page
$my_id = mysql_insert_id(); //Get ID of last inserted row from MySQL
$query_band_add=mysql_query("SELECT * FROM bandas WHERE banda_id='".$my_id."'", $con);
$band_add=mysql_fetch_assoc($query_band_add);
if(mysql_num_rows($query_band_add)!=0){
echo '<li id="item_'.$my_id.'" style="float:left; border:1px solid #000; width:20%; margin-right:10px; margin-bottom:10px;">';
echo '<div class="del_wrapper"><a href="#" class="del_button" id="del-'.$my_id.'">';
echo '<img src="icon_del.gif" border="0" />';
echo '</a></div>';
echo '<div style="float:left; width:110px;"> <img src="../../'.$band_add['banda_logotipo'].'" width="100" style="margin-right:5px;" /></div>';
echo '<div style="float:left; width:50px;"> <a href="../band_one.php?idbnd='.$band_add['banda_id'].'">'.$band_add["banda_nome"].'</a></div>'.'</li>';
mysql_close($con); //close db connection
}
else{
if(mysql_query("INSERT INTO bandas_fav(new_band) VALUES('".$contentToSave."') WHERE band_fav_id='".$my_id."'")){
echo '<li id="item_'.$my_id.'" style="float:left; border:1px solid #000; width:20%; margin-right:10px; margin-bottom:10px;">';
echo '<div class="del_wrapper"><a href="#" class="del_button" id="del-'.$my_id.'">';
echo '<img src="icon_del.gif" border="0" />';
echo '</a></div>';
echo '<div style="float:left; width:110px;"> <img src="http://cache.gawkerassets.com/assets/images/9/2011/01/rock-band-2-wii.jpg" width="100" height="100" style="margin-right:5px;" /></div>';
echo '<div style="float:left; width:50px;"> '.$contentToSave.'</div>'.'</li>';
mysql_close($con); //close db connection
}
else{
echo mysql_error();
}
}
}