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
https://forums.phpfreaks.com/topic/215418-mysql-spaces/
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
https://forums.phpfreaks.com/topic/215418-mysql-spaces/#findComment-1120216
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.