SmileyWar Posted August 16, 2012 Share Posted August 16, 2012 Hello all, This is a odd one, last year i built a query where i was pretty new to mysql, and what i did was as simple as this. Get the query and then print the data. But now that i'm updating the database i absolutely hate having to use numbers because i want to reorder the table. But when i want to change it to column names it's not getting the data. And i can't understand why that's happening. Here is what i have. $op1 = mysql_query("SELECT * FROM carchain_prices_qty WHERE ProductID='".$option1."' ", $connect) or die(mysql_error()); $product1 = mysql_fetch_row($op1); if ($options >= "1"){ echo' <li class="ui-tabs-nav-item ui-tabs-selected" id="nav-fragment-1"><a href="#fragment-1"> <center> <img src="images/preview_'.$product1[8].'_small.jpg" alt="'.$product1[1].'" title="'.$product1[1].'" /> </center> <span> £ '.$product1[2].' per pair<br> '.$product1[9].'<br>'.$product1[10].' </span> </a></li> '; } and here is what i want it to be, noting that all my newly designed scripts are always with column names, it's only that first one i built due to the same issue i have now i used numbers in the array rather then names if ($options >= "1"){ echo' <li class="ui-tabs-nav-item ui-tabs-selected" id="nav-fragment-1"><a href="#fragment-1"> <center> <img src="images/preview_'.$product1['PageID'].'_small.jpg" alt="'.$product1['ProductID'].'" title="'.$product1['ProductID'].'" /> </center> <span> £ '.$product1['Price'].' per pair<br> '.$product1['ProductBrand'].'<br>'.$product1['ProductName'].' </span> </a></li> '; } Your wisdom is much appreciated, thanks! Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted August 16, 2012 Share Posted August 16, 2012 See the manual for the differences between mysql_fetch_row and mysql_fetch_assoc. Quote Link to comment Share on other sites More sharing options...
SmileyWar Posted August 16, 2012 Author Share Posted August 16, 2012 Hello Pickachu2000 Offcourse that makes sense now, thanks very much! I was banging my head all day long researching why column names didn't respond! hahaha. You learn something new every day Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.