Jump to content

MySQL & Spaces


BCAV_WEB

Recommended Posts

I have a form which has a drop down menu select box, which retrives the makes of cars from a database, which once clicked submit will go to another page post that info. Then a if statment says if the variable that has been posted == a certain word that matches the one in the database then display content. However, my issue is when I have a car make such as "Land Rover" saved in the database as typed it just comes back with the final else statement.

 

In the 1st section I have included the form which is posting the information across and in the second I have the if statement. Any ideas of how to get around / make this work?

 

[

<form method=post" action="details.php" enctype="multipart/form-data">

<table class="search_nav">

<tr>

<td>

<select name="manufacture" id="manufacture">

<option value=" " selected="selected">Car Manufactures  </option>

';

$query = "SELECT DISTINCT make FROM cars ORDER BY make ASC";

$result = mysql_query($query) or die ("Error in query: $query. ".mysql_error());

while ($row = @ mysql_fetch_array($result))

{

print '

<option value='.$row["make].'>'.$row["make"].'</option>

  ';

}

print '

</select>

</td>

</tr>

<tr>

<td colspan="2">

<input type="image" src="images/go.gif" alt="Go" name="submit" id="submit" value="Submit"/>

</td>

</tr>

</table>

</form>

]

 

[

 

if ($manufactures == "Land Rover")

{

echo "test";

 

}

]

Link to comment
Share on other sites

I have manually enetered the data into the database, so the select is coming as the word "Land Rover" and the value should also be "Land Rover" and this information is then posted in the form under the id "manufactures". I have over makes working such as Ford and have recently changed the land rover to "Land-Rover" both on the if statement and in the database, which works fine. The issue is to do with the space, I have also tried using " " which also hasn't worked  :(

 

Any Ideas??

 

 

Database Structure

[

  id          int(10)   

make varchar(40)

make_link varchar(25)

rrp         varchar(10)

what_price int(8)

what_link varchar(1000)

our_price         varchar(8)

image varchar(100)

]

 

Data

[

6  Land Rover

]

Link to comment
Share on other sites

Yes that is correct and it works like for most cases however, when it submits "Land Rover" and retrives the word "Land Rover" from the database it doesn't seem to work for some reason. Resulting in the final else statement, any ideas?

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.