A webpage displaying a tabular info:
In thatt table one colunm name WEB_DETAILS has
For example:
db1:app1:filename
db2:app2:filename
db3:app3:filename
db4:app4:filename
It goes on....
Now i want to add a hyperlink for each(1 to end)...The condition here is I want to create a hyperlink which show file based on app1,app2,app4....(imagine that these are folder names)..
WEB_DETAILS:The info in this comes from a query which retrives:
In that i want to split and extract based on: the app name..How to do that?
Just do it like this:
db1
It sounds like you want to create a loop that will output these HTML links. For example
<?php
for($i=1;$i<5;$i++){
echo "<a href='app$i/filename'>db$i</a><br>";
}
?>
Although I don't know how that will fit into the context of your already existing table.
Related
I'm creating a video site using PHP, and I want to insert video source code from a PHP URL.
For example, if I want to get Episode 1 from PHP, I want it like this:
example.com/player.php?=episode1
For Episode 2:
example.com/player.php?=episode2
I don't understand how to link all of the source pages with the main index page.
How can I accomplish this task?
Here's a way you could do it: Use a form on your homepage (index.html?) to select which video you want, and send it to player.php using a GET method. Then use the following on player.php:
<?php
$select = $_GET['select']; //This will be the number input for the video number
echo("<video><source src="episode$select.mp4"></video>"); //This will source the video named `episodeX.mp4`, where `X` is the select value from the form on `index.html`.
?>
Just ask if you need any additional clarification.
In my PHP application there is a link which generate total summary data. Now I need to add another link which generates current date summary data rather than total summary.
I created the link and got the query to do the same. Now the challenge is to identify which link is clicked in the function. Is there any way I can get the clicked link text from php code? So that I can differentiate between them and call the appropriate branch of code can be executed.
You can use $_GET to differenciate which link was clicked.
in your HTML, make the links like this:
<a href='my_page.php?report_id=1'>Report 1</a>
<a href='my_page.php?report_id=2'>Report 2</a>
In your PHP file (in the example above, it is my_page.php) it should have something like:
<?php
if (isset($_GET['report_id']) {
$report_id = $_GET['report_id'];
if ($report_id =='1') {
// ... generate the first report here
}
else if ($report_id=='2') {
// ... do the other stuff here
}
}
?>
You could have the links direct to different pages one page for total summary one for daily or you could put the info in the URL of the link for instance
<a href="path.php?daily_report=true>Generate daily<\a>
<a href="path.php?total_report=true>Generate total<\a>
Post your code if that doesn't help
I'm working on an export tool to Excel format. To reduce the generating time, I don't want to use PHPExcel.
This is a part of my code : http://ideone.com/HCleMO
I like to hide the first column A named ID. I tested the following code in my HTML,
CSS :
style="display:none"
HTML :
hidden="hidden"
No results with these tests. Do you know if this is possible?
Thanks in advance!
Use either of the following:
CSS
tr td:first-child{ display:none; }
jQuery
$("tr td:first-child").hide();
$("tr td").first().hide();
or if you dont want to use the psuedocodes :first-child, add same class in all first of each row and hide them using CSS/JS
For tables, you have to perform the same operation on all the elements in the same row/column. So if you want to hide the first column, give all the elements the same CSS class and then say style=display:none
We have several pages generated using PHP on our website with the following titles (for example):
http://www.mysite.com/project/category/1
http://www.mysite.com/project/category/2
http://www.mysite.com/project/category/3
Each one is created dynamically with the same page layout with each showing a different database result depending on the predefined conditions.
I would like an image to be displayed at the top of the page for just one of the results, let's say for http://www.mysite.com/project/category/2 - how can I go about this?
The relevant code on our page is this:
$category=mysql_fetch_array(mysql_query("select * from project_category where project_category_id='".$project_category_id."'"));?>
If we go down the if statement route can you show an example of how to display an example image by modifying the above code to get me started?
I would probably make it a property (can be a as simple yes/no) in the database, and use the existing db-result to determine if the category has to display a page. Although this might seem overkill - I'd definitely pick this dynamic solution over a if ($categoryId == 2) { } solution any day. Keeps it dynamic and your code clean and generic.
In the end I opted for an if statement (as found here http://www.tizag.com/phpT/if.php).
The original code above was modified in the following way:
$category=mysql_fetch_array(mysql_query("select * from project_category where project_category_id='".$project_category_id."'"));
if ( $project_category_id == "2" ) {
echo '<img src="http://www.mywebsite.com/image.jpg" width="675" height="75" border="0" />';
}?>
With a normal SELECT in the mySQL DB I select the HTML content of the final page.
I am building a way to create pages on the fly ( as any CMS does ) and I am saving the HTML code for each page inside a specific table fo my DB.
The problem is I want the content to be multi-language. But I do not know how to SELECT html code from the DB and before printing it, working on it with PHP.
I know it's hard to understand, this is why I have an example :)
$q='SELECT * FROM pages WHERE Page="'.$page.'"';
$r=mysql_query($q) or die(mysql_error());
while($row = mysql_fetch_array($r)) {
$content = $row['Content'];
}
return $content;
}
The Content of the variable $content, will be something like:
<div id="hello">{$foo}</div>
where {$foo} is in fact a PHP variable and must be run by the PHP code before printing the final HTML.
How can I do that? Also please consider I will have many {$foo} variables into the content, so I must find a way to replace all of them and to make the PHP working on them before printing the final HTML code.
Can you help me? :)