$result = mysql_query()

前端 未结 2 1193
情歌与酒
情歌与酒 2020-12-18 10:40

I am brand new to php/mysql, so please excuse my level of knowledge here, and feel free to direct me in a better direction, if what I am doing is out of date.

I am p

2条回答
  •  抹茶落季
    2020-12-18 11:06

    It is hard to help without knowing more. You are pumping the results into an array, are you expecting to only return one result or many banner_headline results? If you will only ever get one result then all you need to do is something like this:

    PHP:

    $result = mysql_query("
        SELECT `banner_headline`
        FROM `low_engagement`
        WHERE `thread_segment` = 'a3'", $connection) or die(mysql_error());
    // This will get the zero index, meaning first result only
    $alt = mysql_result($result,0,"banner_headline");
    

    HTML:

    
    
    
    <?php echo $alt ?>
    

    On a side note, you should stop using mysql-* functions, they are deprecated.
    You should look into PDO or mysqli

提交回复
热议问题