Jump to content

loop and instert help


siriusdave

Recommended Posts

hi all can someone please help me i have two file (below)

 

 

makepreds.php

 

/**
* siriusfootball 1.0.0
* Copyright © 2006-2007 Siriusdave, All Rights Reserved
**/
session_start();
require ('includes/config.php');
require ('templates/'. $settings['template'] .'/makepreds.template.php');

global $settings,$tbl_prefix,$user;

if ($user['status'] != '1')
please_log_in();


$preds_action = $_GET['a'];

if ($preds_action == 'add_preds') {
$date = getTodaysDate(date("Y-m-d"));
if (isset($_POST['Predict'])) {



}
}

$date = GetDateFromDatetime(date("Y-m-d"));
$week = GetThisWeek();
if (array_key_exists("week", $_GET)) {
$week = $_GET["week"];
}

$match_query = mysql_query("SELECT *,p.* FROM ". $tbl_prefix ."matchdata AS m LEFT JOIN ". $tbl_prefix ."predictiondata AS p ON (m.matchid = p.pmatchid AND p.userid='".$user['id']."' AND m.lid = p.lid ) WHERE m.week=$week AND m.lid='0' ORDER BY m.week, m.matchdate");

$preds = array();
while($match_row = mysql_fetch_assoc($match_query)) {

$points = 0;




$preds[] = array (
    'matchid' => $match_row["matchid"],
    'matchdate' => convertDatetimeToScreenDate($match_row["matchdate"]),
    'hometeam' =>  $match_row["hometeam"],
    'awayteam' => $match_row["awayteam"],
'homescore' => $match_row["homescore"], 
    'awayscore' =>$match_row["awayscore"],
    'phomescore' => $match_row["phomescore"], 
    'pawayscore' =>$match_row["pawayscore"],
    'week' => $week,
'PTS'=> $points,
    'bonus' => $match_row["bonuspoints"],
'homeflag'=> $match_row["hometeam"],
'awayflag'=> $match_row["awayteam"]
);

}	
$page_title = "Predictions";
// Load template
template_preds();



 

makepreds.template.php

 

/**
* siriusfootball 1.0.0
* Copyright © 2006-2007 Siriusdave, All Rights Reserved
*
* Template: Siriusdave by siriusdave
**/


