yanivkalfa Posted January 27, 2008 Share Posted January 27, 2008 my question is this . well i am trying to show pics that is found in a text variable in my mysql table though that variable holds in it more then 1 URL of links and when i find the intery that i want and then go to the variable that have the links and try to Echo it where the URL of the Pic sould be . it will echo some links 1 after eatch other mysql_connect(x, x, x) or die("ERROR--CAN'T CONNECT TO SERVER"); mysql_select_db(xx) or die("ERROR--CAN'T CONNECT TO DB"); $rowcount = "SELECT * FROM downloads WHERE ID = '$DID'"; $result_count = mysql_query($rowcount) or die("Error: " . mysql_error()); $arr = mysql_fetch_array($result_count); <img src="<?php echo $arr["PicLinks"]; ?> / what it will happand now it will be : /<img src="LINKS.COM LINKS2.com /Links3.com"/> /this wil basiclay will not show me any pics and what i am trying to achive is Some how to scane this text variable for pic URLs input them into array or something and then just make a while and echo the whole IMG form 1 by 1 /basicaly i dont know how to do it but what i am trying to achive is like this . echo ('<img src="LINKS.COM"/>'); echo ('<img src="LINKS2.COM"/>'); echo ('<img src="LINKS3.COM"/>'); So i will actualy see the Pics. thanks in advanced and would realy appricate any help. thanks Quote Link to comment https://forums.phpfreaks.com/topic/87983-trying-to-show-pics-connecting-to-sql-and-getting-addres-from-text-variable/ Share on other sites More sharing options...
Bauer418 Posted January 27, 2008 Share Posted January 27, 2008 Your code should read like this: <?php // Database connection and such here $result = mysql_query($query) or die('Error: ' . mysql_error()); while ($row = mysql_fetch_assoc($result)) { echo '<img src="' . $row['column_name'] . '" />'; } Quote Link to comment https://forums.phpfreaks.com/topic/87983-trying-to-show-pics-connecting-to-sql-and-getting-addres-from-text-variable/#findComment-450170 Share on other sites More sharing options...
yanivkalfa Posted January 27, 2008 Author Share Posted January 27, 2008 may i ask what mysql_fetch_assoc does ? Quote Link to comment https://forums.phpfreaks.com/topic/87983-trying-to-show-pics-connecting-to-sql-and-getting-addres-from-text-variable/#findComment-450174 Share on other sites More sharing options...
Bauer418 Posted January 27, 2008 Share Posted January 27, 2008 Same as mysql_fetch_array, however it uses an associative array (where values are assigned to string-based keys, rather than integers). mysql_fetch_array returns a combination of an indexed array (with numerical keys) and an associative array (with string-based keys). Since most people only use the string based keys, having the index-based array in conjunction with that is a waste of memory. Therefore mysql_fetch_assoc is usually more practical. Quote Link to comment https://forums.phpfreaks.com/topic/87983-trying-to-show-pics-connecting-to-sql-and-getting-addres-from-text-variable/#findComment-450188 Share on other sites More sharing options...
yanivkalfa Posted January 27, 2008 Author Share Posted January 27, 2008 Well i tryed what you just said and it didnt worked. i thinks there is some other way Quote Link to comment https://forums.phpfreaks.com/topic/87983-trying-to-show-pics-connecting-to-sql-and-getting-addres-from-text-variable/#findComment-450189 Share on other sites More sharing options...
yanivkalfa Posted January 27, 2008 Author Share Posted January 27, 2008 i understood a way of doing it but i dont know how its working i thinks i can use preg_match function to do so and then Use the Match aray writh for loop but then again i dont know how to work with preg_matcg Quote Link to comment https://forums.phpfreaks.com/topic/87983-trying-to-show-pics-connecting-to-sql-and-getting-addres-from-text-variable/#findComment-450204 Share on other sites More sharing options...
Bauer418 Posted January 27, 2008 Share Posted January 27, 2008 If you copied and pasted my code, no, it will not work. However, if you edited the names of the array keys and such as needed, it should work just fine. But, you didn't leave any details as to how your database is setup, so I can't provide in depth help. Quote Link to comment https://forums.phpfreaks.com/topic/87983-trying-to-show-pics-connecting-to-sql-and-getting-addres-from-text-variable/#findComment-450468 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.