Re: Re: php and html image tag...

From: Date: Mon, 08 Apr 2002 15:23:47 +0000
Subject: Re: Re: php and html image tag...
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-92062@lists.php.net to get a copy of this message
I don't know if anybody else sent you an email about this or not, but there's a much easier way to do what you're doing in this snippet of code... $record = @mysql_query("SELECT wel_area, ad01, ad02, ad03, ad04, ad05, ad06, ad01_t, ad02_t, ad03_t, ad04_t, ad05_t, ad06_t FROM $table",$dbh); while ($row = mysql_fetch_array($record)) {
        // this should print no
        print( "wel_areas set: " . ( isset( $wel_areas ) ? "Yes" : "No" ));
        extract( $row );
        // this should print yes
        print( "wel_areas set: " . ( isset( $wel_areas ) ? "Yes" : "No" ));
} this will create variables into the local scope of each element in this associative array. It's a lot easier than typing each assignment out, and it also means if you include a new field in your query, your code will not have to create a new variable, it'll be automatic... At 08:29 AM 4/8/2002 -0600, Jas wrote:
Nevermind I got it fixed... I forgot to include a couple of fields from my database into my array. =). If you would like to use the code I am putting it here... <?php $table = "cm_dev_ads"; $dbh = mysql_connect('localhost','user_name','password') or die('Could not connect to database, please try again later'); mysql_select_db('bignicke') or die('Could not select database, please try again later'); $record = @mysql_query("SELECT wel_area, ad01, ad02, ad03, ad04, ad05, ad06, ad01_t, ad02_t, ad03_t, ad04_t, ad05_t, ad06_t FROM $table",$dbh); while ($row = mysql_fetch_array($record)) { $wel_area = $row['wel_area']; $ad01 = $row['ad01']; $ad02 = $row['ad02']; $ad03 = $row['ad03']; $ad04 = $row['ad04']; $ad05 = $row['ad05']; $ad06 = $row['ad06']; $ad01_t = $row['ad01_t']; $ad02_t = $row['ad02_t']; $ad03_t = $row['ad03_t']; $ad04_t = $row['ad04_t']; $ad05_t = $row['ad05_t']; $ad05_t = $row['ad05_t']; $ad06_t = $row['ad06_t']; } ?> That is the db connection and the results put into an array... <?php require 'db_index.php'; ?> This calls to the array script, now to echo them into my java-script it is as follows... <a href='javascript:openPopWin("<?php echo $ad01; ?>", 420,545, "", 0, 0)'onmouseover="window.status='This weeks full page ad';return true"><img src="<?php echo $ad01_t; ?>" width="200" height="100" vspace="0" hspace="0" border="0"></a> Hope this helps some other people that might want to do the same type of thing... Jas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.general (#92062) next »