Jump to content

Only Shows 'Description' (Numbers?)


justlukeyou

Recommended Posts

I think you may have a very fundamental misunderstanding of how this works.

 

WHERE description = '$description'

 

What the above means is "where the value of the contents of the database field `description` is identical to the value of the variable $description".

 

I.E. If the `description` field in a particular record is 'this is the best gadget of all time.', the only way it will match is if $description = 'this is the best gadget of all time.'

 

Does that shed any light on this?

Link to comment
Share on other sites

Hi,

 

Yes but this isn't working. 

 

If I have "red widget" in my database under 'description' but then search for:

 

?description=redwidget

?description=red-widget

?description=red

?description=widget

 

All I get at the moment all I get is a blank screen.  However, I know that I have a 'red widget' in 'description' because I can display them using the ID number.  However, I am trying to do by using the description but I am getting very stuck on this.

 

However, if I search for:

 

php?description=description

 

I get everything displayed from my database. 

 

Link to comment
Share on other sites

No, it won't return any results because you're asking it for an exact match. 'red widget' is not the same as 'redwidget', red-widget', 'red' or 'widget'.

 

However, if I search for:

 

php?description=description

 

I get everything displayed from my database. 

 

If that's the case, you've removed the quotes from around '$description' in the query string again, even though it's been pointed out several times that they are absolutely required when comparing string type data.

Link to comment
Share on other sites

Building upon what Kenr said, as well as others, create a simple test php file per the below. then run it

 

<?php
/* database connection here */

$match = "red";
$query = "SELECT * FROM productfeed WHERE description LIKE '%$match%'";
$result = mysql_query($query);
while($row = mysql_fetch_array($result)){
echo $row['description'] . " " .  strlen($row['description']) . "<br/>";
}
?>

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.