Jump to content

Listing records by importance


joshgarrod

Recommended Posts

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();

?>

Link to comment
Share on other sites

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

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.