Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,151,369 members, 7,812,076 topics. Date: Monday, 29 April 2024 at 07:42 AM

Urgent Help To Display Data In Php - Webmasters - Nairaland

Nairaland Forum / Science/Technology / Webmasters / Urgent Help To Display Data In Php (1279 Views)

Please Reply,how To Display Html Codes In Textarea For Wordpress / See Why Google Adsense Failed to Display Your Earning Today / How To Display Google Adsense From An Adsense Banned Blogs (2) (3) (4)

(1) (Reply) (Go Down)

Urgent Help To Display Data In Php by analogiphone: 2:26pm On Sep 22, 2015
Please I need the php code to display this table and input datas in it from my data base.

Please I'm new to web design and I've been trying work on this all day.

I want when a user login to my the site, I'm going to display their datas in this table and show on their page.

E.g

Seuns record
Date. Current Status
02/09/2015 I display whatever record here
18/09/2015. I display the datas
22/09/2015 I display the datas

I will keep updating this record on the users page.

Please I need your urgent help on this

I need go know how to echo the information I wish to place and the table with table rows. Please the php syntax is what I need

Gurus abeg make una help me

Re: Urgent Help To Display Data In Php by analogiphone: 3:11pm On Sep 22, 2015
Wey all the gurus now
Re: Urgent Help To Display Data In Php by onyengbu: 3:18pm On Sep 22, 2015
analogiphone:
Wey all the gurus now
How did you save the 'Current Date' and 'Status' in your database. What is the exact name you gave them and what is the name of your connection to the database?
Re: Urgent Help To Display Data In Php by analogiphone: 3:28pm On Sep 22, 2015
onyengbu:

How did you save the 'Current Date' and 'Status' in your database. What is the exact name you gave them and what is the name of your connection to the database?

Thanks boss.

Reg_date current stamp.

Connection "localhost" "root" "" ( no password )

I will display the users record but not in the table.

What I want in table is just be able to update the date and current status of what they will be doing.
Re: Urgent Help To Display Data In Php by onyengbu: 4:15pm On Sep 22, 2015
analogiphone:


Thanks boss.

Reg_date current stamp.

Connection "localhost" "root" "" ( no password )

I will display the users record but not in the table.

What I want in table is just be able to update the date and current status of what they will be doing.
which one is which. Just seprte and identify them properly.
One more thing is the date lredy formatted in the formt you posted in your first post.
Re: Urgent Help To Display Data In Php by analogiphone: 4:37pm On Sep 22, 2015
onyengbu:

which one is which. Just seprte and identify them properly.
One more thing is the date lredy formatted in the formt you posted in your first post.

Do you mean the connection?

