I'm not the best at explaining things but here I go,
On a different site, I have 10 elements that i want to get and assign to variables
this is how they are
element 1:
<div class="username_header dynamic_fontsize" style="font-size: 48px; top: 0px;">
<span class="username">[element 1]</span>
<span class="user_online_msg">stuff</span>
</div>
elements 2-10
<div class="forum_profile_right_block">
<table border="0" width="97%" cellspacing="2" cellpadding="5">
<tbody>
<tr>
<td>
<div style="font-color:black; font-size:1em">abc2</div>
</td>
<td colspan="2" align="center" bgcolor="#F0F0F0">[element 2]</td>
</tr>
<tr>
<td>
<div style="font-color:black; font-size:1em">abc34</div>
</td>
<td align="center" bgcolor="#F0F0F0">[element 3]</td>
<td align="center" bgcolor="#F0F0F0">[element 4]</td>
</tr>
<tr>
<td>
<div style="font-color:black; font-size:1em">abc5</div>
</td>
<td colspan="2" align="center" bgcolor="#F0F0F0">[element 5]</td>
</tr>
<tr>
<td>
<div style="font-color:black; font-size:1em">abc6</div>
</td>
<td colspan="2" align="center" bgcolor="#F0F0F0">[element 6]
</td>
</tr>
<tr>
<td>
<div style="font-color:black; font-size:1em">abc7</div>
</td>
<td colspan="2" align="center" bgcolor="#F0F0F0">[element 7]</td>
</tr>
<tr>
<td>
<div style="font-color:black; font-size:1em">abc8</div>
</td>
<td colspan="2" align="center" bgcolor="#F0F0F0">[element 8]</td>
</tr>
<tr>
<td>
<div style="font-color:black; font-size:1em">abc9</div>
</td>
<td colspan="2" align="center" bgcolor="#F0F0F0">
<div style="display:inline-block;">[element 9]</div>
<div style="display: inline-block; position: relative; top: 1px;"><img src="images/msdropdown/icons/blank.gif" class="flag us"></div>
</td>
</tr>
<tr>
<td>
<div style="font-color:black; font-size:1em">abc10</div>
</td>
<td colspan="2" align="center" bgcolor="#F0F0F0">[element 10]
</td>
</tr>
</tbody>
</table>
<br>
</div>
Related
I tried to do it but the big problem is foreach here i have the foto:
Problem
Here is my table picture
Here is the code but still have problem:
<div class="row">
<table class="table table-bordered table-striped table-highlight">
<tbody>
<tr height="100">
<td rowspan="6" height="120" width="3%" style="vertical-align: middle;">
<p style="white-space: nowrap;writing-mode: vertical-lr;transform: rotate(180deg);font-weight: bold;"><font >Here is my title </font></p>
</td>
<td colspan="3">
<font>Name</font>
</td>
<td width="64">
<font>Article</font>
</td>
<td width="64">
<font>Price</font>
</td>
<td width="64">
<font>Date</font>
</td>
</tr>
<tr height="20">
<td colspan="3" rowspan="5" height="120" ></td>
<td rowspan="5" style="vertical-align: top;"></td>
<td rowspan="5" style="vertical-align: top;"></td>
<td rowspan="5" style="vertical-align: top;"></td>
</tr>
<tr height="15">
</tr>
<tr height="15">
</tr>
<tr height="15">
</tr>
<tr height="15">
</tr>
</tbody>
</table>
</div>
How can i do it so that when i use foreach it will insert new td and the vertical Here is my title will be there?
ok, so you're using php here's a very basic example on how you can do that, i'm assuming you already did query and the fetching part, and this is a guess of your data structure, you can adjust it to your liking :
<div class="row">
<table class="table table-bordered table-striped table-highlight">
<tbody>
<tr height="100">
<td rowspan="100%" height="120" width="3%" style="vertical-align: middle;">
<p style="white-space: nowrap;writing-mode: vertical-lr;transform: rotate(180deg);font-weight: bold;"><font >Here is my title </font></p>
</td>
<td colspan="3">
<font>Name</font>
</td>
<td width="64">
<font>Article</font>
</td>
<td width="64">
<font>Price</font>
</td>
<td width="64">
<font>Date</font>
</td>
</tr>
<?php
foreach($data as $key => $value){
echo '<tr height="20">';
echo '<td colspan="3">'.$value['name'].'</td>';
echo '<td width="64" style="vertical-align: top;">'.$value['article'].'</td>';
echo '<td width="64" style="vertical-align: top;">'.$value['price'].'</td>';
echo '<td width="64" style="vertical-align: top;">'.$value['date'].'</td>';
echo '</tr>';
}
?>
</tbody>
</table>
</div>
here's a fiddle : https://jsfiddle.net/kkpjx328/
I hope this helps .
PS : on your next question, please consider adding the data structure and if possible, an example or code sample of what you've tried so far so we can provide more specific answers
I have web page look like this
<td valign="top">
<table width="100%" border="0" cellspacing="2" cellpadding="1" class="main_tb3">
<tr>
<td colspan="2">
<div align="center">
<a href="/title/name.php" target="_blank">
<img src="./movie/image.jpg" alt="TitleName" border="0" height="100" width="225" />
</a>
</div>
</td>
</tr>
<tr>
<td colspan="2"><h1 align="center">Title - secondname</h1></td>
</tr>
<tr>
<td><span class="style10">Cat1 :</span></td>
<td>1st name</td>
</tr>
<tr>
<td width="32%"><span class="style10">Cat2 :</span></td>
<td width="68%"><b><i>secondname</i></b></td>
</tr>
<tr>
<td><span class="style10">cat4 :</span></td>
<td>Bla bla</td>
</tr>
<tr>
<td><span class="style10">Cat3 :</span></td>
<td>thirdName2</td>
</tr>
</table>
</td>
<td valign="top">
<table width="100%" border="0" cellspacing="2" cellpadding="1" class="main_tb3">
<tr>
<td colspan="2">
<div align="center">
<a href="/title/name.php" target="_blank">
<img src="./movie/image.jpg" alt="TitleName" border="0" height="100" width="225" />
</a>
</div>
</td>
</tr>
<tr>
<td colspan="2"><h1 align="center">Title - secondname</h1></td>
</tr>
<tr>
<td><span class="style10">Cat1 :</span></td>
<td>1st name</td>
</tr>
<tr>
<td width="32%"><span class="style10">Cat2 :</span></td>
<td width="68%"><b><i>secondname</i></b></td>
</tr>
<tr>
<td><span class="style10">cat4 :</span></td>
<td>Bla bla</td>
</tr>
<tr>
<td><span class="style10">Cat3 :</span></td>
<td>thirdName2</td>
</tr>
</table>
</td>
I would like to get certain values from this site using python regex.
After <div align="center"> I like to get href value: "/title/name.php" and img src: "./movie/image.jpg" and Title - secondname from <h1 align="center">Title - secondname</h1>
i have tried this:
regex = 'class="main_tb3"*\n<a href="(.+?)" target="_blank">\n<img src="(.+?)"'
please help me
you can use below regex
For href value: <a href="(.*?)"
For Image src: <img src="(.*?)"
For Title: titleid=12">(.*?)<
You will find it a lot simpler to install something like BeautifulSoup to do this:
from bs4 import BeautifulSoup
html = """
<td valign="top">
<table width="100%" border="0" cellspacing="2" cellpadding="1" class="main_tb3">
<tr>
<td colspan="2">
<div align="center">
<a href="/title/name.php" target="_blank">
<img src="./movie/image.jpg" alt="TitleName" border="0" height="100" width="225" />
</a>
</div>
</td>
</tr>
<tr>
<td colspan="2"><h1 align="center">Title - secondname</h1></td>
</tr>
<tr>
<td><span class="style10">Cat1 :</span></td>
<td>1st name</td>
</tr>
<tr>
<td width="32%"><span class="style10">Cat2 :</span></td>
<td width="68%"><b><i>secondname</i></b></td>
</tr>
<tr>
<td><span class="style10">cat4 :</span></td>
<td>Bla bla</td>
</tr>
<tr>
<td><span class="style10">Cat3 :</span></td>
<td>thirdName2</td>
</tr>
</table>
</td>
<td valign="top">
<table width="100%" border="0" cellspacing="2" cellpadding="1" class="main_tb3">
<tr>
<td colspan="2">
<div align="center">
<a href="/title/name.php" target="_blank">
<img src="./movie/image.jpg" alt="TitleName" border="0" height="100" width="225" />
</a>
</div>
</td>
</tr>
<tr>
<td colspan="2"><h1 align="center">Title - secondname</h1></td>
</tr>
<tr>
<td><span class="style10">Cat1 :</span></td>
<td>1st name</td>
</tr>
<tr>
<td width="32%"><span class="style10">Cat2 :</span></td>
<td width="68%"><b><i>secondname</i></b></td>
</tr>
<tr>
<td><span class="style10">cat4 :</span></td>
<td>Bla bla</td>
</tr>
<tr>
<td><span class="style10">Cat3 :</span></td>
<td>thirdName2</td>
</tr>
</table>
</td>"""
soup = BeautifulSoup(html)
for table in soup.find_all("table", class_="main_tb3"):
print table.find('a').get('href')
print table.find('h1').text
For the HTML you have given, this will print the following:
/title/name.php
Title - secondname
/title/name.php
Title - secondname
I wanted to use TCPDF to generate a PDF report. but every time it shows me error on line 16928 and I can't understand what to do...
It would be great if you could help me
here is my code:
<?php
$html = "
<html>
<head>
<link rel='stylesheet' href='form.css'>
</head>
<body>
<div class='header'>
<h4>وزارت بهداشت، درمان و آموزش کشور</h4>
<h4>Ministry of Health & Medical Education</h4>
<table>
<tr>
<td class='engterm'>University of medical science:</td><td class='val'>[SAMPLE_ECHO]</td><td class='perterm'>دانشگاه علوم پزشکی:</td>
</tr>
<tr>
<td class='engterm'>Medical center:</td><td class='val'>[SAMPLE_ECHO]</td><td class='perterm'>مرکز پزشکی آموزشی درمانی:</td>
</tr>
</table>
</div>
<div class='body'>
<table class='main' border='1'>
<tr>
<td class='main' colspan='1' rowspan='2' style='text-align: left;'>
<table style='margin: 0 auto;'>
<tr>
<td class='engterm'>Clinic no.:</td><td class='val'>[sample]</td><td class='perterm'>شماره درمانگاهی:</td>
</tr>
</table>
</td>
<td class='main' colspan='2' rowspan='2' style='text-align: center; width: 50%'>
<h4>برگ خلاصه پرونده</h4>
<h4>Unit Summery Sheet</h4>
</td>
<td class='main' colspan='1' rowspan='2' style='direction: ltr;'>
<table style='margin: 0 auto;'>
<tr>
<td class='engterm'>Unit no.:</td><td class='val'>[sample]</td><td class='perterm'>شماره پرونده:</td>
</tr>
</table>
</td>
</tr>
<tr></tr>
<tr>
<td class='main' rowspan='1'>
<table class='data'>
<td>Attending Physician:</td><td>SampleData</td><td>پزشک معالج:</td>
</table>
</td>
<td class='main' rowspan='2'>
<table class='data'>
<tr><td>Ward:</td><td>Sample</td><td>بخش:</td></tr>
<tr><td>Room:</td><td>Sample</td><td>اتاق:</td></tr>
<tr><td>Bed:</td><td>Sample</td><td>تخت:</td></tr>
</table>
</td>
<td class='main' rowspan='1'>
<table class='data'>
<td>Name:</td><td>Sample</td><td>نام:</td>
</table>
</td>
<td class='main' rowspan='1'>
<table class='data'>
<td>Family name:</td><td>Sample</td><td>نام خانوادگی:</td>
</table>
</td>
</tr>
<tr>
<td class='main'>
<table class='data'>
<td>Admission date:</td><td>Sample</td><td>تاریخ پذیرش:</td>
</table>
</td>
<td class='main'>
<table class='data'>
<td>Date of Birth:</td><td>Sample</td><td>تاریخ تولد:</td>
</table>
</td>
<td class='main'>
<table class='data'>
<td>Father's name:</td><td>Sample</td><td>نام پدر:</td>
</table>
</td>
</tr>
<tr>
<td class='main'>
<table class='data'>
<td></td><td>Sample</td><td>تاریخ ترخیص:</td>
</table>
</td>
<td class='main'>
<table class='data'>
<td>Occupation:</td><td>Sample</td><td>شغل:</td>
</table>
</td>
<td class='main'>
<table class='data'>
<td>Marriage status:</td>
<td>
<input type='radio' name='marriage_status' value='married'>متاهل / Married<br>
<input type='radio' name='marriage_status' value='single'>مجرد / Single
</td>
<td>وضعیت تاهل:</td>
</table>
</td>
<td class='main'>
<table class='data'>
<td>Sex:</td>
<td>
<input type='radio' name='sex' value='male'>مرد / Male<br>
<input type='radio' name='sex' value='female'> زن / Female
</td>
<td>جنسیت:</td>
</table>
</td>
</tr>
<tr>
<td colspan='4'>
<table class='data'>
<td colspan='1' style='text-align: left;'>Address:</td><td colspan='2'>Sample</td><td colspan='1' style='text-align: right;'>آدرس:</td>
</table>
</td>
</tr>
<tr>
<td colspan='4'>
<table class='data'>
<td colspan='1'>Final Diagnosis:</td>
<td colspan='2'>Sample</td>
<td colspan='1'>تشخصی نهایی:</td>
</table>
</td>
</tr>
<tr>
<td colspan='4'>
<table class='data'>
<td colspan='1'>Medical & Surgical Procedures:</td>
<td colspan='2'>Sample</td>
<td colspan='1'>اقدامات درمانی و اعمال جراحی:</td>
</table>
</td>
</tr>
<tr>
<td colspan='4'>
<table class='data'>
<td colspan='1'>Results of Paraclinical Examination:</td>
<td colspan='2'>Sample</td>
<td colspan='1'>پاراكلينيكي آزمايشات نتايج:</td>
</table>
</td>
</tr>
<tr>
<td colspan='4'>
<table class='data'>
<td colspan='1'>Disease Progress (Cause of Death):</td>
<td colspan='2'>Sample</td>
<td colspan='1'>سیر بیماری (درصورت فوت، علت مرگ):</td>
</table>
</td>
</tr>
<tr>
<td colspan='4'>
<table class='data'>
<td colspan='1'>Patient's Condition on Discharge:</td>
<td colspan='2'>Sample</td>
<td colspan='1'>وضعیت بیمار هنگام ترخیض:</td>
</table>
</td>
</tr>
<tr>
<td colspan='4'>
<table class='data'>
<td colspan='1'>Recommendations after discharge:</td>
<td colspan='2'>Sample</td>
<td colspan='1'>توصیههای پس از ترخیض:</td>
</table>
</td>
</tr>
<tr>
<td colspan='4'>
<table class='data'>
<td colspan='1'>Attending Physician's Name & Signature:</td>
<td colspan='2'>Sample</td>
<td colspan='1'>نام و امضا پزشک معالج:</td>
</table>
</td>
</tr>
</table>
</div>
</body>
</html>";
require_once('tcpdf/tcpdf.php');
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
if (#file_exists(dirname(__FILE__).'/lang/eng.php')) {
require_once(dirname(__FILE__).'/lang/eng.php');
$pdf->setLanguageArray($l);
}
$pdf->SetFont('helvetica', '', 9);
$pdf->AddPage();
$pdf->writeHTML($html, true, 0, true, 0);
$pdf->lastPage();
$pdf->Output('htmlout.pdf', 'I');
?>
When reading the page from web server, it shows me the following error:
Notice: Undefined index: cols in /home/aien/public_html/Arash.Sammak/JSON Return/tcpdf/tcpdf.php on line 16928
You have to add a valid <thead> element to every table. TCPDF parses the <thead> element to determine the number of columns in a table when it outputs tables in PDF.
Also, check your HTML twice is valid or not if some other errors keep occurring.
Hope this helps.
So, I have this PHP scraper code and HTML below that I want to scrape using Xpath.
When I try to scrape every #href, it shows outerHTML 14, when it is supposes to be 14
The #href is cut in half where the space are. What causes this?
$content = $xpath->query('//a');
foreach($content as $c){
var_dump(htmlspecialchars($c->C14N())); echo '<br>';
}
The one above is the CURL code.
Here is the HTML.
<div class="outercalendar" id="maincalendar821"><table class="calendarHeader">
<tbody><tr>
<td><input type="button" onclick="AjxGetMainCalendarMonth('2', '2015', '821')" value="<"></td>
<td class="calendarHeader" colspan="5">March 2015</td>
<td><input type="button" onclick="AjxGetMainCalendarMonth('4', '2015', '821')" value=">"></td>
</tr>
</tbody></table>
<table class="calendar">
<tbody><tr>
<td class="calendarDay">S</td>
<td class="calendarDay">M</td>
<td class="calendarDay">T</td>
<td class="calendarDay">W</td>
<td class="calendarDay">T</td>
<td class="calendarDay">F</td>
<td class="calendarDay">S</td>
</tr>
<tr>
<td class="calendar">1</td>
<td class="calendar"> </td>
<td class="calendar"> </td>
<td class="calendar"> </td>
<td class="calendar"> </td>
<td class="calendar"> </td>
<td class="calendar">7</td>
</tr>
<tr>
<td class="calendar">8</td>
<td class="calendar"> </td>
<td class="calendar"> </td>
<td class="calendar"> </td>
<td class="calendar"> </td>
<td class="calendar"> </td>
<td class="calendar">14</td>
</tr>
<tr>
<td class="calendar">15</td>
<td class="calendar"> </td>
<td class="calendar"> </td>
<td class="calendar"> </td>
<td class="calendar"> </td>
<td class="calendar"> </td>
<td class="calendar">21</td>
</tr>
<tr>
<td class="calendar">22</td>
<td class="calendar"> </td>
<td class="calendar"> </td>
<td class="calendar"> </td>
<td class="calendar"> </td>
<td class="calendar"> </td>
<td class="calendar">28</td>
</tr>
<tr>
<td class="calendar">29</td>
<td class="calendar"> </td>
<td class="calendar"> </td>
<td class="calendar"> </td>
<td class="calendar"> </td>
<td class="calendar"> </td>
<td class="calendar"> </td>
</tr>
</tbody></table>
</div>
The issue could be in the structure of the info stored in the tag.
I would suggest starting with a more detailed xpath:
//a/#href
so your initial code would be:
$content = $xpath->query('//a/#href');
I have the following view (home_view.php)
<?php $this->load->helper('url');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>diluks eCommerce - Home</title>
<link href="<?php echo base_url();?>Public/scripts/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form action="<?php echo base_url();?>index.php/welcome_controller" method="post">
<div class="container">
<?php
$userpermission = $this->session->userdata('userpermission');
if($userpermission==1){
include 'header-admin.php';
}
else if($userpermission==2){
include 'header-user.php';
}
else{
include 'header-guest.php';}
?>
<div class="level3 clearfix">
<?php include 'shopping-sidebar.php'; ?>
<div class="body-content">
<div class="image-slider">
<img src="<?php echo base_url();?>Public/img/main-img.png" width="785" height="220" />
</div>
<div class="seperate-space">
<div class="separate-title"><a class="bold-captions">Latest Picks</a>
</div>
</div>
<div class="items">
<div class="item-holder">
<table align="center" width="256px" cellpadding="0px" cellspacing="0px">
<tr>
<td class="item-info" align="center" height="34px">Item name</td>
</tr>
<tr>
<td class="item-info" align="center" height="230px">
<img src="<?php echo base_url();?>Public/img/sunflowers.png" width="256" height="230" />
</td>
</tr>
<tr>
<td class="item-info" align="center" height="34px">$30</td>
</tr>
<tr>
<td class="item-info" align="center" height="35px"><input name="btn_read" class="readbtn" value="Read More" /></td>
</tr>
</table>
</div>
<div class="item-holder">
<table align="center" width="256px" cellpadding="0px" cellspacing="0px">
<tr>
<td class="item-info" align="center" height="34px">Item name</td>
</tr>
<tr>
<td class="item-info" align="center" height="230px">
<img src="<?php echo base_url();?>Public/img/treecard.png" width="256" height="230" />
</td>
</tr>
<tr>
<td class="item-info" align="center" height="34px">$30</td>
</tr>
<tr>
<td class="item-info" align="center" height="35px"><input name="btn_read" class="readbtn" value="Read More" /></td>
</tr>
</table>
</div>
<div class="item-holder">
<table align="center" width="256px" cellpadding="0px" cellspacing="0px">
<tr>
<td class="item-info" align="center" height="34px">Item name</td>
</tr>
<tr>
<td class="item-info" align="center" height="230px">
<img src="<?php echo base_url();?>Public/img/3-flowers.png" width="256" height="230" />
</td>
</tr>
<tr>
<td class="item-info" align="center" height="34px">$30</td>
</tr>
<tr>
<td class="item-info" align="center" height="35px"><input name="btn_read" class="readbtn" value="Read More" /></td>
</tr>
</table>
</div>
<div class="item-holder">
<table align="center" width="256px" cellpadding="0px" cellspacing="0px">
<tr>
<td class="item-info" align="center" height="34px">Item name</td>
</tr>
<tr>
<td class="item-info" align="center" height="230px">
<img src="<?php echo base_url();?>Public/img/sunflowers.png" width="256" height="230" />
</td>
</tr>
<tr>
<td class="item-info" align="center" height="34px">$30</td>
</tr>
<tr>
<td class="item-info" align="center" height="35px"><input name="btn_read" class="readbtn" value="Read More" /></td>
</tr>
</table>
</div>
<div class="item-holder">
<table align="center" width="256px" cellpadding="0px" cellspacing="0px">
<tr>
<td class="item-info" align="center" height="34px">Item name</td>
</tr>
<tr>
<td class="item-info" align="center" height="230px">
<img src="<?php echo base_url();?>Public/img/treecard.png" width="256" height="230" />
</td>
</tr>
<tr>
<td class="item-info" align="center" height="34px">$30</td>
</tr>
<tr>
<td class="item-info" align="center" height="35px"><input name="btn_read" class="readbtn" value="Read More" /></td>
</tr>
</table>
</div>
<div class="item-holder">
<table align="center" width="256px" cellpadding="0px" cellspacing="0px">
<tr>
<td class="item-info" align="center" height="34px">Item name</td>
</tr>
<tr>
<td class="item-info" align="center" height="230px">
<img src="<?php echo base_url();?>Public/img/3-flowers.png" width="256" height="230" />
</td>
</tr>
<tr>
<td class="item-info" align="center" height="34px">$30</td>
</tr>
<tr>
<td class="item-info" align="center" height="35px"><input name="btn_read" class="readbtn" value="Read More" /></td>
</tr>
</table>
</div>
<div class="item-holder">
<table align="center" width="256px" cellpadding="0px" cellspacing="0px">
<tr>
<td class="item-info" align="center" height="34px">Item name</td>
</tr>
<tr>
<td class="item-info" align="center" height="230px">
<img src="<?php echo base_url();?>Public/img/sunflowers.png" width="256" height="230" />
</td>
</tr>
<tr>
<td class="item-info" align="center" height="34px">$30</td>
</tr>
<tr>
<td class="item-info" align="center" height="35px"><input name="btn_read" class="readbtn" value="Read More" /></td>
</tr>
</table>
</div>
<div class="item-holder">
<table align="center" width="256px" cellpadding="0px" cellspacing="0px">
<tr>
<td class="item-info" align="center" height="34px">Item name</td>
</tr>
<tr>
<td class="item-info" align="center" height="230px">
<img src="<?php echo base_url();?>Public/img/treecard.png" width="256" height="230" />
</td>
</tr>
<tr>
<td class="item-info" align="center" height="34px">$30</td>
</tr>
<tr>
<td class="item-info" align="center" height="35px"><input name="btn_read" class="readbtn" value="Read More" /></td>
</tr>
</table>
</div>
<div class="item-holder">
<table align="center" width="256px" cellpadding="0px" cellspacing="0px">
<tr>
<td class="item-info" align="center" height="34px">Item name</td>
</tr>
<tr>
<td class="item-info" align="center" height="230px">
<img src="<?php echo base_url();?>Public/img/3-flowers.png" width="256" height="230" />
</td>
</tr>
<tr>
<td class="item-info" align="center" height="34px">$30</td>
</tr>
<tr>
<td class="item-info" align="center" height="35px"><input name="btn_read" class="readbtn" value="Read More" /></td>
</tr>
</table>
</div>
</div>
</div>
</div>
<div style="clear:both"></div>
<div class="level4">
<div class="footer-area">
<div class="lined-space"></div>
<div class="site-map" align="left">
<table>
<tr>
<td class="footer-text">About Us</td>
<td class="footer-text">Facebook</td>
</tr>
<tr>
<td class="footer-text">Contact Us</td>
<td class="footer-text">Twitter</td>
</tr>
<tr>
<td class="footer-text">FAQs</td>
<td class="footer-text">Terms & Conditions</td>
</tr>
<tr>
<td class="footer-text">Help</td>
</tr>
</table>
</div>
<div class="developer-info">
<a class="developers-text">Designed & Developed By Diluks Software Solutions.</a>
</div>
</div>
</div>
</div>
</form>
</body>
</html>
And the controller for that (welcome_controller) is the following,
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Welcome_controller extends CI_Controller {
function __construct(){
parent::__construct();
}
public function index()
{
if(isset($_POST["btn_login"])){
$data = array();
$this->load->model('category_model');
$data['categories'] = $this->category_model->getCategories();
$this->load->view('login_view', $data);
}
else if(isset($_POST["btn_adminpanel"])){
$this->load->view('adminpanel_view');
}
else if(isset($_POST["btn_logout"])){
$this->session->sess_destroy();
$data = array();
$this->load->model('category_model');
$data['categories'] = $this->category_model->getCategories();
$this->load->view('home_view', $data);
}
else if(isset($_POST["btn_read"])){
$this->load->view('readmore_view');
}
}
}
Now I need to redirect the page to readmore_view onClick of the button named 'btn_read', But it doesn't respond. (Note : There are 9 buttons with the same name, and I have tested changing one of them and give the particular name in controller, it didn't work either.) Please suggest me a solution.
<input name="btn_read" class="readbtn" value="Read More" /> There is no input type. You have to mention the type of input.
<input type="submit" name="btn_read" class="readbtn" value="Read More" />