I am new to php but I can't seem to find a direct answer in php manuals or really anywhere on this forum for help. What I am trying to do is pull a sql_query result into a multidimensional array and then add a radio button for each row for the result. This way I can submit the values to a cookie and/or session to the next page to pull data and give more details on the subject.
Here is the code I have so far:
<?php
mysqli_connect('$db', 'user', 'abc123')
//connect to database
//query mining ops where active = 1 and type = alliance or donate
//if result = 0, echo "no current ops open"
//else, continue ->
$qresult = mysql_query("SELECT mineopnum,location,optype,starttime,playercount,isk,completed FROM mining ops WHERE completed='0' AND optype='alliance' OR optype='donate'ORDER BY mineopnum,starttime DESC")
while($info = mysql_fetch_array($qresult))
IF mysql_num_rows($qresult == '0'{
echo "no current ops open"}
//Table results:
//mineopnum //location //optype //starttime //playercount // isk // completed
//database structure layout:
//0 - mineopnum //10 - OREdenseveld //20 - OREkernite //30 - OREgleamspod //40 - OREprismaticgneiss //50 - OREark
//1 - location //11 - OREscord //21 - OREluminouskern //31 - OREbrightspod //41 - OREdarko //51 - OREcrimsonark
//2 - op type //12 - OREcondscord //22 - OREfierykern //32 - OREhemor //42 - OREobsidiano //52 - OREprimeark
//3 - starttime //13 - OREmassivescord //23 - OREomber //33 - OREvividhemor //43 - OREonyxo //53 - OREmerc
//4 - playercount //14 - OREplag //24 - OREsilveromber //34 - OREradianthemor //44 - OREcrok //54 - OREvitmerc
//5 - players //15 - ORErichplag //25 - OREgoldenomber //35 - OREhedb //45 - OREcrystalcrok //55 - OREmagmamerc
//6 - isk //16 - OREazureplag //26 - OREjaspet //36 - OREglazedhedb //46 - OREsharpcrok //56 - ICEclearicicle
//7 - completed //17 - OREpyrox //27 - OREpristinejaspet //37 - OREvitrichedb //47 - OREbistot //57 - ICEenrichedclearice
//8 - OREveld //18 - OREsolidpyrox //28 - OREpurejaspet //38 - OREgneiss //48 - OREmonobist //58 - ICEglacialmass
//9 - OREcondveld //19 - OREviscouspyrox //29 - OREspod //39 - OREiridescentgneiss //49 - OREtribist //59 - ICEsmoothglacial
$value = '0'
$radio = <input type="radio" name="openops" value="$value++">
//form into array
//add radio button at beginning of each row in array
//print array
print_r($qresult)
//private op
// query mining
// when submit is pressed, push selected radio to cookie/session
// redirect to joinminingop.php
//pulls posted data and creates cookie data which will in turn be sent to the mining op page
?>
as stated in the php notes, I want to create a radio button so that I can select the entire row of returned data and forward it to the next page for more details and optional additional code based on what button is selected from a top menu. this has to be done on every row, but I am just lost when it comes to adding "advanced" features without seeing good direct examples.
thanks in advance for the help
The first problem: you must end almost all the codes with ; character, for example:
mysqli_connect('$db', 'user', 'abc123');
Then: the while must have a start and an endign tag: { and }, if it is not declared other way. I don't know, how you would like to make this, so I only give you instruction:
<?php
mysqli_connect('$db', 'user', 'abc123');
$qresult = mysql_query("SELECT mineopnum,location,optype,starttime,playercount,isk,completed FROM mining ops WHERE completed='0' AND optype='alliance' OR optype='donate'ORDER BY mineopnum,starttime DESC");
if(mysql_num_rows($qresult == "0")){
echo("no current ops open");}
while($info = mysql_fetch_array($qresult)){
$value = '0';
$radio = "<input type='radio' name='openops' value='$value++'>";
print("".$radio."").print_r($qresult);}
?>
I didn't fixed this: $value = '0'; $radio = ""; , because it's not the good way to identify, which button did you pressed. You should find another way, for example add an extra line to sql named id, and give them PRIMARY index, so you would be able to process this later in other codes. I know, my code is not perfect, but for instruction is it good. You should watch for ; ' and for " -s.