Jump to content

[SOLVED] Searching a query result.


adam291086

Recommended Posts

I have a simple query that selects everything from a database and limits the results to one row ordered by desc. The code does work. The next step is to search the query result to see is if a certain feild has a result. I'm not sure how to do this. Any pointers are appreciated.

<?php

Include("config.php");
$con;

if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

$result = mysql_query("SELECT * FROM photos ORDER BY photo_id DESC LIMIT 1");
while($row = mysql_fetch_array($result))
{
echo $row['photo_id'];
}

?>

Link to comment
Share on other sites

The next step is to search the query result to see is if a certain feild has a result.

 

You shouldn't search through the result, but write your query in such a way to only retrieve the data you need. eg;

 

SELECT * FROM foo WHERE bar = 'val';

 

What field do you want to check and what value do you want it checked for?

Link to comment
Share on other sites

Basically what i am trying to do is search the database table and return the highest photo_id number. This equals the photo just uploaded. Then i want to check the photo_location and ensure the feild isn't empty. If it is empty then an error message is display else display photo uploaded ok.

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.