DEVILofDARKNESS Posted March 31, 2009 Share Posted March 31, 2009 Hi, How should I do the following? I have made up a mysql table wich looks like the following: region_id int region_name varchar(50) region_population int region_outputs int region_landsize int I want to let everything shown (except the region_id) Like this: region name region pop. reg outputs reg landsize [Radio Box <= which has as value the region_name] . "<br>" I thought this had to be with the foreach loop? Or is it poosible too with a while? Thanks! Quote Link to comment Share on other sites More sharing options...
lonewolf217 Posted March 31, 2009 Share Posted March 31, 2009 this will get you the basic output. <?php $sql = "select * from `table_name1"; $result = mysql_query($sql) or die(echo mysql_error()); while($row = mysql_fetch_array($result)) { echo "<input type=\"checkbox\" value=\"".$row['region_name']."\" name=\"region_name\">"." ".$row['region_population']." ".$row['region_outputs']." ".$row['region_landsize']."<br>"; } Quote Link to comment Share on other sites More sharing options...
Maq Posted March 31, 2009 Share Posted March 31, 2009 This is done with a WHILE loop after you create and execute your query. You need to learn a little more about the basics of PHP and MySQL. Read more here. Quote Link to comment Share on other sites More sharing options...
trq Posted March 31, 2009 Share Posted March 31, 2009 You might be after? <?php $sql = "select * from tbl"; if ($result = mysql_query($sql)) { if (mysql_num_rows($result)) { while ($row = mysql_fetch_array($result)) { foreach ($row as $k => $v) { if ($k != 'region_id') { echo $v . " "; } } } } } ?> Quote Link to comment Share on other sites More sharing options...
DEVILofDARKNESS Posted March 31, 2009 Author Share Posted March 31, 2009 I just never had used a foreach loop and I thought it was easier as with a while, but I just will make it with the while like I'm used to do. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.