Jump to content

trying to show Pics , connecting to SQL and getting addres from Text Variable ..


Recommended Posts

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

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'] . '" />';
}

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.

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

 

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.