servername = "localhost";
username = "root";
password = ""( Didn't set password for my db);
dbname = "mywork";

The date is not really important, i can set it as text and write it our my self.

All i need is how i can bring out the table with php and insert the record inside and the user from the other end when log in to the account will see the information.

Like in the picx below
Re: Urgent Help To Display Data In Php by analogiphone: 4:40pm On Sep 22, 2015
Bros this is what I mean

Re: Urgent Help To Display Data In Php by analogiphone: 4:41pm On Sep 22, 2015
I want to display this table with other information on the users page.
Re: Urgent Help To Display Data In Php by Adesege(m): 5:16pm On Sep 22, 2015
Before we can help solve your problem, your reply to the below questions will point us to the right direction.

1. What code have you tried?
2. Can you dump your sql table here for all to see.

You should know that no one will spoon feed you with codes. Tell us where you missed it and we will correct it.

What's your level in PHP also
Re: Urgent Help To Display Data In Php by analogiphone: 5:17pm On Sep 22, 2015
Where are the gurus, make una help me Na
Re: Urgent Help To Display Data In Php by analogiphone: 6:18pm On Sep 22, 2015
Php
Re: Urgent Help To Display Data In Php by Adesege(m): 7:33pm On Sep 22, 2015
analogiphone:
Php

I know it's php but what php code have you tried?

No one will spoon feed you like I said if you haven't tried any code.
Re: Urgent Help To Display Data In Php by analogiphone: 7:50pm On Sep 22, 2015
Adesege:


I know it's php but what php code have you tried?

No one will spoon feed you like I said if you haven't tried any code.


Thanks bros, this is the code displaying the datas from my database.



<?php

if (isset($_POST['submit'])){

$id=$_POST['usr_id'];

//connecttion to the database

mysql_connect('localhost', 'root' , '');

mysql_select_db('datas');

$query = mysql_query("SELECT * FROM users WHERE id='$id'"wink;

//turn the query into an array so as to access the values from the array key.

$row = mysql_fetch_array($query);

//var_dump($row);
$layout='<div class="container">';
echo "<p>ID: .$row[id]</p>".'</br>';
echo "<p>Your first Name : .$row[Firstname]</p>".'</br>';
echo "<p>Your password : .$row[password]</p>".'</br>';
echo "<p>Your Last Name : .$row[Lastname]</p>".'</br>';
echo "<p>Your Email : .$row[email]</p>".'</br>';

$layout.='</div>';


}

Have tried losts of code to put the record inside a table.
Re: Urgent Help To Display Data In Php by Adesege(m): 7:59pm On Sep 22, 2015
analogiphone:


Thanks bros, this is the code displaying the datas from my database.



Have tried losts of code to put the record inside a table.

What code is this for? For verifying I a user is logged in? Or for logging a user in?

Nevertheless, what's the name of the table holding the date, time, and activity column? And what code have you tried in that respect?
Re: Urgent Help To Display Data In Php by Adesege(m): 8:04pm On Sep 22, 2015
What you want is to spool out all the records in a table, say user_activity, holding a user's activity on your website.

Having columns:

ID - table ID for user_activity
user_id - for the user who initiated the activity.
date (datetime type) - when the activity was made.
title - subject for the activity.

But is there any code you have tried so I can improve on it?
Re: Urgent Help To Display Data In Php by analogiphone: 8:20pm On Sep 22, 2015
Adesege:


What code is this for? For verifying I a user is logged in? Or for logging a user in?

Nevertheless, what's the name of the table holding the date, time, and activity column? And what code have you tried in that respect?


Yes this login the user by id before having access to user side, though this is not the real project I have to do this deprecate my so I don't mix up work

I have not created a table for time and date and that is why I'm confused.

I don't know how to create it in db and display it as to put in into columns ( date and current stAtus ) as for the code I've tried lots both from w3school and other materials none seems to be fixing my issues as in displaying data inside html table, like I said this table will just be part of the information to display on the user side.

The code there logged in the user, which I have done successfully, but only part I'm having issues is the table.

Also the time/date don't need be in any format, I can always write them out from the database for it to display at the user end, just code displaying the table and the update I will be doing at the users side is what I nedd
Re: Urgent Help To Display Data In Php by analogiphone: 8:23pm On Sep 22, 2015
Adesege:
What you want is to spool out all the records in a table, say user_activity, holding a user's activity on your website.

Having columns:

ID - table ID for user_activity
user_id - for the user who initiated the activity.
date (datetime type) - when the activity was made.
title - subject for the activity.

But is there any code you have tried so I can improve on it?

I've tried some, though now on my phone as I had to leave my computer when I could not fix it, been on it since mornin
Re: Urgent Help To Display Data In Php by dwebdesign(m): 8:51pm On Sep 22, 2015
Turn your query into an associative array,
And run a foreach loop to get all the results.

$row= mysql_fetch_assoc($query);

Foreach ($row as $output){
echo $output}
;

Also since you want the details displayed in table.

You also have to create table using html and structure the results of the associative array returned.



You will get all the data displayed in a table .
Re: Urgent Help To Display Data In Php by Adesege(m): 9:52pm On Sep 22, 2015
[size=35pt]<msg>..:::: Modified ...::::</msg>[/size]


This may be what you are looking for.

<table width='100%' height='100%'>
<tr>
<td>S/N</td>
<td>Date</td>
<td>Summary</td>
<td>Actions</td>
</tr>
<?php

//connect to mysql db
//It is recommended you don't use mysql functions again in new projects as it is deprecated and will be removed from future version

$sql=mysql_query('SELECT * FROM user_activity ua LEFT JOIN users us ON ua.user_id=us.id WHERE ua.user_id="".$userIDfromSession."" ORDER BY ua.date DESC') or die(mysql_error());

$num_rows=mysql_num_rows($sql);
if($num_rows>=1){
$i=1;
while($fetch=mysql_fetch_assoc($sql)){
$id=$fetch['id'];
$date=$fetch['date'];
$summary=$fetch['summary'];
echo '
<tr>
<td>'.$i.'</td>
<td>'.$date.'</td>
<td>'.$summary.'</td>
<td><a href="edit.php?id='.$id.'">Edit</a></td>
</tr>
';

$i++;
}//end while
}else{
echo '<tr>
<td>No result in database</td>
</tr>';
}

?>

</table>

I do not guarantee security for this code. Use at your risk
Re: Urgent Help To Display Data In Php by ps3o(m): 7:25am On Sep 23, 2015
it's easy. u need to understand how to alternate table rows.
I wish I could type here, but battery low.
if u are in dire need, WhatsApp 07031175291.
I'm kinda busy
Re: Urgent Help To Display Data In Php by analogiphone: 7:55am On Sep 23, 2015
Here is what I could come up with

Re: Urgent Help To Display Data In Php by analogiphone: 7:58am On Sep 23, 2015
And here is the code that gave me this result, i'm now having problem displaying this on the same page with the code i gave before so that when a user put in the ID this table will display on the user page including other information.


<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
border: 1px solid black;
}
</style>
</head>
<body>

<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "works";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}

