Jump to content


Photo

Displaying only certain data from MySQL DB


  • Please log in to reply
5 replies to this topic

#1 cameeob2003

cameeob2003
  • Members
  • PipPipPip
  • Advanced Member
  • 79 posts

Posted 01 August 2006 - 09:42 PM

I am trying to diplay data on my webpage using php. I only want certain fields which have the correct value to display in the area I choose. I am fairly new to php and was not sure what this set of commands to do this would be called or how I would preform it. Any help is great. Explinations are better :)

#2 Caesar

Caesar
  • Members
  • PipPipPip
  • Advanced Member
  • 1,025 posts

Posted 01 August 2006 - 09:46 PM

Please show a sample of your code and maybe we can take it from there. Otherwise, I suggest you go learn the basics before coding a page.

http://www.php.net
PHP Ninja

#3 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 01 August 2006 - 09:49 PM

i also recomend readingup on mysql or the database your useing as php is the programing lanuage but the database is another story.

good luck.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#4 cameeob2003

cameeob2003
  • Members
  • PipPipPip
  • Advanced Member
  • 79 posts

Posted 01 August 2006 - 09:54 PM

I understand all of that... I assume my question was not clear enough. I was using the following to display information from my database before:

$sql = "SELECT * FROM `news` order by `id` DESC";
		$result = mysql_query($sql) or die(mysql_error());
		while ($text = mysql_Fetch_array($result)) {
			$id = $text['id'];
			$title = $text['title'];
			$date = $text['date'];
			$author = $text['author'];

I want to do something similar but only display the values in the db marked to 1,2,3 ect...

So I would be using something like this

echo'<table>
<tr>
<td>'. $myvariable .'</td>
<td>'. $myvariable2 .'</td>
</tr>
</table>

but it would only display the rows that have a value of 1,2,3.. in the access section

#5 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 01 August 2006 - 09:56 PM

like i say you read the mysql manual

example only
$sql = "SELECT * FROM `news` where whatever='1'  AND order by `id` DESC ";
ect ect ect ....
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#6 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 01 August 2006 - 10:52 PM

I don't understand the significance of the comment "but it would only display the rows that have a value of 1,2,3.. in the access section".  You obviously have code that can retrieve data and code that can display it.  So what's the 'access section' all about?
Legend has it that reading the manual never killed anyone.
My site




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users