rogerteixeira Posted November 2, 2013 Share Posted November 2, 2013 Hi, i'm trying to show the crimes side by side in two column (its a game)like:Crime1 Crime2in the engine show:Crime1Crime2the code is: TableHeader("Crimes"); echo "<table class='plainTable'>"; $result = $db->Execute("select crime_id,name,description,condition_code,success_r ate,stat_cost,jail_time,crime_pic from crimes order by crime_id"); foreach ($result as $row) { echo "<tr valign='top'>"; $res = true; if ($row[3] != null && $row[3] != "") $res = NWEval("return {$row[3]};"); if ($row[5] > $userStats[GetConfigValue("CrimeStatCost", "crime")]->value) $res = false; echo "<td width='1%'>"; echo "<img src='$row[7]'/>"; echo "</td>"; $perc = 100; if ($row[4] != null && $row[4] != "") $perc = round(NWEval("return {$row[4]};") * 100.0, 0); if ($perc > 100) $perc = 100; echo "<td><b>" . Translate($row[1]) . ":</b>" . Translate($row[2]) . ""; echo Translate("<font color='green'><b>Success rate") . ": $perc%</b></font>" . Translate("<font color='red'><b>Cost") . ": {$row[5]}</b></font>"; LinkButton('Do it', 'index.php?p=crime&id={$row[0]}', null, null, false, $res); echo "</td>"; echo "</tr>"; } $result->Close(); echo "</table>"; how to do this?thx guys Link to comment https://forums.phpfreaks.com/topic/283545-display-result-side-by-side/ Share on other sites More sharing options...
Barand Posted November 2, 2013 Share Posted November 2, 2013 here's an example using floating divs $db = new mysqli(HOST, USERNAME, PASSWORD, DATABASE); $sql = "SELECT name, score FROM score"; $res = $db->query($sql); $i = 0; while ($row = $res->fetch_assoc()) { echo <<<TXT <div style='float:left; width:200px; height:50px; padding:10px'> {$row['name']} <br> <span style='font-size:20pt; font-weight: 600'>{$row['score']}</span> </div> TXT; if (++$i%2==0) echo "<div style='clear:both'></div>"; } Result attached Link to comment https://forums.phpfreaks.com/topic/283545-display-result-side-by-side/#findComment-1456638 Share on other sites More sharing options...
rogerteixeira Posted November 2, 2013 Author Share Posted November 2, 2013 can you explain better? i'm newbie and i am learning thx Link to comment https://forums.phpfreaks.com/topic/283545-display-result-side-by-side/#findComment-1456641 Share on other sites More sharing options...
Barand Posted November 3, 2013 Share Posted November 3, 2013 We enclose the output from each record in a <div>,,</div> which is defined as float:left. This means each div will be placed next to the previous one instead of underneath (default behaviour). To ensure that we start a new row every other record (when our counter $i has a remainder of zero when divided by 2) we output a <div> to clear the floating behaviour then start again on the next row of two Link to comment https://forums.phpfreaks.com/topic/283545-display-result-side-by-side/#findComment-1456645 Share on other sites More sharing options...
rogerteixeira Posted November 3, 2013 Author Share Posted November 3, 2013 solved! thx dude Link to comment https://forums.phpfreaks.com/topic/283545-display-result-side-by-side/#findComment-1456646 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.