Jump to content

Archived

This topic is now archived and is closed to further replies.

cameeob2003

Displaying only certain data from MySQL DB

Recommended Posts

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 :)

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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:

[code]$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'];[/code]

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

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

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

Share this post


Link to post
Share on other sites
like i say you read the mysql manual

example only
[code]
$sql = "SELECT * FROM `news` where whatever='1'  AND order by `id` DESC ";
[/code]
ect ect ect ....

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites

×

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.