Jump to content

n00b - displaying content of a specific row from MySQL in a table


Go to solution Solved by requinix,

Recommended Posts

Hi

I am a noob so please forgive my 1% knowledge on php but got to start somewhere.

 

Brief...

I am creating a bonus ball purchase app. A user can goto www.mysite.com/results.php?ID=1 and purchase a number 1-14 as a bit of a "finally thought of a reasonably complex php/sql scripting" See screen print of the final result for the end user. I am trying to create as much as I can and have created the registration, login, forgot password... so im slowly getting there.

 

My SQL table is roughly like

ID (Pri Key, Unique)

Creator
Date
A Photo

 

firstly...

I want to be able to type in a url of a page based on the ID of the line in the table eg www.mysite.com/results.php?ID=1

how would i do this?

 

secondly...

How do i display in a fancy table/php vertically

================

CREATOR | John Smith

DATE | 1/1/2018

PHOTO1 | <display a photo from /images/photos/ID1a.jpg << the 'a' represents the 1st of 3 possible photos. But i could replicate the code to add ID1b and ID1c

================

I think with this answered i could work out how to add the rest of the fields

 

Thirdly...

On my registration, is there a php line i could add that sends me an email with the persons USERNAME when they register so i can go in and activate manually.

 

 

Many Thanks

Lee

 

TODO...

 

  • A creator creates a bonus ball raffle
  • The raffle page the end use see's sees paypal links which need to be linked to the creators paypal
  • When a user buys a number, the purchase option disappears and replaces the field with their name
  • The "available numbers" field decreases from 14 to 0 based on how many numbers purchased
  • Once the available numbers - 0 the status change to "FULL" from "AVAILABLE"
  • Once the last number is purchased displays the next lottery draw date being Tue, Wed, Fri or Sat (here in the uk) 
Edited by bleemster

1. If by "type in" you actually mean "click a link" then the answer is to make a link. Using HTML. It's really quite simple so give it a shot.

2. How much HTML do you know?

3. That's not too difficult but get everything else working first.

 

Sounds more like a CSS/HTML question than a php one.

It's a bit of everything.

sorry, it is all *.php files, with integrated html, rather than the other way around.

 

Im pretty good with HTML and can read a html script and thoroughly understand it... its the PHP part I cannot write very well. I can kinda-read php and get an understanding.

 

Here is the very START of my display script, but it doesnt display anything other than the HTML table header - and from what i see this as if it was working is it would display horizontally where i want vertically. I know its just a matter of jigging the th and tr tags but wondered what the jig is lol. More so need to get it working first before i can move it around

 

And yes i mean create a link... i want the URL to display this PARTICULAR entry from the table based on the ID = 1 (or what ever number... so ID = 9 would be a completely different game

 

<?php

session_start();
require('connect.php');
if(!isset($_SESSION['username']))
{
   header("Location:login.php");
}
 
 
 
$sql = "SELECT * FROM `thunderball`";
 
 
echo "<table border='1'>
<tr>
<th>CREATOR HEAD</th>
<th>AVAILABILITY HEAD</th>
</tr>
";
 
 
while($row = mysqli_fetch_array($sql))
{
echo "<tr>";
echo "<td>" . $row['CREATOR'] . "</td>";
echo "<td>" . $row['AVAILABILITY'] . "</td>";
echo "</tr>";
}
echo "</table>";
 
mysqli_close;
?>
Edited by bleemster
  • Solution

If you want a link to /results.php?ID=1 then the HTML looks like

<a href="/results.php?ID=1">Some text in here</a>
Obviously you wouldn't write 1 - instead you'd use the value in $row.

 

As for the table, all you have to do is think in terms of rows and columns. With the table you want, "CREATOR" and "John Smith" would be in the first row and in the first and second columns respectively. Since HTML tables are written as rows containing columns you'd do

<tr>
<th>CREATOR</th>
<td>John Smith</td>
</tr>
Rinse and repeat for the other rows. Remember to remove the header row since your table won't be using one.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.