lets say i retrieve all of the values where their position belongs to top8.I populate them out in a table and instead of displaying different kinds of values , it displays 3 tables with 3 different values, how is this so? any help so that different values belonging to certain values will all be displayed out? i only need one table with 3 different values.
<?
$facebookID = "top8";
mysql_connect("localhost","root","password") or die(mysql_error());
mysql_select_db("schoutweet") or ie(mysql_error());
$data= mysql_query("SELECT schInitial FROM matchTable WHERE position='".$facebookID."'")
or die(mysql_error());
while($row = mysql_fetch_array($data))
{
?>
<center>
<table border="0" cellspacing="0" cellpadding="0" class="tbl_bracket">
<tr>
<td class="brack_under cell_1"><a href="www.facebook.com"/>team 1.1><?= $row['schInitial']?><a/></td>
<td class="cell_2"> </td>
<td class="cell_3"> </td>
<td class="cell_4"> </td>
<td class="cell_5"> </td>
<td class="cell_6"> </td>
</tr>
<tr>
<td class="brack_under_right_up">team 1.2><?= $row['schInitial']?></</td>
<td class="brack_right"><!--1.2.1--></td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td class="brack_right"><!--2.1--></td>
<td class="brack_under"><!--3.1--></td>
<td><!--here?--></td>
<td><!--there?--></td>
<td><!--everywhere?--></td>
</tr>
</table>
</center>
<?
}
?>
</body>
That's because your <table> tag is within the loop! Place the <table> tag outside the while loop.
place your table tags outside the while loop
Because your writing the table tag inside the while loop. Everything inside the loop is done each loop cycle. If you only want to have one table in the output, you'll have to open and close the table outside of the loop, like this:
$data= mysql_query("SELECT schInitial FROM matchTable WHERE position='".$facebookID."'")
or die(mysql_error());
?>
<center>
<table border="0" cellspacing="0" cellpadding="0" class="tbl_bracket">
<?
while($row = mysql_fetch_array($data))
{
?>
<tr>
<td class="brack_under cell_1"><a href="www.facebook.com"/>team 1.1><?= $row['schInitial']?><a/></td>
<td class="cell_2"> </td>
<td class="cell_3"> </td>
<td class="cell_4"> </td>
<td class="cell_5"> </td>
<td class="cell_6"> </td>
</tr>
<tr>
<td class="brack_under_right_up">team 1.2><?= $row['schInitial']?></</td>
<td class="brack_right"><!--1.2.1--></td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td class="brack_right"><!--2.1--></td>
<td class="brack_under"><!--3.1--></td>
<td><!--here?--></td>
<td><!--there?--></td>
<td><!--everywhere?--></td>
</tr>
<?
}
?>
</table>
</center>
That will, however, print three rows per loop and therefore per record (but you have references to the table contents in two of them, so I suppose that's what you want?).
Also take care about some not well-formed HTML you have there (e.g. the > character in the expression team 1.1> / team 1.2>. If you want to print the > character to the browser, encode it as HTML entity (> for this case). You also have a probably superfluous </ in the first column of the second row (</</td>).
you need to echo the HTML part as well in the while loop like
echo '<table>';
Related
I need to retrieve confused html from a mail. so I have done it before using the class but here is different...so I need the part in the table---td-div with the details about the module subsciber. but before this table you have others. here is the html:
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<div>Nome: GIANCARLO</div>
</td>
</tr>
<tr>
<td>
<div>Cognome: CANNONE</div>
</td>
</tr>
<tr>
<td>
<div>Codice Fiscale: CNNGCR65T01A285W</div>
</td>
</tr>
<tr>
<td>
<div>Email: giancarlocannone#hotmail.com</div>
</td>
</tr>
</tbody>
</table>
I have one php page in which I have changed font for input to devnagri. I need to display it in next php page and also need to insert those to mysql.
first page index.php contains this details......
<table width="535" height="54" border="1">
<tbody>
<tr>
<td height="23">नाम</td>
<td><input type="text" name="name" id="name" style="font-family: Preeti">
</td>
</tr>
<tr>
<td height="23">काम</td>
<td><input type="text" name="job" id="job" style="font-family: Preeti">
</td>
</tr>
</tbody>
</table>
my second page post.php contains
<table width="535" height="54" border="1">
<tbody>
<tr>
<td height="23">नाम</td>
<td><?php
echo $_POST['name'];
?></td>
</tr>
<tr>
<td height="23">काम</td>
<td><?php
echo $_POST['job'];
?></td>
</tr>
</tbody>
</table>
when I type कला in name and खेप in job input
it displays relative english letters on the 2nd page .....
where as I need to display as it displays in input.
I also need to insert those input to mysql and again need to display those mysql data to another page....
I am not getting the way to display and stuck at this point so insert and select query is yet to be done....
Need help to figure it out.
Thanx a lot Phil.
<table width="535" height="54" border="1">
<tbody>
<tr>
<td height="23">नाम</td>
<td style="font-family: Preeti"><?php
echo $_POST['name'];
?></td>
</tr>
<tr>
<td height="23">काम</td>
<td style="font-family: Preeti"><?php
echo $_POST['job'];
?></td>
</tr>
</tbody>
</table>
It has displayed preeti font...
Still INSERT and SELECT query is remaining.
I'm working with PHP and MySQL on a student registration project.
There is a table named programme from which I have to find the value of total no. of registration in every campus.
There are 4 campuses (Delhi, Noida, Jaipur and Mumbai) and 27 courses with 2 date of exam cycle (12-04-2014 and 07-06-2014).
I have to display total no. of registration in every campus for every course in every campus. for e.g. Delhi campus I made this query for first date:
$sql="select * from programme where campus1='delhi' && course1='Fashion Design (FD)' && examdate='12-04-2014'";
$result=mysql_query($sql);
$delhi=mysql_num_rows($result);
and it does echoe the result into the td for the first cycle.
But now I have to make a single query for 27 courses.
I've thought to do this via switch cases, but am unable to do it. How should I proceed?
Here is the Table format which I have to fill from database; it's for one course and similarly there are 26 other courses:
<table class="table table-bordered">
<tr>
<th> </th>
<th colspan="10">Course Wise Registration Report</th>
<th> </th>
</tr>
<tr>
<th>PROGRAMME</th>
<th colspan="2">Delhi</th>
<th colspan="2">Noida</th>
<th colspan="2">Jaipur</th>
<th colspan="2">Mumbai</th>
<th colspan="2">Cycle</th>
<th>TOTAL</th>
</tr>
<tr>
<td> </td>
<td>Cycle-1</td>
<td>Cycle-2</td>
<td>Cycle-1</td>
<td>Cycle-2</td>
<td>Cycle-1</td>
<td>Cycle-2</td>
<td>Cycle-1</td>
<td>Cycle-2</td>
<td>Cycle-1</td>
<td>Cycle-2</td>
<td> </td>
</tr>
<tr>
<td>UG-FD</td>
<td><?php echo $delhi; ?></td>
<td></td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>UG-CD</td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>UG-TD</td>
------------
</tr>
UG-JD
------------
<th>Total</th>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
Here is DB table structure:
examdate campus1 course1 campus2 course2
Here is the format which i want :
Here is the screenshot of DB table programme:
You need to create a query something below.
SELECT COUNT(*) FROM programme
WHERE campus1 = 'delhi' AND examdate = '12-04-2014'
GROUP BY course1
Listen! this is not the final solution. Your tables structures seems not well organized. It should go through several normalization process. Until I have your complete set of table structure I can not give you a final answer.
For now.. just copy and run the above query in your PhpMyAdmin and see what it produce, then you will get an idea.
NOTE : I think it is not possible for you to explain well enough, if so, put some screenshots of your all tables grabbed form PhpMyAdmin and screenshot of your final result how it should looks like.
The query you want is:
SELECT campus1
,course1
,examdate
,count(*) AS count
FROM programme
WHERE examdate IN ('12-04-2014','07-06-2014')
GROUP BY campus1,course1,examdate
You may want to expand the WHERE clause if you don't want to include all campuses and courses.
here different solutions for ur problem
in the main page use combo and selecting campus, list details of that campus below that
combo using a ajax page
combo posting page you just receive the value of that combo means compus name and add to
ur sql directly.
If we use switch we want to enter a input to switch. depending on this input we can
change the output in each case.
I'm grabbing the content from all the td's in this table with the class="job" using this.
$table01 = $salary->find('table.table01');
$rows = $table01[0]->find('td.job');
Then I'm using this to output it which works, but obviously only outputs it as plaintext, I need to do some more with it...
foreach($table01[0]->find('td.job') as $element) {
$jobs .= $element->plaintext . '<br />';
}
Ultimately I would like it outputted to this format. Notice the a href is using the job name and replacing spaces and / with a -.
<tr>
<td class="small"> Graphic Artist / Designer
$23,755 – $55,335 </td>
</tr>
<tr>
<td class="small"> Sales Associate<br />
$15,577 – $56,290 </td>
</tr>
<tr>
<td class="small"> Film / Video Editor<br />
$24,184 – $94,493 </td>
</tr>
Heres the table im scraping
<table cellpadding="0" cellspacing="0" border="0" class="table01">
<tr>
<td class="head">Test</td>
<td class="job">
Graphic Artist / Designer<br/>
$23,755 – $55,335
</td>
</tr>
<tr>
<td class="head">Test</td>
<td class="job">
Sales Associate<br/>
$15,577 – $56,290
</td>
</tr>
<tr>
<td class="head">Test</td>
<td class="job">
Film / Video Editor<br/>
$24,184 – $94,493
</td>
</tr>
</table>
may be better to use regexps
<?php
$html=file_get_contents('1.html');
$jobs='';
if(preg_match_all("/<tr>.*?<td.*?>.*?<\/td>.*?<td\sclass=\"job\">.*?<a.+?href=\"(.+?)\".+?>(.*?)<\/a>(.*?)<\/td>.*?<\/tr>/ims", $html, $res))
{
foreach($res[1] as $i=>$uri)
{
$uri=strtolower(urldecode($uri));
$uri=preg_replace("/_\/_/",'-',$uri);
$uri=preg_replace("/_/",'-',$uri);
$jobs.='<tr><td class="small"> '.$res[2][$i].''.$res[3][$i].'</td></tr>'."\n";
}
}
echo $jobs;
I m working on module in which i have to make pdf from php page. I m Using tcpdf for that but m facing one problem that file contain some mysql queries and php coding which is not executed by pdf page.
$prn_no = $_POST['prn_no'];
$current_sem = $_POST['current_sem'];
$qr_fetch_sem_res_id = mysql_query("SELECT * FROM table1 WHERE ((prn='$prn_no') AND (semisterName='$current_sem'))")or die(mysql_error());
$qr_fetch_sem_result_ans = mysql_fetch_array($qr_fetch_sem_res_id);
<tr>
<td colspan="11" align="left" valign="middle">Programme Name: <?php echo $qr_fetch_sem_result_ans['programme_name'];?></td>
</tr>
<tr>
<td colspan="11" align="center" valign="middle"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="27%">Seat No.: <?php echo $qr_fetch_sem_result_ans['seatNo'];?></td>
<td width="3%"> </td>
<td width="22%">PR No. : <?php echo $qr_fetch_sem_result_ans['prn'];?></td>
<td width="2%"> </td>
<td width="17%">Semester : <?php echo $qr_fetch_sem_result_ans['semisterName'];?></td>
<td width="1%"> </td>
<td width="25%">Month / Year Of Exam : <?php echo $qr_fetch_sem_result_ans['month_year_of_exam'];?> </td>
<td width="3%"> </td>
</tr>
<tr>
<td colspan="3">Name: <?php echo $qr_fetch_sem_result_ans['student_name'];?></td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td colspan="7">College / Institute: <?php echo $qr_fetch_sem_result_ans['institute_name'];?></td>
<td> </td>
</tr>
</table></td>
</tr>
I'm going to go out on a limb here and suggest that you run your queries fist and then build your pdf file. If you run the queries after you build the pdf then of course it will not have access to your data. If that doesn't help then I must not understand what you're asking.