Jump to content

[SOLVED] display by userid?


abs0lut

Recommended Posts

database structure

ctableiy5.th.jpg

 

I need to display this

http://img301.imageshack.us/my.php?image=g1copydp0.jpg

then, next page

the iqids are the same with the first page

the only difference is the userid(the one who post) and the cost he posted..

http://img219.imageshack.us/my.php?image=g2copysi2.jpg

then next page

iqids are the same..

cost

userid3

 

and so on...

 

could you please help me??

 

Link to comment
https://forums.phpfreaks.com/topic/108310-solved-display-by-userid/
Share on other sites

Something like this?

 

<?php
$db = new PDO('mysql:host=localhost;dbname=something', 'username', 'password');

$stmt = $db->prepare('SELECT iqid, cost, stotal FROM table WHERE userid = :userid ORDER BY stotal');
$stmt->execute(array('userid' => $_GET['userid']));

echo <<<EOF
<table>
<tr>
	<th>iqid</th>
	<th>cost</th>
	<th>stotal</th>
</tr>

EOF;

foreach ($stmt->fetchAll() as $item) {
echo <<<EOF
<tr>
	<td>{$item['iqid']}</td>
	<td>{$item['cost']}</td>
	<td>{$item['stotal']}</td>
</tr>
EOF;
}

echo '</table> ';
?>

  • 5 weeks later...

Something like this?

 

<?php
$db = new PDO('mysql:host=localhost;dbname=something', 'username', 'password');

$stmt = $db->prepare('SELECT iqid, cost, stotal FROM table WHERE userid = :userid ORDER BY stotal');
$stmt->execute(array('userid' => $_GET['userid']));

echo <<<EOF
<table>
<tr>
	<th>iqid</th>
	<th>cost</th>
	<th>stotal</th>
</tr>

EOF;

foreach ($stmt->fetchAll() as $item) {
echo <<<EOF
<tr>
	<td>{$item['iqid']}</td>
	<td>{$item['cost']}</td>
	<td>{$item['stotal']}</td>
</tr>
EOF;
}

echo '</table> ';
?>

whats the use of EOF? I couldn't understand OOP.. please help me.

Something like this?

 

<?php
$db = new PDO('mysql:host=localhost;dbname=something', 'username', 'password');

$stmt = $db->prepare('SELECT iqid, cost, stotal FROM table WHERE userid = :userid ORDER BY stotal');
$stmt->execute(array('userid' => $_GET['userid']));

echo <<<EOF
<table>
<tr>
	<th>iqid</th>
	<th>cost</th>
	<th>stotal</th>
</tr>

EOF;

foreach ($stmt->fetchAll() as $item) {
echo <<<EOF
<tr>
	<td>{$item['iqid']}</td>
	<td>{$item['cost']}</td>
	<td>{$item['stotal']}</td>
</tr>
EOF;
}

echo '</table> ';
?>

I entered http://domain.com/file.php?userid=5 in the address bar of browser

the output is only the table header

iqid  cost  total

please help me..

Archived

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

×
×
  • 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.