php - Display data for specific ID -
i have been trying while figure out how display data specific row within database based on id.
say want link survivaloperations.net/page/mso?p=contracts&id=#
where id=# id of row pulling data in database
how pull , display data database using link shown above?
i tried google it, didn't know google find related things
any or links references appreciated!
here had tried:
<?php if ($p == contracts) { $id = isset($_get['id']) ? (int)$_get['id'] : 0; // if $_get['id'] exists, return integer, otherwise use sentinel, id's start 1, 0 works if ($id != 0): // assume specific news item meaning know it's 1 result $query = 'select * contracts id=' . $id . ' limit 1'; // try use limit 1, no need add steps in database lookup endif; mysql_select_db('survival_contracts'); $result = mysql_query($query); //$result = mysql_query($query) or die(mysql_error()); // loop through results while ($row = mysql_fetch_array($result)) { // , use'em wish echo("<div class='mso_body_wrap'> <div id='mso_news_container'> <div class='mso_news_wrap'> <div class='mso_news_top'>$row2[contract_type]</div> <div class='mso_news_poster'> <div class='mso_poster_avatar'><img src='images/tank.jpg'></div> <div class='mso_poster_info'>for <a href='#'>$row2[unit]</a><br/>by: <a href='http://www.survivaloperations.net/user/$row2[userid]-$row2[username]/'>$row2[username]</a> </div> </div> <div class='mso_news_content'> <div class='mso_news_body'> callsign: $row2[callsign]<br/> urgency: $row2[urgency]<br/> location: $row2[location]<br/> grid: $row2[grid]<br/> enemy activity: $row2[enemy_activity]<br/> hours since lasrt contact: $row2[contact_hours]<br/><br/> supplies requested: $row2[supplies]<br/> comments: $row2[comments] </div> </div> <div class='mso_news_bottom'></div> </div> </div>"); } ?>
google $_get variable in php , have @ database connection using pdo or mysqli
http://php.net/manual/en/mysqli.query.php
http://php.net/manual/en/pdo.query.php
after added code:
mysql_* deprecated. try switch either mysqli or pdo , have @ link above.
Comments
Post a Comment