...

View Full Version : want to edit that php/mysql code



maxwel
01-29-2012, 02:22 PM
<?php

$MYSQL_HOST = "localhost";
$MYSQL_USER = "user";
$MYSQL_PW = "pass";
$MYSQL_DB = "db";

$conn = mysql_connect($MYSQL_HOST, $MYSQL_USER, $MYSQL_PW);
mysql_select_db($MYSQL_DB, $conn);

$names = "";

$chatuser = mysql_query("SELECT * FROM pcpin_nickname WHERE pcpin_nickname.default = 'y';");

while($row = mysql_fetch_assoc($chatuser)) {
$names .= $row['nickname_plain'].' ';
}

$names = substr($names, 0, -5);

echo ' <marquee behavior="scroll" direction="up" scrollamount="5" scrolldelay="200" onmouseover="this.scrollAmount=0" onmouseout="this.scrollAmount=5""this.scrolldelay=200">'.htmlspecialchars($names).' </marquee>';


?>

i need instead of names show in a row it shows in a column means in vertical way norizontal
also was wondering if i can make the thumbnail avatar of the pcpin chat show beside the name too

any idea?

thnx in advance

maxwel

jmj001
01-29-2012, 03:17 PM
<?php

$MYSQL_HOST = "localhost";
$MYSQL_USER = "user";
$MYSQL_PW = "pass";
$MYSQL_DB = "db";

$conn = mysql_connect($MYSQL_HOST, $MYSQL_USER, $MYSQL_PW);
mysql_select_db($MYSQL_DB, $conn);

$names = "";

$chatuser = mysql_query("SELECT * FROM pcpin_nickname WHERE pcpin_nickname.default = 'y';");

while($row = mysql_fetch_assoc($chatuser)) {
$names .= '<img src="'.$row['nickname_img_path'].'" align="absmiddle">'.$row['nickname_plain'].'<br>';
}

$names = substr($names, 0, -5);

echo ' <marquee behavior="scroll" direction="up" scrollamount="5" scrolldelay="200" onmouseover="this.scrollAmount=0" onmouseout="this.scrollAmount=5""this.scrolldelay=200">'.htmlspecialchars($names).' </marquee>';


?>

that will put a line break between each of the names but the substr you've got there chopping the last 5 characters off will prob break something...

also added the image in there for you but you'll need to modify it to the actual column name that has the path to the image

let me know what you end up with

maxwel
01-29-2012, 04:25 PM
thanks alot for ur fast reply but actually didn't work :/ that was the output "tony7364<br>WildLio" even 1 letter not showin of one of users :/

jmj001
01-29-2012, 06:39 PM
what's the

$names = substr($names, 0, -5);
in there for?

maxwel
01-29-2012, 06:44 PM
idk, tbh i had that code from the pcpin chat forums. i am not good with php/mysql thangs that much so idk :S i even donno how to get the image url from database tried to search db with notepad++ but i donno which is the url found the (nickname_plain) but nothing about image/avatar there that looks like (avatar_plain) or sumthing

thanks in advance for the help :D so much appreciated

EDIT:
ok i remove the part u mentioned and seems it don miss a letter now and all letters show up but same the <br> didn't break the names i tried even </br> and <br /> instead but no use :S

they appeared like
tony7364</br>WildLion</br> &
tony7364<br />WildLion<br />

jmj001
01-29-2012, 06:48 PM
ok... let's backtrack and see if we can get it to display without the image first...


<?php

$MYSQL_HOST = "localhost";
$MYSQL_USER = "user";
$MYSQL_PW = "pass";
$MYSQL_DB = "db";

$conn = mysql_connect($MYSQL_HOST, $MYSQL_USER, $MYSQL_PW);
mysql_select_db($MYSQL_DB, $conn);

$names = "";

$chatuser = mysql_query("SELECT * FROM pcpin_nickname WHERE pcpin_nickname.default = 'y';");

while($row = mysql_fetch_assoc($chatuser)) {
$names .= $row['nickname_plain'].'<br>';
}

// $names = substr($names, 0, -5);

echo ' <marquee behavior="scroll" direction="up" scrollamount="5" scrolldelay="200" onmouseover="this.scrollAmount=0" onmouseout="this.scrollAmount=5""this.scrolldelay=200">'.htmlspecialchars($names).' </marquee>';


?>

i've commented out the substr $names bit... let me know what that gives you

maxwel
01-29-2012, 06:52 PM
yea already tried what u mentioned lately it worked. i edited ma last post

jmj001
01-29-2012, 07:06 PM
ok.. this time it will work... you gotta ditch htmlspecialchars, sorry... missed that


<?php

$MYSQL_HOST = "localhost";
$MYSQL_USER = "user";
$MYSQL_PW = "pass";
$MYSQL_DB = "db";

$conn = mysql_connect($MYSQL_HOST, $MYSQL_USER, $MYSQL_PW);
mysql_select_db($MYSQL_DB, $conn);

$names = "";

$chatuser = mysql_query("SELECT * FROM pcpin_nickname WHERE pcpin_nickname.default = 'y';");

while($row = mysql_fetch_assoc($chatuser)) {
$names .= $row['nickname_plain'].'<br>';
}

// $names = substr($names, 0, -5);

echo ' <marquee behavior="scroll" direction="up" scrollamount="5" scrolldelay="200" onmouseover="this.scrollAmount=0" onmouseout="this.scrollAmount=5""this.scrolldelay=200">'.$names.' </marquee>';


?>

maxwel
01-29-2012, 07:13 PM
Perfect :D thank you so much :D and u don have to apologize ur helping me :)

btw, i thanked all ur posts the least to giveback as a thank now i have to keep look for that db avatar imges but ik it might be the harderest or impossible but thanks alot bro :D

Maxwel

jmj001
01-29-2012, 07:15 PM
cheers, normally a database will have images listed as path... good luck.. :thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum