Question:
PHP MySQL specific table value?
anonymous
2008-01-17 14:42:25 UTC
I'm making a conditional statement, where I want one end of the condition...

if ($set1 == THIS END) {...}

to be set to get its value from a database table in MySQL...

if ($set1 == this is a value from a database table) {...}

how would I set up a mysql_query to get a specific value from a certain table cell? ...

if ($set1 == this is a value from a database table, column 1) {...}

Also, how would I configure the ORDER BY command to sort an id number by largest first, to smallest last? ...

13, 12, 11, 10, 9, 8 ...

In that way, it would select the most recent value of the column, therefore a specific cell.

Answers much appreciated
Three answers:
Rex M
2008-01-17 14:52:43 UTC
$result = mysql_query('SELECT columnName FROM tableName WHERE columnName='criteria' ORDER BY idColumn DESC');



$row = mysql_fetch_assoc($result);

$desiredValue = $row["columnName"]



columnName, of course, should be the name of the column you want to fetch. You need to have some criteria in place to get the correct row, since I don't know the business logic of your requirements I can't help there.



tableName also self-explanatory.



Your idColumn should ideally be a managed value column that increments the value each time a row is inserted.
gaertner
2016-10-24 08:11:37 UTC
$myDB = new mysqli('localhost', 'root', 'password', 'user_data'); $statement_ = "choose * FROM user_data the position specific_user=".$UniqueUser; $res = $myDB->question($reality); // ... etc.. etc.. the first answer is actual ultimate. This answer will function your determination practise guide and party. * do no longer ignore that $UniqueUser is a variable and incorporates value of the particular person..
Rasmah.com
2008-01-17 15:14:21 UTC
I really have the answer of this question but really i can't answer this question for free ... it is take me along time to create Greate Function .


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...