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
https://forums.phpfreaks.com/topic/161534-listing-records-by-importance/
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

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.