Jump to content

display texts from Mysql in textarea randomly? please Help


crf121359

Recommended Posts

Hello,

 

I am trying to display the texts that is stored in mysql in a textarea on a random basis.

 

here is my code:

 

<?php

mysql_connect("localhost", "myusername", "mypass") or die("Connection Failed");

mysql_select_db("mydatabase")or die("Connection Failed");

 

 

$query1 = ("SELECT name FROM advertising");

$result1 = @mysql_query ($query1) or die (mysql_error());

$data = mysql_fetch_assoc($result1);

 

while($row = mysql_fetch_array($query)){

 

    $name = $row["name"];

}

 

but when I run the above code I get this error and also the textarea doesn't show anything and its blank:

 

Warning: mysql_fetch_array() expects parameter 1 to be resource, null given in /home/path.../public_html/display.php on line 9

 

 

could someone please help me?

 

Thanks

OMG smerny, You are my God... you don't know how long I've been trying to resolve this issue!!

 

Thank you sooooo much.

works like a charm now. :)

 

Now, just to pick your brains again, can you tell me how I can show the texts randomly?

 

for example I have 10 columns in my mysql table with different texts in each of them. how can i  randomly show the contents of each columns in the same textarea?

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.