0

I am trying to read a field in a table which contains this sentence "Sales & Logistics" using the following code:

if(isset($_GET['major1']))
{
    $major = $_GET['major1'];
}
else
{
    $major ="";
}

Unfortunately, $major will contains only "Sales " after this code while it should be "Sales & Logistics".

Note: '&' has not been converted into any shape, it has been saved as it is.

How can I read anything inside this table cell?

Thank You

  • 2
    I have no idea what the code you posted has to do with any table. However, it looks that you didn't convert the `&` properly when creating the query string. Functions like [`http_build_query()`](http://php.net/manual/function.http-build-query.php) are your friend – kero Mar 02 '16 at 08:25
  • Because `&` is used to separate multiple parameters, like `/index.php?major1=SomeTxt&parameter2=otherText`. Not an issue I've faced before though, so not sure how to solve it. – Qirel Mar 02 '16 at 08:25
  • 3
    you must urlencode() get parameters in urls – Jeremy Mar 02 '16 at 08:27
  • "Sales & Logistics" was saved in this table as it is without converting '&' into query string and cannot be change now. we need to extract the whole field with simplest way. – a.n.almutawaa Mar 02 '16 at 08:33
  • What "table" are you talking about? What does a table have to do with URLs and GET parameters? – deceze Mar 02 '16 at 08:35
  • We have a table called "resume" which already contains data. one of the columns called "major1". in some entries "major1" field will contains "Sales & Logistics". I cannot change any thing in this table which means that I cannot replace '&' with '%26'. What will be the best solution to read this whole sentence? – a.n.almutawaa Mar 02 '16 at 08:43
  • "Table" as in **MySQL table**?! You don't change anything about the data in that table. You just need to properly encode URLs in your HTML template, or wherever you're creating that URL. – deceze Mar 02 '16 at 08:45

0 Answers0