Jump to content

[SOLVED] echo other picture


squiblo

Recommended Posts

if my database cannot find a member profile picture how can i echo a different picture?

 

<font face="arial">

<?php

//get data
$button = $_GET['submit'];
$search = $_GET['search'];

if (!$button)
header("location:unititled.php");
else
{
if (strlen($search)<3)
	header("location:unititled.php");
else
{
	echo "";

	//connect to our database
	mysql_connect("localhost","","");
	mysql_select_db("");


		//explode our search term
		$search_exploded = explode(" ",$search);

		foreach($search_exploded as $search_each)
		{

		//construct query
		$x++;
		if ($x==1)
		    $construct .= "username LIKE '%$search_each%'";
		else
		    $construct .= " OR username LIKE '%$search_each%'";			
	    
		}


	//echo out construct

	$construct = "SELECT * FROM members WHERE $construct";
	$run = mysql_query($construct);

	$foundnum = mysql_num_rows($run);

	if ($foundnum==0)
	   echo "No results found.";
	else
	{
	   echo "You searched for <b>$search</b><br>$foundnum result(s) found!<p><hr size='1'>";
	   
	   while ($runrows = mysql_fetch_assoc($run))
	   {
	 //get data
                $state = ucwords($runrows['state']);
                $url = $runrows['url'];
                $username = ucwords($runrows['username']);
                $imagelocation = $runrows['imagelocation'];

	echo "
                <img src ='$imagelocation' width='100' height='110' border='0' align='left' style='padding-right:10px'><br>
	<b>$username</b><br>
	$state<br>
	<a href='$url'>View Profile</a><br><br><br>
	<hr size='1' width='300' align='left'>
      		   
      		
      		
        	
  		";

  		
             }


           }   



        }	



}	



?>
</font>


 

the profile pictures are in ['imagelocation']

Link to comment
Share on other sites

If I understand correctly you are retrieving the data from a database, therefore if they have not selected a picture the field should be blank right? therefore this should work:

 

if ($imagelocation == ""){
   $imagelocation = "path to defualt image";
}

Link to comment
Share on other sites

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.