Page 1 of 1

[Need Help] Show Database Value in a Box

Posted: Mon Jan 30, 2012 2:25 am
by exphp
[Need Help] Show Database Value in a Box

Hello, PHP master.
I'm newbie in PHP.
And I have a question about PHP coding.

I have table in my database. Like this : download/file.php?id=1505&mode=view

And I have to show the value of ticket_code in my page. Like this: download/file.php?id=1504&mode=view

Both of images are also in attachment files.
Note:
[*]the value of ticket_code can be changed. So, if the value of ticket_code increase for each ticket_type, the number of box for

ticket_code also will increase. If value of ticket_code decrease, the number of box for ticket_code also will decrease.
[*]Each ticket_code contains of a direct link to the form that show information about the ticket_code, such us ticket_price etc.
I need help to create the PHP code for this case.
Does anybody have any idea about it? Please help me. :help:
Firstly, thanks for your attantion. :)

Re: [Need Help] Show Database Value in a Box

Posted: Mon Jan 30, 2012 6:19 am
by theserve
something like:

Code: Select all

$ticket_type = "";
$query = mysql_query("SELECT * FROM ticket ORDER BY ticket_type ASC");
while($data = mysql_fetch_assoc($query))
{
if($data['ticket_type'] != $ticket_type)
{
$ticket_type = $data['ticket_type'];
echo '<div style="header">' . $data['ticket_type'] . "</div>";
}
echo '<div class="box">' . $data['ticket_code'] . '</div>';
}
and add css styles for header and box.

Re: [Need Help] Show Database Value in a Box

Posted: Mon Jan 30, 2012 9:55 am
by exphp
theserve wrote:something like:

Code: Select all

$ticket_type = "";
$query = mysql_query("SELECT * FROM ticket ORDER BY ticket_type ASC");
while($data = mysql_fetch_assoc($query))
{
if($data['ticket_type'] != $ticket_type)
{
$ticket_type = $data['ticket_type'];
echo '<div style="header">' . $data['ticket_type'] . "</div>";
}
echo '<div class="box">' . $data['ticket_code'] . '</div>';
}
and add css styles for header and box.
Firstly, thank you very much for you. :)
I've tried the code and it works.
But, I still have a problem about the limit.
Such us, the limit for each row is 5 or 10 or etc.
Just like in the picture.
For example: there are 10 ticket_code for VIP : V-01 up to V-10. Then I need to make a limit for each row is 5. So, the ticket_code for each ticket_type in the page will be shown as:
  1. V-01 V-02 V-03 V-04 V-05
  • V-06 V-07 V-08 V-09 V-10
Do you have any idea to create the code for this case ?
Please help me more to understand for creating the code.
First of all: Thank you very much. :)