Jump to content

Obsolete80

New Members
  • Posts

    6
  • Joined

  • Last visited

    Never

About Obsolete80

  • Birthday 03/19/1980

Profile Information

  • Gender
    Male
  • Location
    Manchester, UK

Obsolete80's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks for the help, I tried a few ways of checking that an image existed, but just couldn't figure it out!
  2. I'm attempting to replace missing images from a site that I'm currently working on with a standard image (images/unavailable.jpg) until I have the relevant images. The only way I've been able to achieve this so far is to have copies of unavailable.jpg saved with the image names that are missing, which means I currently have about 20-30 copies of the same image. Is there a simple way to do this? The code I currently have is displayed below: $result = mysql_query("SELECT * FROM pigs WHERE status LIKE 'available'"); $num_rows = mysql_num_rows($result); echo " We currently have <strong> $num_rows </strong> guinea pigs available for rehoming<br/><br/><br/>"; //build query $query = mysql_query("SELECT * FROM pigs WHERE status LIKE 'available' ORDER BY added"); //display results while ($row = mysql_fetch_array($query)) { echo "<img src='images/pigs/".$row['id'].".jpg' alt='' border='0' class='thumb' />". " - <a href='details.php?id=".$row['id']."'>".$row['name']."</a> - ".$row['sex']." , ".$row['age']." months<br/><br/><br/>" ;} I'm new to php so theres probably a really simple solution to this, but I've been unable to find it so far...
  3. I (finally) managed to find the solution... a missing . got the following code to work: while ($row = mysql_fetch_array($query)) { echo "<img src='images/pigs/".$row['id'].".jpg' alt='' border='0' class='floatLeft' />". "<strong>Name: </strong> ".$row['name']. "<br/><br/> <strong>Sex: </strong> ".$row['sex']. "<br/> <strong>Age: </strong> ".$row['age']. "<br/> <strong>Added On: </strong> ".$row['added']. "<br/> <strong>Colour: </strong>".$row['colour']. "<br/><br/> <strong>Details: </strong>".$row['details']. " "; "<br/>" ;} ?>
  4. The code I have tried is: while ($row = mysql_fetch_array($query)) { echo "<img src='images/pigs/".$row['id'].".jpg' alt='' border='0' class='floatLeft' /> " "<strong>Name: </strong> ".$row['name']. "<br/> <strong>Sex: </strong> ".$row['sex']. "<br/> <strong>Age: </strong> ".$row['age']. "<br/> <strong>Added On: </strong> ".$row['added']. "<br/> <strong>Colour: </strong>".$row['colour']. "<br/> <strong>Details: </strong>".$row['details']. " "; "<br/>" ;} which just gives me the error "Parse error: parse error, expecting `','' or `';'' in C:\wamp\www\pigs2\details.php on line 38" the code for line 38 is: "<strong>Name: </strong> ".$row['name']. I've tried several slight variations of the code, but can only seem to get it working when I just use the image OR just the information. I'm not too sure what you mean by All of the image files will be named using the id field (primary) in the database, at the moment I only have a small number of records for the building and testing process.
  5. Sorry about that, I didn't explain fully.. I want to display both the image and the other information together within the same piece of code with the image first.
  6. Not sure if this should go here or in the mysql section, so I'll apologise in advance if it's wrong I'm currently building a site for a friend with a basic details page to display a selected result from searches. For some reason I can't get a picture and other information to display at the same time. If i use: while ($row = mysql_fetch_array($query)) { echo "<strong>Name: </strong> ".$row['name']. "<br/> <strong>Sex: </strong> ".$row['sex']. "<br/> <strong>Age: </strong> ".$row['age']. "<br/> <strong>Added On: </strong> ".$row['added']. "<br/> <strong>Colour: </strong>".$row['colour']. "<br/> <strong>Details: </strong>".$row['details']. " "; "<br/>" ;} the information is all displayed. If i use while ($row = mysql_fetch_array($query)) { echo "<img src='images/pigs/".$row['id'].".jpg' alt='' border='0' class='floatLeft' /> " ;} but for some reason i'm unable to get both to display at the same time. I know this is probably a simple problem to solve, but any help would be appreciated!
  7. Obsolete80

    Hi

    Hi, I'm new to php, but have a basic knowledge of html/css from playing around with sites in my free time.
×
×
  • 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.