NameSilo

PHP/MYSQL Help

Namecheap AuctionsNamecheap Auctions
SpaceshipSpaceship
Spacemail by SpaceshipSpacemail by Spaceship
Watch

dc1pop

VIP Member
Impact
13
Hi,

Im lookign for some information and help on this situation. Im currently creating a profile database which includes images. However not all profiles have an image so im looking to see how hard it is to create it so a default image can be used rather then always uploading a "deafult" image which is taking up space :)

Thanks,
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
easy..you can set a default variable for mysql...
 
0
•••
This is just an example, I don't know what you're code looks like. But it might be similar to the following.

PHP:
$query = "SELECT * FROM profiles where user_id='$user_id'";
$exec = mysql_connect($query);

$row = mysql_fetch_row($result);

echo $row[0]; // Probably the user_id
echo $row[1]; // username
// $row[2]; This is probably where the picture is stored.
// Other ones will follow here depending on your database

if empty($row[2]) {
//Place the code for the default image here
} else {
// Place the code for the user image here
}

// other code
Hopefully that makes sense to you.

-Steve
 
0
•••
Hi Steve once again :D

The code i have is below:

PHP:
$fplcontent = '<table border="0" width="100%" cellspacing="3" cellpadding="2" id="table14" class="style4">
			<tr>
				<td width="134" rowspan="9" align="center">
				<img src="http://footballtalk.org/uploads/'.$players['img'].'" border="1" width="150" height="205"></td>

Obviously i want to do the image part so any assistance very new to php and upgrading a system a namepros member built for me which is very good but i just want to make a few "minor changes" :)

Thanks!
 
0
•••
PHP:
if(empty($players['img'])){
$players['img'] = "default_image.gif";
}
$fplcontent = '<table border="0" width="100%" cellspacing="3" cellpadding="2" id="table14" class="style4">
            <tr>
                <td width="134" rowspan="9" align="center">
                <img src="http://footballtalk.org/uploads/'.$players['img'].'" border="1" width="150" height="205"></td>

If I understand correctly.
 
1
•••
Tree said:
PHP:
if(empty($players['img'])){
$players['img'] = "default_image.gif";
}
$fplcontent = '<table border="0" width="100%" cellspacing="3" cellpadding="2" id="table14" class="style4">
            <tr>
                <td width="134" rowspan="9" align="center">
                <img src="http://footballtalk.org/uploads/'.$players['img'].'" border="1" width="150" height="205"></td>

If I understand correctly.


Worked wonderful!!

How would i ever get things to work without Namepros another problem solved!
 
0
•••
I'm glad its all worked out now.

:)

-Steve
 
0
•••
stscac said:
I'm glad its all worked out now.

:)

-Steve

Thanks!

You have been great recently. As i said you got a vote comig n your way and i cant leave rep for you as i have already :)
 
0
•••
I'm glad it works. :)
 
0
•••
dc1pop said:
stscac said:
I'm glad its all worked out now.

:)

-Steve

Thanks!

You have been great recently. As i said you got a vote comig n your way and i cant leave rep for you as i have already :)
Thanks, its my pleasure. Just remember it closes on the 6th, so get it in before then. Thanks!

-Steve
 
0
•••
stscac said:
Thanks, its my pleasure. Just remember it closes on the 6th, so get it in before then. Thanks!

-Steve


Thats for nominations though then voting opens :D

I cant nominate someone whos nominated :P
 
0
•••
Oh ok. Seems as if there's already 5 votes.

-Steve
 
0
•••
5 people must have nominated you :D
 
0
•••
CatchedCatched

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com
Catchy
DomDB
NameFit
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back