$sql = "SELECT Date, Current_Status FROM delivery";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
echo "<table><tr><th>Date</th><th>Current Status</th></tr>";
// output data of each row
while($row = $result->fetch_assoc()) {
echo "<tr><td>". $row["Date"]. " </td><td>" . $row["Current_Status"]. "</td></tr>";

}
echo "</table>";
} else {
echo "0 results";
}

$conn->close();
?>

</body>
</html>

Re: Urgent Help To Display Data In Php by analogiphone: 10:23am On Sep 23, 2015
Adesege:
What you want is to spool out all the records in a table, say user_activity, holding a user's activity on your website.

Having columns:

ID - table ID for user_activity
user_id - for the user who initiated the activity.
date (datetime type) - when the activity was made.
title - subject for the activity.

But is there any code you have tried so I can improve on it?

My oga please still waiting to hear from you
Re: Urgent Help To Display Data In Php by analogiphone: 10:24am On Sep 23, 2015
Adesege:


What code is this for? For verifying I a user is logged in? Or for logging a user in?

Nevertheless, what's the name of the table holding the date, time, and activity column? And what code have you tried in that respect?


I want to display both the table and other details on the page, but problem is i practice both of them differently, the table is mysqli while other record i intend to display is mysql, don't know how i can display both of them.
Re: Urgent Help To Display Data In Php by Adesege(m): 7:58am On Sep 24, 2015
analogiphone:


My oga please still waiting to hear from you

I have worked on it but was banned while replying your message.

Will share the editted code with you once I change to pc mode as I'm on my phone now.

Barka de salah
Re: Urgent Help To Display Data In Php by analogiphone: 8:29am On Sep 24, 2015
Adesege:


I have worked on it but was banned while replying your message.

Will share the editted code with you once I change to pc mode as I'm on my phone now.

Barka de salah

Thanks my oga
Re: Urgent Help To Display Data In Php by Adesege(m): 11:15am On Sep 24, 2015
This may be what you are looking for.

<table width='100%' height='100%'>
<tr>
<td>S/N</td>
<td>Date</td>
<td>Summary</td>
<td>Actions</td>
</tr>
<?php

//connect to mysql db
//It is recommended you don't use mysql functions again in new projects as it is deprecated and will be removed from future version

$sql=mysql_query('SELECT * FROM user_activity ua LEFT JOIN users us ON ua.user_id=us.id WHERE ua.user_id="".$userIDfromSession."" ORDER BY ua.date DESC') or die(mysql_error());

$num_rows=mysql_num_rows($sql);
if($num_rows>=1){
$i=1;
while($fetch=mysql_fetch_assoc($sql)){
$id=$fetch['id'];
$date=$fetch['date'];
$summary=$fetch['summary'];
echo '
<tr>
<td>'.$i.'</td>
<td>'.$date.'</td>
<td>'.$summary.'</td>
<td><a href="edit.php?id='.$id.'">Edit</a></td>
</tr>
';

$i++;
}//end while
}else{
echo '<tr>
<td>No result in database</td>
</tr>';
}

?>

</table>

I do not guarantee security for this code. Use at your risk

(1) (Reply)

UK, US Non Hosted Adsense For Sale / If You’ve Been Running Facebook Ads, Or Want To Run Facebook Ads, Read This; / Flashscore Country Manager For Nigeria.

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 46
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.