function template_preds() {
global $settings, $lang, $preds,$user;

template_header2();

foreach ( $preds as  $p) {}
echo '<div class="content_box_header">
      <a href="', $settings['siteurl'] ,'/">', $settings['sitename'] ,'</a> >Predictions </div>
<div class="content_box">
<form method="POST" action="makepreds.php?a=add_preds">';

echo'
    <table align="center" width="100%" >
    <tr>
    <td colspan="11" align="center" class="TBLROWRED">Predictions for '.$user['username'].' [Week '.$p['week'].']</td>
    </tr>
    <tr>
    <td width="80" align="center" class="TBLROWRED">Date</td>
    <td class="TBLROWRED" > </td>
    <td width="150" align="center" class="TBLROWRED">Home</td>
    <td align="center" class="TBLROWRED">G</td>
    <td align="center" class="TBLROWRED">v</td>
    <td align="center" class="TBLROWRED">G</td>
    <td width="150" align="center" class="TBLROWRED">Away</td>
<td class="TBLROWRED" > </td>
      <td align="center" class="TBLROWRED">Result</td>
    <td align="center" class="TBLROWRED">PTS</td>
    <td width="60" align="center" class="TBLROWRED">Bonus Points</td>
    </tr>';
foreach ( $preds as  $p) {
if(strtotime($p['matchdate']) < time()) {
echo'<tr>
<td width="80" align="center" class="TBLROWGREEN">Kicked Off</td>
<td class="TBLROWGREEN"><img src="flags/'.$p['homeflag'].'.png";"></td>
<td width="150"align="center" class="TBLROWGREEN">'.$p['hometeam'] .'</td>
<td align="CENTER" class="TBLROWGREEN">'.$p['phomescore'].'<br></td>
<td align="CENTER" class="TBLROWGREEN">v</td>
<td align="CENTER" class="TBLROWGREEN">'.$p['pawayscore'].'</td>
<td width="150" align="center" class="TBLROWGREEN">'.$p['awayteam'] .'</td>
<td class="TBLROWGREEN"><img src="flags/'.$p['awayflag'].'.png";"></td>
<td align="center" class="TBLROWGREEN">'.$p['homescore'] .' - '.$p['awayscore'] .' </td>
<td align="center" class="TBLROWGREEN">'.$p['PTS'].'</td>
<td width="60" align="center" class="TBLROWGREEN">'. $p['bonus'].'</td>
</tr>';

}else{

echo'<tr>
<td width="80" align="center" class="TBLROWGREEN">'.$p['matchdate'].'</td>
<td class="TBLROWGREEN"><img src="flags/'.$p['homeflag'].'.png";"></td>
<td width="150"align="center" class="TBLROWGREEN">'.$p['hometeam'] .'</td>
<td align="CENTER" class="TBLROWGREEN">';
if($p['phomescore']==''){
echo'
<select name="phomescore">
<option>'.$p['phomescore'].'</option>
<option>0</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
<option>11</option>
<option>12</option>
<option>13</option>
<option>14</option>
<option>15</option>
</select>';
}else{
echo''.$p['phomescore'].'';
}
echo'<br></td>
<td align="CENTER" class="TBLROWGREEN">v</td>
<td align="CENTER" class="TBLROWGREEN">';
if($p['pawayscore'] ==''){
echo'
<select name="pawayscore" >
<option>'.$p['pawayscore'].'</option>
<option>0</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
<option>11</option>
<option>12</option>
<option>13</option>
<option>14</option>
<option>15</option>
</select>';
}else{
echo''.$p['pawayscore'].'';
}
echo'<br></td>
<td width="150" align="center" class="TBLROWGREEN">'.$p['awayteam'] .'</td>
<td class="TBLROWGREEN"><img src="flags/'.$p['awayflag'].'.png";"></td>
<td align="center" class="TBLROWGREEN">'.$p['homescore'] .' - '.$p['awayscore'] .' </td>
<td align="center" class="TBLROWGREEN">'.$p['PTS'].'</td>
<td width="60" align="center" class="TBLROWGREEN">'. $p['bonus'].'</td>
</tr>

<input type="text" name="matchid" value="'. $p['matchid'].'">';
}
}
echo'<tr><td colspan="11" align="center" >
<input class="submit" type="SUBMIT" name="Predict" value="Predict These score">
</td></tr></table>
</form>
</div>';
echo '
</div>
<div style="clear: both;"></div>
</div><div style="clear: both;"></div>';

template_footer2();

}

 

the first makepreds.php which gets the info from the database as array

the secound is makepreds.template.php is the template file which displays the info from the array useing a loop

 

i have add code to this to make it in to a form,

what i need is what code i need to add to make it so when people put in there phomescore and pawayscore and hit submit it enters the info for that matchid in to the database ...

 

i have started by adding this code

$preds_action = $_GET['a'];

if ($preds_action == 'add_preds') {
$date = getTodaysDate(date("Y-m-d"));
if (isset($_POST['Predict'])) {



}
}

 

but dont know where to go from here i have tryed load of diffrent code but had no luck please can som one help me...

:'(

 

you can see what i am trying to do here

http://www.siriusjewelleryonline.com/newfootball/makepreds.php

 

username test

password test

Link to comment
https://forums.phpfreaks.com/topic/105628-loop-and-instert-help/
Share on other sites

no i know how to do that, the script connect to a database.. and i know instert into ect just not sure how to get all the values from the looped form in makepred.template.php

ie

matchid 1 phomescore1 pawayscore1

matchid 2 phomescore2 pawayscore2

 

to instert into the datebase i have try everything ...so i not sure how to got about it ...

Archived

This topic is now archived and is closed to further replies.

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