Jump to content

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

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.