joshgarrod Posted June 9, 2009 Share Posted June 9, 2009 Hi, I am having a go at allowing the admin user to list records and update them by importance. I have a field in my table called "importance" which by default is set to 1, the admin user should then be able to click increase to increase the value by one, therefore list it higher... but my attempt has failed. What am I doing wrong? <?php $con = mysql_connect("host","user","pass"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("quest", $con); $ref = $_GET['ref']; $query = mysql_query("SELECT * FROM shows WHERE `ref` = '$ref'"); if(mysql_num_rows($query)==0){ die("Sorry, but this entry doesn't exist!"); }else{ while($info = mysql_fetch_array($query)){ $importance = $info ['importance']; } $importance == $importance + 1 mysql_query("UPDATE importance shows where ref='$ref'"); mysql_close(); header("location:edit_remove_shows.php"); exit(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/161534-listing-records-by-importance/ Share on other sites More sharing options...
RussellReal Posted June 9, 2009 Share Posted June 9, 2009 in UPDATE, the syntax is UPDATE `tableName` SET `fieldName` = 'value' WHERE `fieldX` = 'anotherValue' and to select in order of importance, higher importance would be @ top SELECT * FROM `tableName` WHERE `x` = 'x' ORDER BY `importance` DESC Quote Link to comment https://forums.phpfreaks.com/topic/161534-listing-records-by-importance/#findComment-852440 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.