473,513 Members | 2,428 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Advice on a table

13 New Member
I want to create a table to which 3 different users will post data. The data is just message/news data and each user will only need to post data to one field. So far I have a table with the fields:
ID, Message, Daily_Announcement, and News

I want to extract the data posted into each field and display it on a corresponding html page. I have the following code to extract and display the data but it displays everything input into the table and I want to be able to display just the most recent entry from each of the fields. What would be the best way to set up the table and what am I missing to just extract the most recent posting?
<?php
$db = mysqli_connect("localhost", "", "","db-jvadmin");
if (!$db)
{
die('Could not connect: ' . mysqli_error());
}

$query = "SELECT * FROM Announcements";

$result = mysqli_query($db,$query);

while($row = mysqli_fetch_array($result))
{
echo $row[Message'];
}
mysqli_close($db);
?>
Apr 1 '08 #1
2 1004
TheServant
1,168 Recognized Expert Top Contributor
Syntax error: echo $row['Message']; (you had: echo $row[Message'];)

I will have to think about how to get the most recent as I am still unsure about how the table is set out. Try fix that syntax error and see if it no longer returns all the row data.

Also post your code in the correct tags! Just above where you post (where the Bold and Italic options are) there are code tags (CODE, PHP, HTML, etc).
Apr 1 '08 #2
Markus
6,050 Recognized Expert Expert
Use a 'limit' clause.

[php]
<?php
$db = mysqli_connect("localhost", "", "","db-jvadmin");
if (!$db)
{
die('Could not connect: ' . mysqli_error());
}

$query = "SELECT `Message`,`Daily_Announcement`,`News` FROM Announcements LIMIT 1";

$result = mysqli_query($db,$query);

while($row = mysqli_fetch_array($result))
{
echo "{$row['Message']} - {$row['Daily_Announcement']} - {$row['News']}";
}
mysqli_close($db);
?>
[/php]
regards.
Apr 1 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

75
6096
by: Howard Nease | last post by:
Hello, everyone. I would appreciate any advice that someone could give me on my future career path. Here is my situation: I am a bright Junior in a very well-respected private high school, taking...
7
3190
by: Daniel Roy | last post by:
Hi guys, I've been playing with this query for about a week now, and I still can't find ways to speed it up. It runs for about 5 minutes. The only table (among the 41) with significant amount of...
9
1423
by: obhayes | last post by:
Hi, I have two tables Table A and B, below with some dummy data... Table A (contains specific unique settings that can be requested) Id, SettingName 1, weight 2, length Table B (contains...
3
1645
by: James Armstrong | last post by:
Hi all, (warning - long post ahead) I have been tasked with designing a database for my company which will store trade information (it is a financial firm). It will need to export this info...
1
1308
by: meganrobertson22 | last post by:
Hi Everybody- I am trying to create a Table structure to represent the relationship between Agencies and their Sub-Agencies. There are Agencies and Sub-Agencies. Some Agencies have...
3
3153
by: ChadDiesel | last post by:
Hello everyone. I need some advice on table structure for a new project I've been given. One of our customers sends us an Excel spreadsheet each week containing their order. Currently, someone...
2
1011
by: Manny | last post by:
Hello I'm fairly new to ASP.NET and need your advice, I need to display monthly/weekly table information on the same page. The user should be able to select first from a month (from a month link...
2
1293
by: eviewcs | last post by:
Hello, I am relatively new to DB2 and i would appreciate if anybody can give me advice on UDF table. My question is : 1) Is performance an issue when using UDF table? 2) I read from previous...
23
2400
by: JohnH | last post by:
I'm just recently come to work for an auto brokerage firm. My position involves performing mysterious rites, rituals and magick in order to get information out of their access database. This is...
9
1707
by: Mo | last post by:
After a little PHP education, my first project (to get my feet wet) is making an employee time-tracking program for our small business. *** ANY SUGGESTION, THOUGHTS, OR ADVICE WOULD BE WARMLY...
0
7260
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7160
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
7099
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5685
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5086
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4746
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3222
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1594
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
456
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.