I will try to be more specific.
Search Results from an php/mysqli query are put into a table.
This is the code for the table:
<tr>
<td bgcolor="#FFFFFF" style="padding-right:7;" id="Photo1<?php echo $uid ?>">
<a href="../view_profile/view_profile.php?id=<?php echo $uid; ?>">
<img src="../../users/<?php echo $gender; ?>/<?php echo $email; ?>/Profile/<?php echo $img; ?>" style="height:70; width:70;">
</a>
</td>
<td onMouseOver="serched_name_over1(<?php echo $uid;?>)" onMouseOut="serched_name_out1(<?php echo $uid;?>)" width="500" bgcolor="#FFFFFF" id="Name_bg1<?php echo $uid; ?>">
<a href="../view_profile/view_profile.php?id=<?php echo $uid;?>" id="Name_font1<?php echo $uid;?>"><?php echo $name; ?>
</a>
</td>
</tr>
I run the query and results are shown on website.
Source Code:
<table cellspacing="0" border="0">
<tr>
<td bgcolor="#FFFFFF" style="padding-right:7;" id="Photo156">
<a href="../view_profile/view_profile.php?id=56">
<img src="../../users/Male/jonnycash#gmail.com/Profile/GABRIEL ALCANTAR ALCALA.png" style="height:70; width:70;">
</a>
<a href="../view_profile/view_profile.php">
<img src="../../users/Male/jonnycash#gmail.com/Profile/GABRIEL ALCANTAR ALCALA.png" style="height:70; width:70;">
</a>
</td>
<td onMouseOver="serched_name_over1(56)" onMouseOut="serched_name_out1(56)" width="500" bgcolor="#FFFFFF" id="Name_bg156">
<a href="../view_profile/view_profile.php?id=56" id="Name_font156">
Jonny Cash </a>
</td>
</tr>
<tr>
<td colspan="2"> <hr style="border-color:#CCCCCC;"> </td>
</tr>
</table>
Now, the info I want is shown on the website, however...
THE LINK does not work on the website (i click on the img and nothing), but on the Source Code it does (i click on the link and it takes me to page).
I have tried echoing in parts to construct the path, but no use. I tried and also, nothing. I tried using the htmlspecialchars and htmlentities. And nothing. I have even tried doing a regular html code inside the table along side the results... and nothing. It does not link.
What am I doing wrong?
If you need to see more code, please let me know to attach more.
Please help.
Related
I'm trying to get a better understanding of PHP Simple HTML DOM and am kinda stuck on the following.
I am trying to retrieve information from one of my user pages by using the following code :
$dom = file_get_html('http://127.0.0.1/comments/top-commenters/');
foreach($dom->find('tr[id*=commenter]') as $result) {
print_r($result->innertext);
}
Which produces for each commenter profile ($result->innertext) the following :
<td class="Position"># 3 </td>
<td class="img" align="center">
<a href="/images/users/814ocnqlN6.jpg">
<img src="/images/users/814ocnqlN6.jpg" info="Image" border="0"/></a>
<a uid="814ocnqlN6"></td>
<td> <b>User 3.</b>
<div class="tiny">Most recent comments</div>
</td>
<td class="NumCredits"> 471 </td>
<td class="NumComments"> 5.439 </td>
<td class="PercUpVotes"> 93% </td>
Now if I would like to access within each result (same foreach loop) for example :
<td class="Position"># 3 </td>
And
<td class="NumComments"> 5.439 </td>
What would be the best way to accomplish this ?
Try:
$dom = file_get_html('http://127.0.0.1/comments/top-commenters/');
foreach($dom->find('tr[id*=commenter]') as $result) {
print_r($result->find('td.Position'));
print_r($result->find('td.NumComments'));
}
}
I am trying to make multiple buttons in PHP. I am new to html and PHP. I am unable to saw the problem in the code. Its not giving error but do nothing when I click on the button.
Here is the piece of my code
<html>
<head></head>
<body>
<table>
<tbody>
<tr>
</tr>
</tbody>
</table>
<table border="5" cellpadding="0" cellspacing="0" margin-bottom="1px" width="100%" style="color:navy">
<tbody>
<tr>
<td> <b> Teacher's Name </b> </td>
<td> <b> Courses </b> </td>
<td> <b> Feedback </b> </td>
</tr>
<!--?php while ($row = mysql_fetch_row($subjects)) {
$Teacher_Names = mysql_query("SELECT Name FROM teachers where Teacher_ID = $row[1]");
$Name = mysql_fetch_row($Teacher_Names)?-->
<tr>
<td>
<!--?php echo $Name[0];?--></td>
<td>
<!--?php echo $row[0]; ?--> </td>
<td>
<form method="POST" action="CourseFeedbackForm.php">
<img type="button" src="books.jpg" height="30" width="30" id="<?php $button.$count?>" name="submit" value="<?php $row[1]?>">
<!--?php $count = $count + 1; ?-->
<img src="horizontal1.jpg" height="30" style="padding-left:0px">
<img type="button" src="teachers.jpg" height="30" width="30" id="<?php $button.$count?>" name="submit" value="<?php $row[1]?>">
<!--?php $count = $count + 1; ?-->
</form></td>
</tr>
<!--?php } ?-->
</tbody>
</table>
</body>
</html>
It kind of took me a while to understand what you are doing there, but not I still did not understand everything. Why are you calling <img type="button">? In order to get a button, you know, that thing that you can click and it executes a piece of code, use <button type="submit"></button>. Almost everything you've done there is wrong. I'm not an expert, but I really can't see the reason you would try to use the <img> tag to create a button.
Offtopic: Learn to use <div></div>. It is much more flexible than a table, and table's are old and outdated.
For my uni project i have created a website for my local rugby team...
I have a database of players and in that database i have a column for profile picture. I was told to just put the path to the image in the player record which i did. The photo doesnt load just the line i put it there. The path i inserted below....
H:\WebDesign2\Xampp\htdocs\BedlinogRFC\images\Benji.jpg
Below is my dreamweaver code:
<div class="playerProfilePhotoContainer">
<table height="250" width="299" border="0" cellpadding="3">
<caption>
Player Photo
</caption>
<tr>
<td><img src="<?php echo $row_Recordset1['ProfilePhoto']; ?>" alt="Profile Photo of Player"/></td>
</tr>
</table>
</div>
Can anybody show me where i am going wrong or where i need to change?
Thanks
This:
<td height="235"><?php echo $row_Recordset1['ProfilePhoto']; ?></td>
Should be:
<td height="235"><img src="<?php echo $row_Recordset1['ProfilePhoto']; ?>" alt=""/></td>
I must be doing something wrong here. It doesn't work like it should but its a simple task that serves only one purpose, display the photos from my ./images and ./thumbnails folder to my PHP web form. It is not fully finished but I would just like to get the functionality of being able to see my displayed photos on my page.
Image name are the same in both folders, size is different. Here are some sample photo names in the two folders. IMG786_3, IMG3413, IMG31.
Here is the query to my database in which it retrieves all the title, description, and file name of all photos stored in my database. I put them into an array so I can access them based on an index.
$imgQuery = "SELECT FileName, Title, Description FROM PICTURE WHERE OwnerID='$id' LIMIT 0,7";
if($imgResult = mysqli_query($link, $imgQuery))
{
while($imgRow = mysqli_fetch_row($imgResult))
{
$filename[] = $imgRow[0];
$title[] = $imgRow[1];
$description[] = $imgRow[2];
}
}
Below is the code that is supposed to display these strings of photos from the two folders I have. When I click on a thumbnail, it is suppose to bring that full size image from the ./images folder and the entire index of the filename, description, and title will change.
print <<<photo
<body>
<span> <?php echo $error; ?> </span>
<form action='MyAlbum.php' method='post'>
<table>
<tr><td colspan='7' ><h2 align='center'>$name's Album</h2></td>
</tr>
<tr><td colspan='7' >$title[$i]</td>
</tr>
<tr><td colspan='5' ><img src="./images/$filename[$i]" /></td><td colspan='2'>$description[$i] </td>
</tr>
<tr>
<td><img src="./thumbnails/$filename[0]" /></td> <td><img src="./thumbnails/$filename[1]" /></td> <td><img src="./thumbnails/$filename[2]" /></td>
<td><img src="./thumbnails/$filename[3]" /></td><td><img src="./thumbnails/$filename[4]" /></td> <td><img src="./thumbnails/$filename[5]" /></td>
<td><img src="./thumbnails/$filename[6]" /></td>
</tr>
</table>
</form>
</body>
</html>
photo;
Your heredoc is wrong.
1st - You should iterate over file name to get the thumbnails.
2nd - you are getting images with variable $i which looks like an iterator but no for loop present.
I have modified the heredoc into html which works. You will still need javascript/jquery(i prefer) to achieve your image replacement to work. By default when the page loads the first image is displayed.
<html>
<body>
<span> <?php //echo $error; ?> </span>
<form action='MyAlbum.php' method='post'>
<table border="1">
<tr><td colspan='7' ><h2 align='center'><?php echo $name ?>'s Album</h2></td>
</tr>
<tr><td colspan='7' >
<?php echo $title[0]; ?></td>
</tr>
<tr>
<td colspan='5' ><img src="./images/<?php echo $filename[0] ?>" /></td>
<td colspan='2' ><?php echo $description[0]; ?></td>
</tr>
<tr>
<?php foreach($filename as $f): ?>
<td><img src="./thumbnails/<?php echo $f ?>" /></td>
<?php endforeach; ?>
</tr>
</table>
</form>
</body>
</html>
One more thing. using 3 different arrays is not efficient. 1 associative array can achieve this work fine. Lemme know if you have doubts.
Dins
i have one php code for button creation
for($i=1;$i<=$n;$i++)
{
$row=mysql_fetch_array($result);
if($row['btn_color']==1)
$btbg="side-button5.png";
if($row['btn_color']==2)
$btbg="side-button6.png";
if($row['btn_color']==3)
$btbg="side-button7.png";
if($row['btn_color']==4)
?>
<br>
<table width="200" height="50" border="0" cellpadding="0" cellspacing="0">
<tr>
<td background="images/<?php echo $btbg ; ?>" style="background-repeat:no-repeat"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="66">
<div align="center" class="buttonside">
<p>
<a class="buttonside" href="vpa.php?pgid=<?php echo $row['page_id']; ?>">
<?php echo $row['btn_text']?></p>
</a>
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
<?php
}
?>
this code is working fine but the link is on text, i want to put link on full button(background)
Thanks
To make the button 'linkable', you'll need to wrap the <a> tag around it.
However, you're going to need to change your HTML markup structure - you can't wrap an anchor around a table cell!